"Reader and Data Access" 角色无法通过 powershell 获得?
"Reader and Data Access" role is not available through powershell?
我正在尝试将 "Reader and Data Access" 角色分配给我在 Azure 中的服务主体,但它抛出错误
我没有在 MSDN 上看到此角色,但在 Azure 门户上可见
New-AzureRmRoleAssignment
-RoleDefinitionName 'Reader and Data Access' `
-ServicePrincipalName $app.ApplicationId`
New-AzureRmRoleAssignment : The filter 'roleName eq 'Reader and Data
Access'' is not supported. Supported filters are either roleName eq
'{value}' or type eq 'BuiltInRole|CustomRole'
但是我可以从 Azure UI 控制台看到并分配这个角色。
我在我的实验室测试,我得到了和你一样的错误日志。我使用 -RoleDefinitionId
而不是 -RoleDefinitionName
来解决这个问题。以下脚本适合我。
$value=Get-AzureRmRoleDefinition
$a=$value |where {$_.Name -eq "Reader and Data Access"}
New-AzureRmRoleAssignment -ObjectId $app.ObjectId -Scope /subscriptions/$subscriptionID -RoleDefinitionId $a.Id
我正在尝试将 "Reader and Data Access" 角色分配给我在 Azure 中的服务主体,但它抛出错误
我没有在 MSDN 上看到此角色,但在 Azure 门户上可见
New-AzureRmRoleAssignment
-RoleDefinitionName 'Reader and Data Access' `
-ServicePrincipalName $app.ApplicationId`
New-AzureRmRoleAssignment : The filter 'roleName eq 'Reader and Data Access'' is not supported. Supported filters are either roleName eq '{value}' or type eq 'BuiltInRole|CustomRole'
但是我可以从 Azure UI 控制台看到并分配这个角色。
我在我的实验室测试,我得到了和你一样的错误日志。我使用 -RoleDefinitionId
而不是 -RoleDefinitionName
来解决这个问题。以下脚本适合我。
$value=Get-AzureRmRoleDefinition
$a=$value |where {$_.Name -eq "Reader and Data Access"}
New-AzureRmRoleAssignment -ObjectId $app.ObjectId -Scope /subscriptions/$subscriptionID -RoleDefinitionId $a.Id