我正在尝试获取当前的角色分配状态。
例如:我为我的网络应用分配了贡献者角色
New-AzureRmRoleAssignment -ObjectId 43fddad0-xxxx-xxxx-xxxx-665033f5fbf0 -RoleDefinitionName "Storage Blob Data Contributor" -Scope "/subscriptions/4364666b-xxxx-xxxx-xxxx-47158904c439/resourceGroups/devt002RG/providers/Microsoft.Storage/storageAccounts/devt002"
当我再次在 VSTS 中运行上述命令时,它会给出错误消息
2019-04-02T10:22:58.2614183Z ##[error]The role assignment already exists.
我只想获取我的网络应用程序的角色(存储 Blob 数据贡献者)分配的当前状态,如果它已经存在,我将跳过该分配。
我尝试过:
Get-AzureRmRoleAssignment -Scope "/subscriptions/4364666b-xxxx-xxxx-xxxx-47158904c439/resourceGroups/devt002RG/providers/Microsoft.Storage/storageAccounts/devt002"
Get-AzureRmRoleAssignment -Id 43fddad0-xxxx-xxxx-xxxx-665033f5fbf0
最佳答案
好吧,您使用的是正确的命令,您只需要围绕它构建一些逻辑即可确定分配是否已存在。
如果您事先知道 GUID:
Get-AzRoleAssignment -ObjectId "GUID"
这是最简单的检查方法
关于azure - 如何知道 azure 角色分配已经存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55509780/