Azure Webapp Keyvault 引用,具有用户分配的暂存槽标识

Azure Webapp Keyvault reference with user-assigned identity for staging slot

Azure Web 应用程序具有配置设置(环境变量)的密钥保管库引用。 我按照 this 文档来设置连接。 keyvault 引用已在 Web 应用程序的 production/main 槽中正确解析。他们没有解决暂存槽。 我已授予同一托管标识对登台 Web 应用程序的访问权限。使用上述 link 中提供的代码片段不允许将其分配给特定的插槽。只是 webapp 资源。 :

userAssignedIdentityResourceId=$(az identity show -g MyResourceGroupName -n MyUserAssignedIdentityName --query id -o tsv) appResourceId=$(az webapp show -g MyResourceGroupName -n MyAppName --query id -o tsv) az rest --method PATCH --uri "${appResourceId}?api-version=2021-01-01" --body "{'properties':{'keyVaultReferenceIdentity':'${userAssignedIdentityResourceId}'}}"

关于生产槽和暂存槽之间的区别有什么解决方案吗?

根据这个thread:

Each slot gets its own identity, and this stays with that slot during a swap. This means you always have a production security context, a test security context, etc.

因此您需要为暂存槽创建身份并授予它对密钥保管库的权限。