Azure DevOps -> 管道 -> 库 -> 访问 Azure Key Vault -> Key Vault 不允许从所有网络访问

标签 azure azure-devops azure-keyvault

我们已通过服务连接(服务主体身份验证)在 Azure DevOps 和 Azure Key Vault 之间建立连接。但是,为了使其正常工作,我们需要将 Azure Key Vault -> Networking 标记为“允许从以下位置访问:所有网络”。鉴于我们在此处存储 secret ,我们希望使用选项专用终结点和选定网络,而不是将允许受信任的 Microsoft 服务绕过此防火墙? 设置为 .

像这样:

enter image description here

但是,这会导致 Azure DevOps -> Pipelines -> Library 出现错误:

The specified Azure service connection needs to have "Get, List" secret management permissions on the selected key vault. Click "Authorize" to enable Azure Pipelines to set these permissions or manage secret permissions in the Azure portal.

enter image description here

如果我们为 Azure Key Vault 设置“允许来自:所有网络”的访问,它会按前面所述工作,但我们希望尽可能避免这种情况。

enter image description here

在管道中设置 Azure Key Vault 任务

enter image description here

或设置变量组,然后切换回专用端点和选定网络会导致部署时出现类似错误。

enter image description here

MyKey: "Client address is not authorized and caller is not a trusted service.\r\nClient address: 111.222.333.44\r\nCaller: appid=;oid=00000000-0000-0000-0000-000000000000;iss=https://sts.windows.net//\r\nVault: My-Vault;location=northeurope. The specified Azure service connection needs to have Get, List secret management permissions on the selected key vault. To set these permissions, download the ProvisionKeyVaultPermissions.ps1 script from build/release logs and execute it, or set them from the Azure portal."

enter image description here

不幸的是,客户端地址每次都是新的,但 oidiss 值是相同的。根据文档,只能将 IPv4 地址或 CIDR 添加到防火墙。有没有办法将 Azure 代理标记为受信任的 Microsoft 服务,或者这是一个不好的做法?不过,它似乎确实比所有网络安全得多。

最佳答案

这仍然是一个悬而未决的问题 - Issue

可能有些解决方案如 URL 中提到的

  • 在管道中添加一个任务并将代理的 IP 列入白名单,然后在获得 keyvault 中的值后删除白名单。

  • 白名单 Azure DevOps IP 列表可能每周一次,但这似乎不可靠

  • @Grand建议的实际上也是解决方案之一。

关于Azure DevOps -> 管道 -> 库 -> 访问 Azure Key Vault -> Key Vault 不允许从所有网络访问,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61411653/

相关文章:

azure-devops - Azure 多级管道 : conditionally skip one stage but not the next

tfsbuild - 源代码管理中缺少 TfvcTemplate.12.xaml

Azure Artifacts 无法与 powershell 存储库一起使用

azure - 通过 ARM 模板使用参数(数组类型)为多个对象 ID 设置 key 保管库访问策略

azure - 如何在不更改 secret 标识符的情况下更新 Key Vault secret 值?

c# - 通过 C# 访问 Azure 中的 keyvault 时引发异常

azure - 哪个 C# 字段将 Azure 表存储列创建为 "binary"类型

azure - Umbraco.config 存储在 Azure 云服务中的哪里?

c# - 在已发布的应用程序中上传到 Blob 存储时出现 IOException

c# - 当我在 Visual Studio 中发布 Azure 函数时包含文件