azure - 如何从“访问控制”选项卡获取存储帐户容器的角色分配

标签 azure powershell azure-active-directory azure-cli rbac

我正在尝试使用 powershell 从存储帐户容器的访问控制选项卡获取所有对象。

enter image description here

使用命令:

Get-AzRoleAssignment -ResourceGroupName 'devtest' -ResourceName 'sa-name' -ResourceType 'Microsoft.Storage/storageAccounts'

我从以下位置获取所有对象:

  • 存储帐户
  • 容器

enter image description here

如您所见,使用此命令我可以在同一调用中获取存储帐户容器的范围。

我尝试使用如下命令:

Get-AzRoleAssignment -ResourceGroupName 'devtest' -ResourceName 'SA-name' -ResourceType 'Microsoft.Storage/storageAccounts' | Where-Object -Property Scope -Like '*containers/container-name'

但我对结果不满意,因为我没有获得此容器的所有者,因为它是从不同的资源继承的

我的问题是,如何使用 powershell、CLI 或 REST API 以及所有对象从特定容器的 IAM Blade 获取角色分配对象?

最佳答案

您可以通过列出存储帐户的所有角色分配并排除除您想要查看的容器之外的所有容器来列出特定容器上的 RBAC:

Get-AzRoleAssignment -ResourceGroupName "<your-resource-group-name>" -ResourceType "Microsoft.Storage/storageAccounts" -ResourceName "<your-storage-account-name>" | Where-Object { $_.Scope -like '*/containers/<your-container-name>' -or -not ($_.Scope -like '*/storageAccounts*/default/containers/*') }

关于azure - 如何从“访问控制”选项卡获取存储帐户容器的角色分配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71305643/

相关文章:

azure - SharePoint 在线 OAuth2 token invalid_scope

oauth - 如何允许任何域登录我的 Azure Active Directory 应用程序

azure - PowerShell 列出所有 Azure VM 数据磁盘大小困惑

Azure 数据浏览器摄取批处理策略未按预期工作

sql - 为什么没有选项使用 ssms 将数据导入到 Azure 数据库?

c# - Azure sb lite 连接字符串和事件中心兼容名称

amazon-web-services - 使用 Elastic Beanstalk 在实例启动时运行 Windows Powershell 脚本

powershell - 错误: "Select-AzureSubscription Must specify a non-null subscription name"

powershell - 是否可以从 powershell 脚本对 vbscript msgbox 使用react?

azure - 如何创建允许注册应用程序和服务主体的 Azure 自定义角色