az role definition
管理角色定義。
命令
| 名稱 | Description | 類型 | 狀態 |
|---|---|---|---|
| az role definition create |
建立自定義角色定義。 |
Core | GA |
| az role definition delete |
刪除角色定義。 |
Core | GA |
| az role definition list |
列出角色定義。 |
Core | GA |
| az role definition show |
顯示角色定義。 |
Core | GA |
| az role definition update |
更新角色定義。 |
Core | GA |
az role definition create
建立自定義角色定義。
az role definition create --role-definition
範例
建立具有記憶體和網路資源唯讀存取權的角色,以及啟動或重新啟動 VM 的能力。 (Bash)
az role definition create --role-definition '{
"Name": "Contoso On-call",
"Description": "Perform VM actions and read storage and network information.",
"Actions": [
"Microsoft.Compute/*/read",
"Microsoft.Compute/virtualMachines/start/action",
"Microsoft.Compute/virtualMachines/restart/action",
"Microsoft.Network/*/read",
"Microsoft.Storage/*/read",
"Microsoft.Authorization/*/read",
"Microsoft.Resources/subscriptions/resourceGroups/read",
"Microsoft.Resources/subscriptions/resourceGroups/resources/read",
"Microsoft.Insights/alertRules/*",
"Microsoft.Support/*"
],
"DataActions": [
"Microsoft.Storage/storageAccounts/blobServices/containers/blobs/*"
],
"NotDataActions": [
"Microsoft.Storage/storageAccounts/blobServices/containers/blobs/write"
],
"AssignableScopes": ["/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"]
}'
從包含 JSON 描述的檔案建立角色。
az role definition create --role-definition @ad-role.json
必要參數
角色描述為 JSON,或包含 JSON 描述的檔案路徑。
全域參數
提高日誌詳細程度以顯示所有調試日誌。
| 屬性 | 值 |
|---|---|
| 預設值: | False |
顯示此說明訊息並結束。
只顯示錯誤,隱藏警告。
| 屬性 | 值 |
|---|---|
| 預設值: | False |
輸出格式。
| 屬性 | 值 |
|---|---|
| 預設值: | json |
| 接受的值: | json, jsonc, none, table, tsv, yaml, yamlc |
JMESPath 查詢字串。 如需詳細資訊和範例,請參閱 http://jmespath.org/。
訂用帳戶的名稱或標識碼。 您可以使用 az account set -s NAME_OR_ID來設定預設訂用帳戶。
增加記錄的詳細程度。 針對完整偵錯記錄使用 --debug。
| 屬性 | 值 |
|---|---|
| 預設值: | False |
az role definition delete
刪除角色定義。
az role definition delete --name
[--custom-role-only {false, true}]
[--resource-group]
[--scope]
範例
刪除角色定義。 (autogenerated)
az role definition delete --name MyRole
必要參數
符合角色定義的名稱 (GUID) 或 roleName (例如 'Reader') 屬性。
選擇性參數
下列參數是選擇性參數,但視內容而定,命令可能需要一或多個參數才能成功執行。
僅限自定義角色(與內建角色的比較)。
| 屬性 | 值 |
|---|---|
| 預設值: | False |
| 接受的值: | false, true |
只有在資源群組層級新增角色或指派時,才使用它。
角色指派或定義適用的範圍,例如 /subscriptions/0b1f6471-1bf0-4dda-aec3-1111222223333、/subscriptions/0b1f6471-1bf0-4dda-aec3-11112222333/resourceGroups/myGroup, 或 /subscriptions/0b1f6471-1bf0-4dda-aec3-11112222333/resourceGroups/myGroup/providers/Microsoft.Compute/virtualMachines/myVM。
全域參數
提高日誌詳細程度以顯示所有調試日誌。
| 屬性 | 值 |
|---|---|
| 預設值: | False |
顯示此說明訊息並結束。
只顯示錯誤,隱藏警告。
| 屬性 | 值 |
|---|---|
| 預設值: | False |
輸出格式。
| 屬性 | 值 |
|---|---|
| 預設值: | json |
| 接受的值: | json, jsonc, none, table, tsv, yaml, yamlc |
JMESPath 查詢字串。 如需詳細資訊和範例,請參閱 http://jmespath.org/。
訂用帳戶的名稱或標識碼。 您可以使用 az account set -s NAME_OR_ID來設定預設訂用帳戶。
增加記錄的詳細程度。 針對完整偵錯記錄使用 --debug。
| 屬性 | 值 |
|---|---|
| 預設值: | False |
az role definition list
列出角色定義。
az role definition list [--custom-role-only {false, true}]
[--name]
[--resource-group]
[--scope]
選擇性參數
下列參數是選擇性參數,但視內容而定,命令可能需要一或多個參數才能成功執行。
僅限自定義角色(與內建角色的比較)。
| 屬性 | 值 |
|---|---|
| 預設值: | False |
| 接受的值: | false, true |
符合角色定義的名稱 (GUID) 或 roleName (例如 'Reader') 屬性。 如果提供 GUID,以提升效能,請使用 az role definition show 命令。
只有在資源群組層級新增角色或指派時,才使用它。
角色指派或定義適用的範圍,例如 /subscriptions/0b1f6471-1bf0-4dda-aec3-1111222223333、/subscriptions/0b1f6471-1bf0-4dda-aec3-11112222333/resourceGroups/myGroup, 或 /subscriptions/0b1f6471-1bf0-4dda-aec3-11112222333/resourceGroups/myGroup/providers/Microsoft.Compute/virtualMachines/myVM。
全域參數
提高日誌詳細程度以顯示所有調試日誌。
| 屬性 | 值 |
|---|---|
| 預設值: | False |
顯示此說明訊息並結束。
只顯示錯誤,隱藏警告。
| 屬性 | 值 |
|---|---|
| 預設值: | False |
輸出格式。
| 屬性 | 值 |
|---|---|
| 預設值: | json |
| 接受的值: | json, jsonc, none, table, tsv, yaml, yamlc |
JMESPath 查詢字串。 如需詳細資訊和範例,請參閱 http://jmespath.org/。
訂用帳戶的名稱或標識碼。 您可以使用 az account set -s NAME_OR_ID來設定預設訂用帳戶。
增加記錄的詳細程度。 針對完整偵錯記錄使用 --debug。
| 屬性 | 值 |
|---|---|
| 預設值: | False |
az role definition show
顯示角色定義。
az role definition show [--id]
[--name]
[--scope]
範例
顯示名稱為 [讀取者] 角色定義 (GUID)。
az role definition show --scope /subscriptions/00000000-0000-0000-0000-000000000000 --name acdd72a7-3385-48ef-bd42-f606fba81ae7
顯示具有其資源識別碼的「讀取者」角色定義。
az role definition show --id /subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Authorization/roleDefinitions/acdd72a7-3385-48ef-bd42-f606fba81ae7
選擇性參數
下列參數是選擇性參數,但視內容而定,命令可能需要一或多個參數才能成功執行。
完整角色定義標識碼。 針對訂用帳戶層級角色定義,請使用 /subscriptions/{guid}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId} 的格式,或租用戶層級角色定義的 /providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}。
角色定義的名稱 (GUID)。
角色指派或定義適用的範圍,例如 /subscriptions/0b1f6471-1bf0-4dda-aec3-1111222223333、/subscriptions/0b1f6471-1bf0-4dda-aec3-11112222333/resourceGroups/myGroup, 或 /subscriptions/0b1f6471-1bf0-4dda-aec3-11112222333/resourceGroups/myGroup/providers/Microsoft.Compute/virtualMachines/myVM。
全域參數
提高日誌詳細程度以顯示所有調試日誌。
| 屬性 | 值 |
|---|---|
| 預設值: | False |
顯示此說明訊息並結束。
只顯示錯誤,隱藏警告。
| 屬性 | 值 |
|---|---|
| 預設值: | False |
輸出格式。
| 屬性 | 值 |
|---|---|
| 預設值: | json |
| 接受的值: | json, jsonc, none, table, tsv, yaml, yamlc |
JMESPath 查詢字串。 如需詳細資訊和範例,請參閱 http://jmespath.org/。
訂用帳戶的名稱或標識碼。 您可以使用 az account set -s NAME_OR_ID來設定預設訂用帳戶。
增加記錄的詳細程度。 針對完整偵錯記錄使用 --debug。
| 屬性 | 值 |
|---|---|
| 預設值: | False |
az role definition update
更新角色定義。
az role definition update --role-definition
範例
使用 「az role definition list」 的輸出來更新角色。 (Bash)
az role definition update --role-definition '{
"roleName": "Contoso On-call",
"Description": "Perform VM actions and read storage and network information.",
"id": "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/providers/Microsoft.Authorization/roleDefinitions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"roleType": "CustomRole",
"type": "Microsoft.Authorization/roleDefinitions",
"Actions": [
"Microsoft.Compute/*/read",
"Microsoft.Compute/virtualMachines/start/action",
"Microsoft.Compute/virtualMachines/restart/action",
"Microsoft.Network/*/read",
"Microsoft.Storage/*/read",
"Microsoft.Authorization/*/read",
"Microsoft.Resources/subscriptions/resourceGroups/read",
"Microsoft.Resources/subscriptions/resourceGroups/resources/read",
"Microsoft.Support/*"
],
"DataActions": [
"Microsoft.Storage/storageAccounts/blobServices/containers/blobs/*"
],
"NotDataActions": [
"Microsoft.Storage/storageAccounts/blobServices/containers/blobs/write"
],
"AssignableScopes": ["/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"]
}'
必要參數
現有角色的描述為 JSON,或包含 JSON 描述的檔案路徑。
全域參數
提高日誌詳細程度以顯示所有調試日誌。
| 屬性 | 值 |
|---|---|
| 預設值: | False |
顯示此說明訊息並結束。
只顯示錯誤,隱藏警告。
| 屬性 | 值 |
|---|---|
| 預設值: | False |
輸出格式。
| 屬性 | 值 |
|---|---|
| 預設值: | json |
| 接受的值: | json, jsonc, none, table, tsv, yaml, yamlc |
JMESPath 查詢字串。 如需詳細資訊和範例,請參閱 http://jmespath.org/。
訂用帳戶的名稱或標識碼。 您可以使用 az account set -s NAME_OR_ID來設定預設訂用帳戶。
增加記錄的詳細程度。 針對完整偵錯記錄使用 --debug。
| 屬性 | 值 |
|---|---|
| 預設值: | False |