I'm attempting to automate deployment of SharePoint Apps (Add-ins) to specific sites (Not adding to the app catalog) for an on-premises installation of SharePoint 2016. The user I am running this under is in the farm administrators group and I am able to upload the app to the app catalog and add it to the target site manually. To do this I am using the following powershell:
"Importing $fullPath to $SiteCollection"
$spapp = Import-SPAppPackage -Path "$fullPath" -Site "$SiteCollection" -Source ObjectModel -Confirm:$false
"Installing $spapp"
$app = Install-SPapp -Web "$Web" -Identity $spapp -Confirm:$false
$fullPath is a valid path to the .app file, $SiteCollection points to the site collection that I want to install this on and web is actually the same as site collection in this case.
I am getting the below error:
Import-SPAppPackage : Cannot open database "{Database Name}" requested by the login. The login failed. Login failed for user '{DOMAIN\user}'.
The user indicated in the error message is the same user who can add it to the catalog manually.
My question is actually two-fold:
First, any clues on that error and/or what further permissions I should ask the DBA for (Also a justification would be super helpful)
Second: I am doing this to automate deployments through TFS, is there a better way to do it? There is a TFS SharePoint deployment release activity, but that requires that the app be published to the catalog and we are trying to enable point-solutions to a specific site/web.