az policy assignment
管理資源原則指派。
命令
| 名稱 | Description | 類型 | 狀態 |
|---|---|---|---|
| az policy assignment create |
建立資源原則指派。 |
Core | GA |
| az policy assignment delete |
刪除資源原則指派。 |
Core | GA |
| az policy assignment identity |
管理原則指派的受控識別。 |
Core | GA |
| az policy assignment identity assign |
將系統指派的身分識別或使用者指派的身分識別新增至原則指派。 |
Core | GA |
| az policy assignment identity remove |
從原則指派中移除受控識別。 |
Core | GA |
| az policy assignment identity show |
顯示原則指派的受控識別。 |
Core | GA |
| az policy assignment list |
列出資源原則指派。 |
Core | GA |
| az policy assignment non-compliance-message |
管理原則指派的不符合規範訊息。 |
Core | GA |
| az policy assignment non-compliance-message create |
將不符合規範的訊息新增至原則指派。 |
Core | GA |
| az policy assignment non-compliance-message delete |
從原則指派中移除一或多個不符合規範的郵件。 |
Core | GA |
| az policy assignment non-compliance-message list |
列出原則指派的不符合規範訊息。 |
Core | GA |
| az policy assignment show |
顯示資源原則指派。 |
Core | GA |
| az policy assignment update |
更新資源原則指派。 |
Core | 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'
選擇性參數
The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.
原則指派的描述。
原則指派的顯示名稱。
原則指派的強制模式,例如 Default、DoNotEnforce。 如需詳細資訊,請造訪 https://aka.ms/azure-policyAssignment-enforcement-mode。
| 屬性 | 值 |
|---|---|
| 預設值: | Default |
| 接受的值: | Default, DoNotEnforce |
系統指派的身分識別可以存取的範圍。
| 屬性 | 值 |
|---|---|
| Parameter group: | Managed Identity Arguments |
原則指派的位置。 只有在使用受控識別時才需要。
提供此旗標以使用系統指派的身分識別進行原則指派。 如需更多範例,請參閱說明。
| 屬性 | 值 |
|---|---|
| Parameter group: | Managed Identity Arguments |
要用於原則指派的UserAssigned Identity Id。 如需更多範例,請參閱說明。
| 屬性 | 值 |
|---|---|
| Parameter group: | Managed Identity Arguments |
新原則指派的名稱。
原則指派不適用的空間分隔範圍。
JSON 格式化字串或具有原則規則參數值的檔案或 URI 路徑。
原則定義的名稱或識別碼。 如果未提供,則必須提供原則集定義參數。
原則集定義的名稱或識別碼。 如果未提供,則必須提供原則定義參數。
將套用原則的資源群組。
將指派給受控識別的角色名稱或標識碼。
| 屬性 | 值 |
|---|---|
| Parameter group: | Managed Identity Arguments |
| 預設值: | Contributor |
套用此原則指派的範圍。
全域參數
提高日誌詳細程度以顯示所有調試日誌。
| 屬性 | 值 |
|---|---|
| 預設值: | False |
顯示此說明訊息並結束。
只顯示錯誤,隱藏警告。
| 屬性 | 值 |
|---|---|
| 預設值: | False |
輸出格式。
| 屬性 | 值 |
|---|---|
| 預設值: | json |
| 接受的值: | json, jsonc, none, table, tsv, yaml, yamlc |
JMESPath 查詢字串。 如需詳細資訊和範例,請參閱 http://jmespath.org/。
訂用帳戶的名稱或標識碼。 您可以使用 az account set -s NAME_OR_ID來設定預設訂用帳戶。
增加記錄的詳細程度。 針對完整偵錯記錄使用 --debug。
| 屬性 | 值 |
|---|---|
| 預設值: | False |
az policy assignment delete
刪除資源原則指派。
az policy assignment delete --name
[--resource-group]
[--scope]
範例
刪除資源原則指派。 (autogenerated)
az policy assignment delete --name MyPolicyAssignment
必要參數
原則指派的名稱。
選擇性參數
The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.
將套用原則的資源群組。
套用此原則指派子命令的範圍。 預設為目前的內容訂閱。
全域參數
提高日誌詳細程度以顯示所有調試日誌。
| 屬性 | 值 |
|---|---|
| 預設值: | False |
顯示此說明訊息並結束。
只顯示錯誤,隱藏警告。
| 屬性 | 值 |
|---|---|
| 預設值: | False |
輸出格式。
| 屬性 | 值 |
|---|---|
| 預設值: | json |
| 接受的值: | json, jsonc, none, table, tsv, yaml, yamlc |
JMESPath 查詢字串。 如需詳細資訊和範例,請參閱 http://jmespath.org/。
訂用帳戶的名稱或標識碼。 您可以使用 az account set -s NAME_OR_ID來設定預設訂用帳戶。
增加記錄的詳細程度。 針對完整偵錯記錄使用 --debug。
| 屬性 | 值 |
|---|---|
| 預設值: | False |
az policy assignment list
列出資源原則指派。
az policy assignment list [--disable-scope-strict-match]
[--resource-group]
[--scope]
選擇性參數
The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.
包含繼承自父範圍或子範圍的原則指派。
將套用原則的資源群組。
套用此原則指派子命令的範圍。 預設為目前的內容訂閱。
全域參數
提高日誌詳細程度以顯示所有調試日誌。
| 屬性 | 值 |
|---|---|
| 預設值: | False |
顯示此說明訊息並結束。
只顯示錯誤,隱藏警告。
| 屬性 | 值 |
|---|---|
| 預設值: | False |
輸出格式。
| 屬性 | 值 |
|---|---|
| 預設值: | json |
| 接受的值: | json, jsonc, none, table, tsv, yaml, yamlc |
JMESPath 查詢字串。 如需詳細資訊和範例,請參閱 http://jmespath.org/。
訂用帳戶的名稱或標識碼。 您可以使用 az account set -s NAME_OR_ID來設定預設訂用帳戶。
增加記錄的詳細程度。 針對完整偵錯記錄使用 --debug。
| 屬性 | 值 |
|---|---|
| 預設值: | False |
az policy assignment show
顯示資源原則指派。
az policy assignment show --name
[--resource-group]
[--scope]
範例
顯示資源原則指派。 (autogenerated)
az policy assignment show --name MyPolicyAssignment
必要參數
原則指派的名稱。
選擇性參數
The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.
將套用原則的資源群組。
套用此原則指派子命令的範圍。 預設為目前的內容訂閱。
全域參數
提高日誌詳細程度以顯示所有調試日誌。
| 屬性 | 值 |
|---|---|
| 預設值: | False |
顯示此說明訊息並結束。
只顯示錯誤,隱藏警告。
| 屬性 | 值 |
|---|---|
| 預設值: | False |
輸出格式。
| 屬性 | 值 |
|---|---|
| 預設值: | json |
| 接受的值: | json, jsonc, none, table, tsv, yaml, yamlc |
JMESPath 查詢字串。 如需詳細資訊和範例,請參閱 http://jmespath.org/。
訂用帳戶的名稱或標識碼。 您可以使用 az account set -s NAME_OR_ID來設定預設訂用帳戶。
增加記錄的詳細程度。 針對完整偵錯記錄使用 --debug。
| 屬性 | 值 |
|---|---|
| 預設值: | False |
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'
選擇性參數
The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.
原則指派的描述。
原則指派的顯示名稱。
原則指派的強制模式,例如 Default、DoNotEnforce。 如需詳細資訊,請造訪 https://aka.ms/azure-policyAssignment-enforcement-mode。
| 屬性 | 值 |
|---|---|
| 接受的值: | Default, DoNotEnforce |
原則指派的名稱。
原則指派不適用的空間分隔範圍。
JSON 格式化字串或具有原則規則參數值的檔案或 URI 路徑。
將套用原則的資源群組。
套用此原則指派子命令的範圍。 預設為目前的內容訂閱。
全域參數
提高日誌詳細程度以顯示所有調試日誌。
| 屬性 | 值 |
|---|---|
| 預設值: | False |
顯示此說明訊息並結束。
只顯示錯誤,隱藏警告。
| 屬性 | 值 |
|---|---|
| 預設值: | False |
輸出格式。
| 屬性 | 值 |
|---|---|
| 預設值: | json |
| 接受的值: | json, jsonc, none, table, tsv, yaml, yamlc |
JMESPath 查詢字串。 如需詳細資訊和範例,請參閱 http://jmespath.org/。
訂用帳戶的名稱或標識碼。 您可以使用 az account set -s NAME_OR_ID來設定預設訂用帳戶。
增加記錄的詳細程度。 針對完整偵錯記錄使用 --debug。
| 屬性 | 值 |
|---|---|
| 預設值: | False |