我们已通过服务连接(服务主体身份验证)在 Azure DevOps 和 Azure Key Vault 之间建立连接。但是,为了使其正常工作,我们需要将 Azure Key Vault
-> Networking
标记为“允许从以下位置访问:所有网络
”。鉴于我们在此处存储 secret ,我们希望使用选项专用终结点和选定网络
,而不是将允许受信任的 Microsoft 服务绕过此防火墙?
设置为 是
.
像这样:
但是,这会导致 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.
如果我们为 Azure Key Vault 设置“允许来自:所有网络
”的访问,它会按前面所述工作,但我们希望尽可能避免这种情况。
在管道中设置 Azure Key Vault 任务
或设置变量组,然后切换回专用端点和选定网络
会导致部署时出现类似错误。
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."
不幸的是,客户端地址每次都是新的,但 oid
和 iss
值是相同的。根据文档,只能将 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/