Showing posts with label webdeploy. Show all posts
Showing posts with label webdeploy. Show all posts

Thursday, 31 March 2016

MSDeploy dacpac Deployment ERROR_EXECUTING_METHOD

When using the RM tool to deploy dacpacs as explained in “Deploy dacpac with MSDeploy in VS Release Management”, below error might occur.
image
Info: Adding MSDeploy.dbDacFx (MSDeploy.dbDacFx).
Info: Adding database (server=tcp:mydb.database.windows.net,1433;database=DeployTest;user id=
e;trustservercertificate=False;connection timeout=30)
Info: Initializing deployment: Pending.
Info: Analyzing deployment plan: Pending.
Info: Updating database: Pending.
Info: Creating deployment plan: Pending.
Info: Verifying deployment plan: Pending.
Info: Deploying package to database: Pending.
Info: Creating deployment plan: Running.
Info: Initializing deployment: Running.
Info: Initializing deployment (Start)
Info: Initializing deployment: Faulted.
Info: Initializing deployment (Failed)
Info: Creating deployment plan: Faulted.
Info: Verifying deployment plan: Faulted.
Info: Deploying package to database: Faulted.
Error Code: ERROR_EXECUTING_METHOD
More Information: Could not deploy package.
Unable to connect to target server.
  Learn more at: http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_EXECUTING_METHOD.
Error: Could not deploy package.
Error: Unable to connect to target server.
This is without much information and a generic error, might require tearing your hair out a lot, trying to resolve.
How to resolve
This could be easily a firewall blocking access to your SQL server, or firewall not allowed IP for your Azure database server. Fix could be easy as adding the required firewall exceptions.image

Tuesday, 22 March 2016

Deploy dacpac with MSDeploy in VS Release Management

To deploy a dacpac against a target database, MSDeploy can be used. In powershell, following command allows to deploy a dacpac.
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
 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."
    }
Using this poweshell script a tool in RM can be created as shown below.01
Using the tool, create an action component.02
This component can be used in a release template.03
Database updates can be pushed to Azure SQL or any other target SQL server.04

Popular Posts