如何使用Azure CLI在Azure SQL中添加用户分配的身份?

huangapple go评论64阅读模式
英文:

How to add user assigned identity in azure sql using azure cli?

问题

使用Azure CLI执行以下功能。关闭系统分配的服务主体,添加用户托管标识,并将其设置为主要标识。非常感谢帮助。

参考链接:https://learn.microsoft.com/en-us/azure/azure-sql/database/authentication-azure-ad-user-assigned-managed-identity?view=azuresql#set-a-managed-identity-in-the-azure-portal

英文:

I want to do the following function using Azure CLI. turn the system assigned service principal off, Add a user managed identity and make it the primary identity using Azure CLI. Would much appreciate the help.

Reference: https://learn.microsoft.com/en-us/azure/azure-sql/database/authentication-azure-ad-user-assigned-managed-identity?view=azuresql#set-a-managed-identity-in-the-azure-portal

答案1

得分: 0

az sql mi update -g Analytics-Resources -n sqlmanagedinstanceshared -i --user-assigned-identity-id /subscriptions/xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/Analytics-Resources/providers/Microsoft.ManagedIdentity/userAssignedIdentities/dbm --identity-type UserAssigned --pid /subscriptions/xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/Analytics-Resources/providers/Microsoft.ManagedIdentity/userAssignedIdentities/dbm

我尝试使用以下代码在我的环境中复制这个问题:

我遇到了相同的错误:

这个错误是因为在 -i 后面多了一个额外的反斜杠,我去掉它后尝试执行了这段代码:

错误已经解决,成功执行了。

英文:

I tried to replicate the issue in my environment with below code:

 az sql mi update -g Analytics-Resources -n sqlmanagedinstanceshared -i \ --user-assigned-identity-id /subscriptions/xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/Analytics-Resources/providers/Microsoft.ManagedIdentity/userAssignedIdentities/dbm \ --identity-type UserAssigned --pid /subscriptions/xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/Analytics-Resources/providers/Microsoft.ManagedIdentity/userAssignedIdentities/dbm

I got the same error:

如何使用Azure CLI在Azure SQL中添加用户分配的身份?

This error I got because of extra back slash at -i I removed that tried to exucute the code:

az sql mi update -g Analytics-Resources -n sqlmanagedinstanceshared -i  --user-assigned-identity-id /subscriptions/xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/Analytics-Resources/providers/Microsoft.ManagedIdentity/userAssignedIdentities/dbm \ --identity-type UserAssigned --pid /subscriptions/xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/Analytics-Resources/providers/Microsoft.ManagedIdentity/userAssignedIdentities/dbm

The error was resolved, and it executed successfully.

如何使用Azure CLI在Azure SQL中添加用户分配的身份?

huangapple
  • 本文由 发表于 2023年3月8日 19:00:12
  • 转载请务必保留本文链接:https://go.coder-hub.com/75672154.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定