I'm deploying a dacpac file onto a SQLAzure database using the following Powershell script
[Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.Smo")
[Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.Management.Sdk.Sfc")
[Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.Management.Dac")
[Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.ConnectionInfo")
$serverConnection = New-Object Microsoft.SqlServer.Management.Common.ServerConnection("dbinstance.db.net", "uid", "pwd")
$sqlStoreConnection = New-Object Microsoft.SqlServer.Management.Sdk.Sfc.SqlStoreConnection($serverConnection.SqlConnectionObject)
$sqlStoreConnection.Connect()
$newDacStore = New-Object Microsoft.SqlServer.Management.Dac.DacStore($sqlStoreConnection)
$dacpacPath = "C:\Database\Database.dacpac"
$fileStream = [System.IO.File]::Open($dacpacPath, [System.IO.FileMode]::OpenOrCreate)
$dacType = [Microsoft.SqlServer.Management.Dac.DacType]::Load($fileStream)
$newDacStore.add_DacActionStarted({Write-Host `n`nStarting at $(get-date) :: $_.Description})
$newDacStore.add_DacActionFinished({Write-Host Completed at $(get-date) :: $_.Description})
$dacName = "TestDB"
$evaluateTSPolicy = $true
$deployProperties = New-Object Microsoft.SqlServer.Management.Dac.DatabaseDeploymentProperties($serverconnection,$dacName)
$newDacStore.Install($dacType, $deployProperties, $evaluateTSPolicy)
$fileStream.Close()
It runs fine until the Install when it throws the following:
Starting at 24/08/2011 16:50:37 :: Preparing DAC metadata in the SQL Server instance 'dbinstance'
Completed at 24/08/2011 16:50:37 :: Preparing DAC metadata in the SQL Server instance 'dbinstance'
Starting at 24/08/2011 16:50:38 :: Preparing deployment script
Completed at 24/08/2011 16:50:39 :: Preparing deployment script
Starting at 24/08/2011 16:50:39 :: Creating database 'TestDB'
Completed at 24/08/2011 16:50:41 :: Creating database 'TestDB'
Starting at 24/08/2011 16:50:46 :: Creating schema objects in database 'TestDB'
Completed at 24/08/2011 16:52:41 :: Creating schema objects in database 'TestDB'
Starting at 24/08/2011 17:02:05 :: Registering the DAC in DAC metadata.
Completed at 24/08/2011 17:02:09 :: Registering the DAC in DAC metadata.
Starting at 24/08/2011 17:02:09 :: Creating database 'TestDB'
Completed at 24/08/2011 17:02:09 :: Creating database 'TestDB'
Exception calling "Install" with "3" argument(s): "Unable to install DacInstance. Please verify the
components of the application."
At C:\Database\DeployDatabase.ps1:53 char:21
+ $newDacStore.Install <<<< ($dacType, $deployProperties, $evaluateTSPolicy)
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodException
Looking at SSMS, I can see that the database has been registered (Management > Data-tier Applications), but no database is created.
I'm at a loss as to what is happening and the error message is a bit vague.
Anyone with any ideas?
Sunil