Unable to deploy Azure SQL that is on private link using Azure DevOps Release pipeline - Stack Overflow

admin2025-04-18  0

I'm unable to deploy to an Azure SQL database using Azure DevOps Release pipeline using the task : Azure SQL Database deployment. The error that I get is

A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: TCP Provider, error: 0 - No such host is known.)

My tasks are below:

steps:
- task: AzurePowerShell@5
  displayName: 'Azure PowerShell : Get Agent Public IP'
  inputs:
    azureSubscription: 'zzzzzz'
    ScriptType: InlineScript
    Inline: |
     $ip = (Invoke-WebRequest -uri ";).Content
     Write-Host $ip
     Write-Host "##vso[task.setvariable variable=AgentIP;]$ip"
    azurePowerShellVersion: LatestVersion

variables:
  ServerName: 'xxxx.database.windows'
  DatabaseName: 'yyyy'
  UserName: '[email protected]'
  AgentIP: ''

steps:
- task: SqlAzureDacpacDeployment@1
  displayName: 'Azure SQL DacpacTask'
  inputs:
    azureSubscription: 'zzzzz'
    AuthenticationType: aadAuthenticationPassword
    ServerName: '$(ServerName)'
    DatabaseName: '$(DatabaseName)'
    aadSqlUsername: '$(UserName)'
    aadSqlPassword: '$(Password)'
    DacpacFile: '$(System.DefaultWorkingDirectory)/xxxx/drop_db/DB.dacpac'
    AdditionalArguments: '/p:IgnoreAnsiNulls=True /p:IgnoreComments=False /p:BlockOnPossibleDataLoss=True /p:GenerateSmartDefaults=True /p:DropObjectsNotInSource=False /p:UnmodifiableObjectWarnings=False /p:ExcludeObjectTypes=Users;Logins;RoleMembership;Permissions'
    IpDetectionMethod: IPAddressRange
    StartIpAddress: '$(AgentIP)'
    EndIpAddress: '$(AgentIP)'

I'm using an Agent Pool that is a Virtual Machine Scale Set. The Azure SQL Server is having a Private endpoint. During the deployment, I'm adding the Public IP of the Agent machine to the Firewall rules of the Azure SQL using the inbuilt option of the DACPAC task but that doesn't seem to make any difference. The "Allow Azure services and resources to access this server" exception checkbox is enabled.

Any help is appreciated.

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1744970880a277479.html

最新回复(0)