Search code examples
azureazure-pipelinesazure-sql-databasecicdazure-pipelines-yaml

SqlAzureDacpacDeployment@1 - Error in devops pipeline Could not deploy package


I am trying to deploy dacpac to an existing sql db, and getting the following error:

##[error]*** Could not deploy package. ##[error]Unable to connect to target server 'AAA.database.windows.net'. Please verify the connection information such as the server name, login credentials, and firewall rules for the target server. Cannot open server ##[error] 'MyMSSQlServer' requested by the login. Client is not allowed to access the server.

##[error]The Azure SQL DACPAC task failed. SqlPackage.exe exited with code 1.Check out how to troubleshoot failures at https://aka.ms/sqlazuredeployreadme#troubleshooting-

Here are my steps in release pipeline:

- download: current
  artifact: databases

- task: SqlAzureDacpacDeployment@1
  displayName: Execute Azure SQL Dacpac
  inputs:
    azureSubscription: 'MySuvscription'
    ServerName: 'MyMSSQlServer.database.windows.net'
    DatabaseName: 'AAA'
    SqlUserName: 'mysqlserveradmin'
    SqlPassword: 'mysqlserverpassword'
    DacpacFile: '$(Pipeline.Workspace)\databases\foldera\folderb\folderc\folderd\MyApp.Database.dacpac'
    IpDetectionMethod: AutoDetect

I assumed IpDetectionMethod should handle the access permission. Can anyone suggest how to fix this now?


Solution

  • - download: current
      artifact: databases
    
    - task: SqlAzureDacpacDeployment@1
      displayName: Execute Azure SQL Dacpac
      inputs:
        azureSubscription: 'MySubscription'
        ServerName: 'MyMSSQlServer.database.windows.net'
        DatabaseName: 'AAA'
        SqlUserName: 'mysqlserveradmin'
        SqlPassword: 'mysqlserverpassword'
        deployType: 'DacpacTask'
        DeploymentAction: 'Publish'
        DacpacFile: '$(Pipeline.Workspace)\databases\foldera\folderb\folderc\folderd\MyApp.Database.dacpac'
        AdditionalArguments: //If you have any parameters, sql cmd variables please add here
        IpDetectionMethod: 'IPAddressRange'
        StartIpAddress: '0.0.0.0'
        EndIpAddress: '0.0.0.0'
        DeleteFirewallRule: true