如何帮助 Azure 网络安全组规则识别 Azure DevOps 的服务标签

问题描述 投票:0回答:2

我正在尝试设置入站网络安全组规则,以允许从 Azure DevOps Pipelines 到 Azure 公共 Azure vnet 的受控访问,该公共 Azure vnet 与包含运行 Sonarqube 的 Azure 容器实例的私有 Azure vnet 接口。我根据 Azure 文档制作了这个here

来自 Azure DevOps 的入站流量的 NSG 规则利用服务标签,特别是“AzureDevOps”服务标签。我的 ARM 模板当前包含这两个 NSG 规则:

{
             "name": "inbound-devops-rule",
             "properties": {
             "description": "Inbound Azure DevOps",
             "protocol": "*",
             "sourcePortRange": "*",
             "destinationPortRange": "*",
             "sourceAddressPrefix": "AzureDevOps",
             "destinationAddressPrefix": "*",
             "access": "Allow",
             "priority": 100,
             "direction": "Inbound"
                 }
             },
             {
             "name": "InboundRequiredGatewayPorts",
             "properties": {
             "description": "Inbound AZ admin",
             "protocol": "TCP",
             "sourcePortRange": "*",
             "destinationPortRange": "65200-65535",
             "sourceAddressPrefix": "GatewayManager",
             "destinationAddressPrefix": "*",
             "access": "Allow",
             "priority": 115,
             "direction": "Inbound"
                 }
             },

目前,这不允许流量通过 NSG 规则并进入 vnet。在测试中,我能够解决此问题的唯一方法是创建一个完全开放的规则,允许来自 NSG 中所有来源的所有流量……从安全角度来看,这显然不是一个理想的场景。到目前为止,我已经梳理了文档并尝试了数十种不同的配置,除了开放/不受保护的 NSG 配置之外,没有其他配置允许 Azure DevOps 流量。

我当前在尝试从 Azure DevOps 管道连接到容器化 Azure Sonarqube 资源时遇到的简单错误是:

2022-12-02T19:46:46.7098999Z ##[section]Starting: SonarQubePrepare
 2022-12-02T19:46:46.7231846Z ==============================================================================
 2022-12-02T19:46:46.7232191Z Task         : Prepare Analysis Configuration
 2022-12-02T19:46:46.7232466Z Description  : Prepare SonarQube analysis configuration
 2022-12-02T19:46:46.7232684Z Version      : 5.8.0
 2022-12-02T19:46:46.7232868Z Author       : sonarsource
 2022-12-02T19:46:46.7233232Z Help         : Version: 5.8.0. [More Information](http://redirect.sonarsource.com/doc/install-configure-scanner-tfs-ts.html)
 2022-12-02T19:46:46.7233633Z ==============================================================================
 2022-12-02T19:47:08.4683602Z ##[error][SQ] API GET '/api/server/version' failed, error was: {"errno":"ETIMEDOUT","code":"ETIMEDOUT","syscall":"connect","address":"<REDACTED>","port":80}
 2022-12-02T19:47:08.4811763Z ##[section]Finishing: SonarQubePrepare

根据上面的规则示例,是否正确配置为允许使用服务标签的来自 Azure DevOps 的流量?是否可以提供任何其他指导来设置 NSG 规则以允许流量从我的 Azure DevOps 管道传输到 Azure 容器化资源?

azure azure-devops azure-nsg
2个回答
2
投票

Azure DevOps Microsoft 托管代理使用服务标签 AzureCloud.region 而不是 Azure DevOps,地址如下:doc

首先在 DevOps UI 中检查您的 DevOps 组织区域。

然后检查此Azure Geography

中的区域

请注意:要获取代理可能的 IP 范围的完整列表,您必须使用您所在地理位置中包含的所有区域的 IP 范围。

供您参考:如果您的 DevOps 组织位于英国,您必须将 AzureCloud.uksouth 和 AzureCloud.ukwest 的服务标记添加到 NSG 入站安全规则中,以确保 MS 托管的代理能够访问 Azure 资源。


0
投票

这是允许区域的简单方法,无需为每周更新列表中的每个 IP 创建规则:

"sourceAddressPrefix": "AzureCloud.eastus"

我想知道如果坏人可以在同一区域部署针对其他系统的代理,会发生什么。我认为这条规则不会阻止他们。

© www.soinside.com 2019 - 2024. All rights reserved.