&引用;“读卡器和数据访问”;角色无法通过powershell访问?
我试图在Azure中将“读卡器和数据访问”角色分配给我的服务主体,但它抛出了一个错误 我没有看到此角色在上列出,但在azure门户上可见&引用;“读卡器和数据访问”;角色无法通过powershell访问?,powershell,azure,azure-powershell,azure-automation,Powershell,Azure,Azure Powershell,Azure Automation,我试图在Azure中将“读卡器和数据访问”角色分配给我的服务主体,但它抛出了一个错误 我没有看到此角色在上列出,但在azure门户上可见 New-AzureRmRoleAssignment -RoleDefinitionName 'Reader and Data Access' ` -ServicePrincipalName $app.ApplicationId` 新AzureRmRoleAssignment:过滤器“roleName eq”读卡器和数据 不支持访问“
New-AzureRmRoleAssignment
-RoleDefinitionName 'Reader and Data Access' `
-ServicePrincipalName $app.ApplicationId`
新AzureRmRoleAssignment:过滤器“roleName eq”读卡器和数据
不支持访问“”。支持的筛选器为roleName eq或
“{value}”或类型eq“内置角色|自定义角色”
但是,我可以从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
我没有Azure,但是当您尝试
Get-AzureRmRoleAssignment
@Matt是的,我可以使用Get-AzureRmRoleDefinition
在powershell中看到此角色,并且我还可以看到已使用Get-AzureRmRoleAssignment
列出了正在分配的角色。这是您能够创建的角色吗预定的?我问这个问题是因为我想知道名称中是否有尾随空格或隐藏字符(不允许这样做)。这不是预定义的角色。我从未创建过任何自定义角色。它将向ServicePrincipal或Application授予权限吗?它们都受支持。