azure 通过PowerShell脚本将应用程序的角色添加到资源组

syqv5f0l  于 2023-05-23  发布在  Shell
关注(0)|答案(1)|浏览(189)

我有一个资源组“test-rg”。如何通过PowerShell脚本将自定义角色“自定义角色”添加到此资源组的应用程序“test-application”?

xtupzzrd

xtupzzrd1#

我相信由
“如何通过PowerShell脚本将自定义角色'自定义角色'添加到此资源组的应用程序'test-application'?”
你的意思是
“How can I create a role assignment of the role 'Custom Role' for the application 'test-application' for a Resource Group by PowerShell?”
如果是这种情况,您只需要创建一个角色分配。
https://learn.microsoft.com/en-us/azure/role-based-access-control/role-assignments-powershell
使用Azure PowerShell分配Azure角色- Azure RBAC| Microsoft Learn
要在PowerShell中执行此操作,您需要运行以下命令:

  1. New-AzRoleAssignment -ObjectId <objectId> `
  2. -RoleDefinitionName <roleName> `
  3. -Scope /subscriptions/<subscriptionId>/resourcegroups/<resourceGroupName>

其中:

  • <objectId>是服务主体/企业应用程序的对象ID,
  • <roleName>是内置或自定义角色(例如,Custom Role),
  • <subscriptionId><resourceGroupName>是您要给予访问权限的相应订阅和资源组的标识符。

示例:

  1. New-AzRoleAssignment -ObjectId "ae75b865-abf1-4376-afb8-54ebbf0b2051" `
  2. -RoleDefinitionName "Custom Role" `
  3. -Scope /subscriptions/4270e84b-c064-450b-9c67-a4a449d319df/resourcegroups/test-rg
展开查看全部

相关问题