【发布时间】:2020-10-09 15:12:57
【问题描述】:
Azure DevOps/Pipeline IP 随机更改,因此由于防火墙规则,我无法使用 Azure SQL 数据库。
这种情况有什么解决办法?
【问题讨论】:
标签: azure azure-devops azure-sql-database azure-pipelines azure-pipelines-release-pipeline
Azure DevOps/Pipeline IP 随机更改,因此由于防火墙规则,我无法使用 Azure SQL 数据库。
这种情况有什么解决办法?
【问题讨论】:
标签: azure azure-devops azure-sql-database azure-pipelines azure-pipelines-release-pipeline
您可以在连接数据库之前根据代理的当前 ip 创建防火墙规则,如下所示:
- task: AzureCLI@2
inputs:
azureSubscription: [name of service connection]
scriptType: pscore
scriptLocation: inlineScript
inlineScript: |
# Set firewall on server open for the agent
$agentIp = (New-Object net.webclient).downloadstring("http://checkip.dyndns.com") -replace "[^\d\.]"
az sql server firewall-rule create -g $(rg) -s $(server) -n test --start-ip-address $agentIp --end-ip-address $agentIp
以类似的方式,您可以在管道末端将其移除。
【讨论】:
IpDetectionMethod(Specify Firewall Rules Using) 字段设置为 AutoDetect,这会自动将代理 ip 添加到防火墙规则中。
我在 Azure SQL 数据库防火墙中添加了 Azure IP 范围,然后它就可以工作了。 例如:
Start IP 13.107.6.0 and End IP 13.107.6.255
和
Start IP 13.107.43.0 and End IP 13.107.43.255
我不确定这是一个永久的解决方案。
【讨论】: