Invoke-Expression "& 'WebDeployFolderPath\msdeploy.exe' --% -verb:sync -source:dbDacFx=`'SourceDACPAC`' -dest:dbDacFx=`'DestinationDBConnection`',commandTimeout=100" -Verbose -ErrorAction "Stop"
Example
.\DeployDacpacMSDeploy.ps1 -WebDeployFolder "C:\Program Files (x86)\IIS\Microsoft Web Deploy V3" -SourceDACPAC "C:\temp\MyDb.dacpac" -DestinationDBConnection "Server=tcp:qa-db.database.windows.net,1433;Database=mydb;User ID=dbadmin@qa-db;Password=pwd;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30" -CommandTimeout 100
A poweshell script can be developed, to use in a Release Management tool.
![image image](https://lh3.googleusercontent.com/-jc4vKNtGJUo/Vv0N59S9FzI/AAAAAAAAG_Y/nzfNB2znZyQ/image_thumb%25255B4%25255D.png?imgmax=800)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
param( [Parameter(mandatory=$true)] [string]$WebDeployFolder, [Parameter(mandatory=$true)] [string]$SourceDACPAC, [Parameter(mandatory=$true)] [string]$DestinationDBConnection, [Parameter(mandatory=$true)] [string]$CommandTimeout ) $ErrorActionPreference = "Stop" Invoke-Expression "& '$WebDeployFolder\msdeploy.exe' --% -verb:sync -source:dbDacFx=`'$SourceDACPAC`' -dest:dbDacFx=`'$DestinationDBConnection`',commandTimeout=$CommandTimeout" -Verbose -ErrorAction "Stop" | Out-Host if ($lastexitcode -ne 0) { throw "Dacpac deploy failed." } |
![01 01](https://lh3.googleusercontent.com/-yl7sdttEi_g/VvIgUKtZ3fI/AAAAAAAAG9c/gdfr_QMRvf0/01_thumb%25255B4%25255D.png?imgmax=800)
Using the tool, create an action component.
![02 02](https://lh3.googleusercontent.com/-bCPwNj32c8M/VvIgWiDGnfI/AAAAAAAAG9k/C-6a1QXOx78/02_thumb%25255B2%25255D.png?imgmax=800)
This component can be used in a release template.
![03 03](https://lh3.googleusercontent.com/-8GBs2V7V4WE/VvIgZPYcneI/AAAAAAAAG9s/-ErUjcFRW6A/03_thumb%25255B3%25255D.png?imgmax=800)
Database updates can be pushed to Azure SQL or any other target SQL server.
![04 04](https://lh3.googleusercontent.com/-aqRHWOEI2cs/VvIgbc0t62I/AAAAAAAAG90/qbLucmsGzpY/04_thumb%25255B6%25255D.png?imgmax=800)
1 comment:
Resolving ERROR_EXECUTING_METHOD with the tool is explained here .
Post a Comment