如何启用 "system assigned" 身份并更新密钥保管库以添加新的访问策略 azure cli

How to enable "system assigned" identity and update the key vault to add new access policy azure cli

如何启用“系统分配”标识并更新密钥保管库以使用 azure cli 添加新的访问策略...

尝试了以下命令,但它抱怨说由于某种原因找不到 RG 或者我遗漏了一些东西。
az webapp identity assign --name --resource-group

Tried below command but it complaints that it cannot find RG for some reason or i'm missing something.

您使用的命令是正确的,请确保您输入的资源组名称正确,并确保您运行通过az account show正确订阅下的命令,如果不正确,请使用az account set 来设置它。

az account set --subscription '<subscription-id>'
az webapp identity assign --name '<webapp-name>' --resource-group '<group-name>'

然后,如果您想将系统分配的身份添加到密钥库的访问策略中,请使用 az keyvault set-policy。 (等待几分钟后az webapp identity assign,需要在Azure AD中创建与身份相关的服务主体)

样本(<object-id>az webapp identity assign返回的principalId):

az keyvault set-policy --name '<keyvault-name>' --resource-group '<group-name>' --object-id '<object-id>' --secret-permissions get list delete