Azure DevOps/管道IP随机更改,因此由于防火墙规则,我无法使用Azure SQL数据库 [英] Azure DevOps/Pipeline IP is changing randomly so I can not use Azure SQL Database because of firewall rules

本文介绍了Azure DevOps/管道IP随机更改,因此由于防火墙规则,我无法使用Azure SQL数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Azure DevOps/管道IP随机变化,因此由于防火墙规则,我无法使用Azure SQL数据库.

Azure DevOps/Pipeline IP is changing randomly so I can not use Azure SQL Database because of firewall rules.

在这种情况下,解决方案是什么?

What is the solution in this case?

推荐答案

在连接数据库之前,您可以基于代理的当前IP创建防火墙规则,如下所示:

You can create a firewall rule based on the current ip of the agent before connecting with the database like so:

  - 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

您可以通过类似的方式在管道末端将其删除.

In a similar way you can remove it at the end of the pipeline.

这篇关于Azure DevOps/管道IP随机更改,因此由于防火墙规则,我无法使用Azure SQL数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆