我正在尝试使用 azure CLI 在 azure 中创建自定义角色。我一直在关注这个演练:
我对角色定义使用了完全相同的示例(仅针对我的订阅 ID 进行调整)。当我运行azure role create
输出看起来好像它正在成功创建:
info: Executing command role create
info: Validating role definition
+ Creating role definition "6b07875c-fa5b-4fc9-b95d-a665c3b4ad48"
info: Created role definition 6b07875c-fa5b-4fc9-b95d-a665c3b4ad48
data: Name : Virtual Machine Operator
data: Id : 6b07875c-fa5b-4fc9-b95d-a665c3b4ad48
data: Description : Can monitor and restart virtual machines.
data: AssignableScopes : 0=/subscriptions/xxxx
data: Actions : 0=Microsoft.Storage/*/read, 1=Microsoft.Network/*/read, 2=Microsoft.Compute/*/read, 3=Microsoft.Compute/virtualMachines/start/action, 4=Microsoft.Compute/virtualMachines/restart/action, 5=Microsoft.Authorization/*/read, 6=Microsoft.Resources/subscriptions/resourceGroups/read, 7=Microsoft.Insights/alertRules/*, 8=Microsoft.Insights/diagnosticSettings/*, 9=Microsoft.Support/*
data: NotActions :
data: IsCustom : true
data:
info: role create command OK
azure role list
但是,当我运行并azure role show "Virtual Machine Operator"
返回时,新角色不会出现:
info: Executing command role show
+ Searching for role definitions
info: No role definition matching the search criteria was found
info: role show command OK
我能发现发生任何事情的唯一提示是,如果我尝试azure role create
再次执行,它会返回以下内容:
info: Executing command role create
info: Validating role definition
+ Creating role definition "ce84ed80-ec75-4465-b668-b0752b959fcd"
error: A role definition cannot be updated with a name that already exists.
error: Error information has been recorded to C:\Users\James\.azure\azure.err
error: role create command failed