az policy assignment

管理資源原則指派。

命令

名稱 Description 類型 狀態
az policy assignment create

建立資源原則指派。

核心 GA
az policy assignment delete

刪除資源原則指派。

核心 GA
az policy assignment identity

管理原則指派的受控識別。

核心 GA
az policy assignment identity assign

將系統指派的身分識別或使用者指派的身分識別新增至原則指派。

核心 GA
az policy assignment identity remove

從原則指派中移除受控識別。

核心 GA
az policy assignment identity show

顯示原則指派的受控識別。

核心 GA
az policy assignment list

列出資源原則指派。

核心 GA
az policy assignment non-compliance-message

管理原則指派的不符合規範訊息。

核心 GA
az policy assignment non-compliance-message create

將不符合規範的訊息新增至原則指派。

核心 GA
az policy assignment non-compliance-message delete

從原則指派中移除一或多個不符合規範的郵件。

核心 GA
az policy assignment non-compliance-message list

列出原則指派的不符合規範訊息。

核心 GA
az policy assignment show

顯示資源原則指派。

核心 GA
az policy assignment update

更新資源原則指派。

核心 GA

az policy assignment create

建立資源原則指派。

az policy assignment create [--description]
                            [--display-name]
                            [--enforcement-mode {Default, DoNotEnforce}]
                            [--identity-scope]
                            [--location]
                            [--mi-system-assigned]
                            [--mi-user-assigned]
                            [--name]
                            [--not-scopes]
                            [--params]
                            [--policy]
                            [--policy-set-definition]
                            [--resource-group]
                            [--role]
                            [--scope]

範例

在範圍建立資源原則指派

Valid scopes are management group, subscription, resource group, and resource, for example
   management group:  /providers/Microsoft.Management/managementGroups/MyManagementGroup
   subscription:      /subscriptions/0b1f6471-1bf0-4dda-aec3-111122223333
   resource group:    /subscriptions/0b1f6471-1bf0-4dda-aec3-111122223333/resourceGroups/myGroup
   resource:          /subscriptions/0b1f6471-1bf0-4dda-aec3-111122223333/resourceGroups/myGroup/providers/Microsoft.Compute/virtualMachines/myVM
     az policy assignment create --scope \
        "/providers/Microsoft.Management/managementGroups/MyManagementGroup" \
            --policy {PolicyName} -p "{ \"allowedLocations\": \
                { \"value\": [ \"australiaeast\", \"eastus\", \"japaneast\" ] } }"

建立資源原則指派並提供規則參數值。

az policy assignment create --policy {PolicyName} -p "{ \"allowedLocations\": \
    { \"value\": [ \"australiaeast\", \"eastus\", \"japaneast\" ] } }"

使用系統指派的身分識別建立資源原則指派。

az policy assignment create --name myPolicy --policy {PolicyName} --mi-system-assigned --location eastus

使用系統指派的身分識別建立資源原則指派。 身分識別將具有訂用帳戶的「參與者」角色存取權。

az policy assignment create --name myPolicy --policy {PolicyName} --mi-system-assigned --identity-scope /subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx --role Contributor --location eastus

使用使用者指派的身分識別建立資源原則指派。

az policy assignment create --name myPolicy --policy {PolicyName} -g MyResourceGroup --mi-user-assigned myAssignedId --location westus

使用強制模式建立資源原則指派。 它會指出在指派建立和更新期間是否強制執行原則效果。 如需詳細資訊,請造訪 https://aka.ms/azure-policyAssignment-enforcement-mode 。

az policy assignment create --name myPolicy --policy {PolicyName} --enforcement-mode 'DoNotEnforce'

選擇性參數

--description

原則指派的描述。

--display-name

原則指派的顯示名稱。

--enforcement-mode -e

原則指派的強制模式,例如 Default、DoNotEnforce。 如需詳細資訊,請造訪 https://aka.ms/azure-policyAssignment-enforcement-mode

接受的值: Default, DoNotEnforce
預設值: Default
--identity-scope

系統指派的身分識別可以存取的範圍。

--location -l

原則指派的位置。 只有在使用受控識別時才需要。

--mi-system-assigned

提供此旗標以使用系統指派的身分識別進行原則指派。 如需更多範例,請參閱說明。

--mi-user-assigned

要用於原則指派的 UserAssigned Identity Id。 如需更多範例,請參閱說明。

--name -n

新原則指派的名稱。

--not-scopes

原則指派不適用的空間分隔範圍。

--params -p

JSON 格式化字串或具有原則規則參數值的檔案或 URI 路徑。

--policy

原則定義的名稱或識別碼。 如果未提供,則必須提供原則集定義參數。

--policy-set-definition -d

原則集定義的名稱或識別碼。 如果未提供,則必須提供原則定義參數。

--resource-group -g

將套用原則的資源群組。

--role

將指派給受控識別的角色名稱或識別碼。

預設值: Contributor
--scope

套用此原則指派的範圍。

全域參數
--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 policy assignment delete

刪除資源原則指派。

az policy assignment delete --name
                            [--resource-group]
                            [--scope]

範例

刪除資源原則指派。 (自動產生)

az policy assignment delete --name MyPolicyAssignment

必要參數

--name -n

原則指派的名稱。

選擇性參數

--resource-group -g

將套用原則的資源群組。

--scope

套用此原則指派子命令的範圍。 預設為目前的內容訂閱。

全域參數
--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 policy assignment list

列出資源原則指派。

az policy assignment list [--disable-scope-strict-match]
                          [--resource-group]
                          [--scope]

選擇性參數

--disable-scope-strict-match

包含繼承自父範圍或子範圍的原則指派。

--resource-group -g

將套用原則的資源群組。

--scope

套用此原則指派子命令的範圍。 預設為目前的內容訂閱。

全域參數
--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 policy assignment show

顯示資源原則指派。

az policy assignment show --name
                          [--resource-group]
                          [--scope]

範例

顯示資源原則指派。 (自動產生)

az policy assignment show --name MyPolicyAssignment

必要參數

--name -n

原則指派的名稱。

選擇性參數

--resource-group -g

將套用原則的資源群組。

--scope

套用此原則指派子命令的範圍。 預設為目前的內容訂閱。

全域參數
--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 policy assignment update

更新資源原則指派。

az policy assignment update [--description]
                            [--display-name]
                            [--enforcement-mode {Default, DoNotEnforce}]
                            [--name]
                            [--not-scopes]
                            [--params]
                            [--resource-group]
                            [--scope]

範例

更新資源原則指派的描述。

az policy assignment update --name myPolicy --description 'My policy description'

選擇性參數

--description

原則指派的描述。

--display-name

原則指派的顯示名稱。

--enforcement-mode -e

原則指派的強制模式,例如 Default、DoNotEnforce。 如需詳細資訊,請造訪 https://aka.ms/azure-policyAssignment-enforcement-mode

接受的值: Default, DoNotEnforce
--name -n

原則指派的名稱。

--not-scopes

原則指派不適用的空間分隔範圍。

--params -p

JSON 格式化字串或具有原則規則參數值的檔案或 URI 路徑。

--resource-group -g

將套用原則的資源群組。

--scope

套用此原則指派子命令的範圍。 預設為目前的內容訂閱。

全域參數
--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 來取得完整偵錯記錄。