az role assignment

管理角色指派。

命令

名稱 Description 類型 狀態
az role assignment create

為使用者、群組或服務主體建立新的角色指派。

核心 GA
az role assignment delete

刪除角色指派。

核心 GA
az role assignment list

列出角色指派。

核心 GA
az role assignment list-changelogs

列出角色指派的變更記錄。

核心 GA
az role assignment update

更新使用者、群組或服務主體的現有角色指派。

核心 GA

az role assignment create

為使用者、群組或服務主體建立新的角色指派。

az role assignment create --role
                          --scope
                          [--assignee]
                          [--assignee-object-id]
                          [--assignee-principal-type {ForeignGroup, Group, ServicePrincipal, User}]
                          [--condition]
                          [--condition-version]
                          [--description]
                          [--name]

範例

建立角色指派,將 Azure 虛擬機上的讀取者角色授與指定的被指派者。

az role assignment create --assignee sp_name --role Reader --scope /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MyResourceGroup/providers/Microsoft.Compute/virtualMachines/MyVm

為具有描述和條件的被指派者建立角色指派。

az role assignment create --role Owner --scope /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MyResourceGroup/providers/Microsoft.Storage/storageAccounts/MyStorageAccount --assignee "John.Doe@Contoso.com" --description "Role assignment foo to check on bar" --condition "@Resource[Microsoft.Storage/storageAccounts/blobServices/containers:Name] stringEquals 'foo'" --condition-version "2.0"

使用您自己的指派名稱建立角色指派。

az role assignment create --assignee-object-id 00000000-0000-0000-0000-000000000000 --assignee-principal-type ServicePrincipal --role Reader --scope /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MyResourceGroup --name 00000000-0000-0000-0000-000000000000

必要參數

--role

角色名稱或識別碼。

--scope

角色指派或定義適用的範圍,例如 /subscriptions/0b1f6471-1bf0-4dda-aec3-1111222223333、/subscriptions/0b1f6471-1bf0-4dda-aec3-11112222333/resourceGroups/myGroup, 或 /subscriptions/0b1f6471-1bf0-4dda-aec3-111112222333/resourceGroups/myGroup/providers/Microsoft.Compute/virtualMachines/myVM。

選擇性參數

--assignee

代表使用者、群組或服務主體。 支援的格式:物件標識碼、使用者登入名稱或服務主體名稱。

--assignee-object-id

如果許可權不足,請使用此參數而非 『--assignee』 來略過圖形 API 調用。 此參數僅適用於使用者、群組、服務主體和受控識別的物件標識碼。 針對受控識別,請使用主體標識符。針對服務主體,請使用物件標識碼,而不是應用程式識別碼。

--assignee-principal-type

搭配 --assignee-object-id 使用,以避免在 Microsoft Graph 中傳播延遲所造成的錯誤。

接受的值: ForeignGroup, Group, ServicePrincipal, User
--condition
預覽

使用者可獲得授權的條件。

--condition-version
預覽

條件語法的版本。 如果未指定 --condition-version,則預設為 2.0。

--description
預覽

角色指派的描述。

--name -n

角色指派的 GUID。 每個角色指派都必須是唯一且不同的。 如果省略,則會基因化新的 GUID。

全域參數
--debug

增加記錄詳細資訊,以顯示所有偵錯記錄。

--help -h

顯示此說明訊息並結束。

--only-show-errors

只顯示錯誤,隱藏警告。

--output -o

輸出格式。

接受的值: json, jsonc, none, table, tsv, yaml, yamlc
預設值: json
--query

JMESPath 查詢字串。 如需詳細資訊和範例,請參閱 http://jmespath.org/

--subscription

訂用帳戶的名稱或識別碼。 您可以使用 來設定預設訂用 az account set -s NAME_OR_ID帳戶。

--verbose

增加記錄詳細資訊。 使用 --debug 來取得完整偵錯記錄。

az role assignment delete

刪除角色指派。

az role assignment delete [--assignee]
                          [--ids]
                          [--include-inherited]
                          [--resource-group]
                          [--role]
                          [--scope]
                          [--yes]

範例

刪除角色指派。 ( 自動產生 )

az role assignment delete --assignee 00000000-0000-0000-0000-000000000000 --role "Storage Account Key Operator Service Role"

選擇性參數

--assignee

代表使用者、群組或服務主體。 支援的格式:物件標識碼、使用者登入名稱或服務主體名稱。

--ids

以空格分隔的角色指派標識碼。

--include-inherited

包含父範圍上套用的指派。

預設值: False
--resource-group -g

只有在資源群組層級新增角色或指派時,才使用它。

--role

角色名稱或識別碼。

--scope

角色指派或定義適用的範圍,例如 /subscriptions/0b1f6471-1bf0-4dda-aec3-1111222223333、/subscriptions/0b1f6471-1bf0-4dda-aec3-11112222333/resourceGroups/myGroup, 或 /subscriptions/0b1f6471-1bf0-4dda-aec3-111112222333/resourceGroups/myGroup/providers/Microsoft.Compute/virtualMachines/myVM。

--yes -y

繼續刪除訂用帳戶下的所有指派。

全域參數
--debug

增加記錄詳細資訊,以顯示所有偵錯記錄。

--help -h

顯示此說明訊息並結束。

--only-show-errors

只顯示錯誤,隱藏警告。

--output -o

輸出格式。

接受的值: json, jsonc, none, table, tsv, yaml, yamlc
預設值: json
--query

JMESPath 查詢字串。 如需詳細資訊和範例,請參閱 http://jmespath.org/

--subscription

訂用帳戶的名稱或識別碼。 您可以使用 來設定預設訂用 az account set -s NAME_OR_ID帳戶。

--verbose

增加記錄詳細資訊。 使用 --debug 來取得完整偵錯記錄。

az role assignment list

列出角色指派。

根據預設,只會顯示限定為訂用帳戶的指派。 若要檢視資源或群組範圍的工作分派,請使用 --all

az role assignment list [--all]
                        [--assignee]
                        [--include-classic-administrators {false, true}]
                        [--include-groups]
                        [--include-inherited]
                        [--resource-group]
                        [--role]
                        [--scope]

選擇性參數

--all

顯示目前訂用帳戶下的所有指派。

預設值: False
--assignee

代表使用者、群組或服務主體。 支援的格式:物件標識碼、使用者登入名稱或服務主體名稱。

--include-classic-administrators

列出訂用帳戶傳統系統管理員的預設角色指派,也稱為共同管理員。

接受的值: false, true
預設值: False
--include-groups

包含使用者所屬群組的額外指派(可轉移性)。

預設值: False
--include-inherited

包含父範圍上套用的指派。

預設值: False
--resource-group -g

只有在資源群組層級新增角色或指派時,才使用它。

--role

角色名稱或識別碼。

--scope

角色指派或定義適用的範圍,例如 /subscriptions/0b1f6471-1bf0-4dda-aec3-1111222223333、/subscriptions/0b1f6471-1bf0-4dda-aec3-11112222333/resourceGroups/myGroup, 或 /subscriptions/0b1f6471-1bf0-4dda-aec3-111112222333/resourceGroups/myGroup/providers/Microsoft.Compute/virtualMachines/myVM。

全域參數
--debug

增加記錄詳細資訊,以顯示所有偵錯記錄。

--help -h

顯示此說明訊息並結束。

--only-show-errors

只顯示錯誤,隱藏警告。

--output -o

輸出格式。

接受的值: json, jsonc, none, table, tsv, yaml, yamlc
預設值: json
--query

JMESPath 查詢字串。 如需詳細資訊和範例,請參閱 http://jmespath.org/

--subscription

訂用帳戶的名稱或識別碼。 您可以使用 來設定預設訂用 az account set -s NAME_OR_ID帳戶。

--verbose

增加記錄詳細資訊。 使用 --debug 來取得完整偵錯記錄。

az role assignment list-changelogs

列出角色指派的變更記錄。

az role assignment list-changelogs [--end-time]
                                   [--start-time]

選擇性參數

--end-time

查詢格式為 %Y-%m-%dT%H:%M:%SZ 的結束時間,例如 2000-12-31T12:59:59Z。 預設為目前時間。

--start-time

查詢的開始時間,格式為 %Y-%m-%dT%H:%M:%SZ,例如 2000-12-31T12:59:59Z。 預設為目前時間之前的 1 小時。

全域參數
--debug

增加記錄詳細資訊,以顯示所有偵錯記錄。

--help -h

顯示此說明訊息並結束。

--only-show-errors

只顯示錯誤,隱藏警告。

--output -o

輸出格式。

接受的值: json, jsonc, none, table, tsv, yaml, yamlc
預設值: json
--query

JMESPath 查詢字串。 如需詳細資訊和範例,請參閱 http://jmespath.org/

--subscription

訂用帳戶的名稱或識別碼。 您可以使用 來設定預設訂用 az account set -s NAME_OR_ID帳戶。

--verbose

增加記錄詳細資訊。 使用 --debug 來取得完整偵錯記錄。

az role assignment update

更新使用者、群組或服務主體的現有角色指派。

az role assignment update --role-assignment

範例

從 JSON 檔案更新角色指派。

az role assignment update --role-assignment assignment.json

從 JSON 字串更新角色指派。 (巴什)

az role assignment update --role-assignment '{
    "canDelegate": null,
    "condition": "@Resource[Microsoft.Storage/storageAccounts/blobServices/containers:Name] stringEquals '"'"'foo'"'"'",
    "conditionVersion": "2.0",
    "description": "Role assignment foo to check on bar",
    "id": "/subscriptions/00000001-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.Authorization/roleAssignments/3eabdd43-375b-4dbd-8dc4-04acd15ce56b",
    "name": "3eabdd43-375b-4dbd-8dc4-04acd15ce56b",
    "principalId": "00000002-0000-0000-0000-000000000000",
    "principalType": "User",
    "resourceGroup": "rg1",
    "roleDefinitionId": "/subscriptions/00000001-0000-0000-0000-000000000000/providers/Microsoft.Authorization/roleDefinitions/acdd72a7-3385-48ef-bd42-f606fba81ae7",
    "scope": "/subscriptions/00000001-0000-0000-0000-000000000000/resourceGroups/rg1",
    "type": "Microsoft.Authorization/roleAssignments"
}'

必要參數

--role-assignment

現有角色指派的描述為 JSON,或包含 JSON 描述的檔案路徑。

全域參數
--debug

增加記錄詳細資訊,以顯示所有偵錯記錄。

--help -h

顯示此說明訊息並結束。

--only-show-errors

只顯示錯誤,隱藏警告。

--output -o

輸出格式。

接受的值: json, jsonc, none, table, tsv, yaml, yamlc
預設值: json
--query

JMESPath 查詢字串。 如需詳細資訊和範例,請參閱 http://jmespath.org/

--subscription

訂用帳戶的名稱或識別碼。 您可以使用 來設定預設訂用 az account set -s NAME_OR_ID帳戶。

--verbose

增加記錄詳細資訊。 使用 --debug 來取得完整偵錯記錄。