0

我想使用管道和私有 IP 下载 Azure Key Vault,因为由于 NSG 限制性规则,机器只能通过私有 IP 进行通信。我的 azure 管道在部署组上运行,该部署组也与密钥保管库位于同一资源组中。默认 Keyvault 任务使用公共 IP。有没有办法在管道中做到这一点?

4

1 回答 1

1

有没有办法在管道中做到这一点?

根据您的描述,您的 azure keyvault 似乎位于虚拟网络后面。

您可以尝试将专用 IP 添加到 Azure 密钥库防火墙白名单。

然后,您可以使用 Azure Key Vault Task 来下载 Key Vault。

最后,您可以删除 Ip 规则。

这是我的示例:

steps:
- task: AzurePowerShell@5
  displayName: 'Azure PowerShell script: InlineScript'
  inputs:
    azureSubscription: kevin0225
    ScriptType: InlineScript
    Inline: |
     $IP= Invoke-RestMethod http://ipinfo.io/json | Select -exp ip
     
     $IP
     
     Add-AzKeyVaultNetworkRule -VaultName "keyvaultname" -IpAddressRange "$IP"
    preferredAzurePowerShellVersion: 3.1.0

- task: AzureKeyVault@1
  displayName: 'Azure Key Vault: kevin0225'
  inputs:
    azureSubscription: kevin0225
    KeyVaultName: kevin0225

- task: AzurePowerShell@5
  displayName: 'Azure PowerShell script: InlineScript'
  inputs:
    azureSubscription: kevin0225
    ScriptType: InlineScript
    Inline: |
     $IP= Invoke-RestMethod http://ipinfo.io/json | Select -exp ip
     
     $IP
     
     Remove-AzKeyVaultNetworkRule -VaultName "keyvaultname" -IpAddressRange "$IP"
    preferredAzurePowerShellVersion: 3.1.0

这是有关将 IP 添加到 azure keyvault 防火墙的方法的文档。

于 2021-02-25T08:14:38.197 回答