Powershell script to deploy .dacpac not working via Octopus

Good afternoon,

I was hoping someone may be able to help me with a powershell script I’m trying to automate with Octopus.

The script is attached, but I wrote it to deploy my database via a .dacpac.

What’s odd is that if I run the script via a command prompt it runs ok with this command:

powershell -executionPolicy bypass -file “c:\temp\Deploy.ps1”

But if I run the same script against the same .dacpac from Octopus I get the following error.

C:\OctopusTentacle\Applications\Test\MyApp\1.2.5612.22500\Content\MyApp.Database.dacpac
Info 13:33:16
Microsoft.SqlServer.Dac.DacServicesException
Could not generate deployment script.
at Microsoft.SqlServer.Dac.DacServices.GenerateDeployScript(DacPackage package, String targetDatabaseName, DacDeployOptions options, Nullable1 cancellationToken) at GenerateDeployScript(Object , Object[] ) at System.Management.Automation.DotNetAdapter.AuxiliaryMethodInvoke(Object target, Object[] arguments, MethodInformation methodInformation, Object[] originalArguments) Info 13:33:18 Microsoft.SqlServer.Dac.DacServicesException Could not deploy package. at Microsoft.SqlServer.Dac.DeployOperation.Microsoft.SqlServer.Dac.IOperation.Run(OperationContext context) at Microsoft.SqlServer.Dac.DacServices.InternalDeploy(IPackageSource packageSource, Boolean isDacpac, String targetDatabaseName, DacDeployOptions options, CancellationToken cancellationToken, DacLoggingContext loggingContext) at Microsoft.SqlServer.Dac.DacServices.Deploy(DacPackage package, String targetDatabaseName, Boolean upgradeExisting, DacDeployOptions options, Nullable1 cancellationToken)
at Deploy(Object , Object[] )
at System.Management.Automation.DotNetAdapter.AuxiliaryMethodInvoke(Object target, Object[] arguments, MethodInformation methodInformation, Object[] originalArguments)

Can you think of any reasons why I’d be able to run this OK from the the cmd prompt but not Octopus?

Any thoughts greatly appreciated,

Cheers,

Doug

Hi Doug,

Thanks for getting in touch! Tentacle runs under a different user, so things you might have access to do and run, Tentacle might not. There are two things you can do.
The first is you can test how any script will behave on a Tenatcle using our Script Console. http://docs.octopusdeploy.com/display/OD/Script+Console
And the second is you can change the user that Tentacle is running as. http://docs.octopusdeploy.com/display/OD/Run+Tentacle+under+a+specific+user+for+use+in+PowerShell

Hope that helps!
Vanessa

Hi Vanessa,

Thanks very much for the information, running the script via the console gave me the same result so I switched the service to run as a user with admin permissions on the box.

The script now runs as expected which is excellent! thanks again,

Doug

Hi Doug,

Great to hear!

Vanessa