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 non-compliance-message show |
擷取不合規訊息。 |
Core | GA |
| az policy assignment non-compliance-message update |
更新不合規訊息。 |
Core | GA |
| az policy assignment show |
擷取原則指派。 |
Core | GA |
| az policy assignment update |
更新原則指派。 |
Core | GA |
az policy assignment create
建立原則指派。
使用指定的範圍和名稱建立原則指派。 原則指派會套用至其範圍內所包含的所有資源。 例如,當您在資源群組範圍指派原則時,該原則會套用至群組中的所有資源。
az policy assignment create [--acquire-policy-token]
[--assign-identity --mi-system-assigned --system-assigned]
[--change-reference]
[--definition-version]
[--description]
[--display-name]
[--enforcement-mode {Default, DoNotEnforce}]
[--identity-scope]
[--location]
[--metadata]
[--mi-user-assigned --user-assigned]
[--name]
[--non-compliance-messages]
[--not-scopes]
[--overrides]
[--params]
[--policy]
[--policy-set-definition]
[--resource-group]
[--resource-selectors]
[--role]
[--scope]
範例
在範圍建立資源原則指派
az policy assignment create --scope "/providers/Microsoft.Management/managementGroups/{managementGroupName}" --policy {policyName} -p "{ 'allowedLocations': { 'value': [ 'australiaeast', 'eastus', 'japaneast' ] } }"
建立資源政策指派並提供規則參數值
az Create a resource policy assignment and provide rule parameter values 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/{subscriptionId} --role Contributor --location eastus
建立一個資源政策指派,並以使用者指派身份
az policy assignment create --name myPolicy --policy {policyName} -g MyResourceGroup --mi-user-assigned myAssignedId --location westus
建立帶有強制模式的資源政策指派
az policy assignment create --name myPolicy --policy {policyName} --enforcement-mode DoNotEnforce
選擇性參數
下列參數是選擇性參數,但視內容而定,命令可能需要一或多個參數才能成功執行。
自動取得 Azure 原則 令牌以進行此資源操作。
| 屬性 | 值 |
|---|---|
| 參數群組: | Global Policy Arguments |
設定系統指派的管理身份。
| 屬性 | 值 |
|---|---|
| 參數群組: | Identity Arguments |
相關變更的 ID 是為此資源操作所參考的。
| 屬性 | 值 |
|---|---|
| 參數群組: | Global Policy Arguments |
要指派的政策版本。
| 屬性 | 值 |
|---|---|
| 參數群組: | Properties Arguments |
政策指派說明。
| 屬性 | 值 |
|---|---|
| 參數群組: | Properties Arguments |
原則指派的顯示名稱。
| 屬性 | 值 |
|---|---|
| 參數群組: | Properties Arguments |
原則指派強制模式。
| 屬性 | 值 |
|---|---|
| 參數群組: | Properties Arguments |
| 預設值: | Default |
| 接受的值: | Default, DoNotEnforce |
系統指派的身分識別可以存取的範圍。
原則指派的位置。
| 屬性 | 值 |
|---|---|
| 參數群組: | Parameters Arguments |
原則指派元數據。 支援速記語法、json-file 和 yaml-file。 請嘗試 “??” 以顯示更多。
| 屬性 | 值 |
|---|---|
| 參數群組: | Properties Arguments |
設定使用者指派的管理身份。 支援速記語法、json-file 和 yaml-file。 請嘗試 “??” 以顯示更多。
| 屬性 | 值 |
|---|---|
| 參數群組: | Identity Arguments |
原則指派的名稱。
描述資源不符合原則之原因的訊息。 支援速記語法、json-file 和 yaml-file。 請嘗試 “??” 以顯示更多。
| 屬性 | 值 |
|---|---|
| 參數群組: | non-compliance-message Arguments |
政策指派不包含範圍。 支援速記語法、json-file 和 yaml-file。 請嘗試 “??” 以顯示更多。
| 屬性 | 值 |
|---|---|
| 參數群組: | Properties Arguments |
政策覆寫。 支援速記語法、json-file 和 yaml-file。 請嘗試 “??” 以顯示更多。
| 屬性 | 值 |
|---|---|
| 參數群組: | Properties Arguments |
指派原則規則的參數值。 支援速記語法、json-file 和 yaml-file。 請嘗試 “??” 以顯示更多。
| 屬性 | 值 |
|---|---|
| 參數群組: | Properties Arguments |
要指派的政策定義或政策集定義的名稱或資源 ID。
要指派的政策定義或政策集合定義。
| 屬性 | 值 |
|---|---|
| 參數群組: | Properties Arguments |
資源群組的名稱。 您可以使用 az configure --defaults group=<name> 來設定預設群組。
資源選取器清單可依資源內容篩選原則。 支援速記語法、json-file 和 yaml-file。 請嘗試 “??” 以顯示更多。
| 屬性 | 值 |
|---|---|
| 參數群組: | Properties Arguments |
將指派給受控識別的角色名稱或標識碼。
原則指派的範圍。
全域參數
提高日誌詳細程度以顯示所有調試日誌。
| 屬性 | 值 |
|---|---|
| 預設值: | 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
[--acquire-policy-token]
[--change-reference]
[--resource-group]
[--scope]
範例
在作用域刪除政策指派
az policy assignment delete --scope subscriptions/{subscriptionId} --name EnforceNaming
刪除政策指派
az policy assignment delete --name MyPolicyAssignment
必要參數
原則指派的名稱。
選擇性參數
下列參數是選擇性參數,但視內容而定,命令可能需要一或多個參數才能成功執行。
自動取得 Azure 原則 令牌以進行此資源操作。
| 屬性 | 值 |
|---|---|
| 參數群組: | Global Policy Arguments |
相關變更的 ID 是為此資源操作所參考的。
| 屬性 | 值 |
|---|---|
| 參數群組: | Global Policy Arguments |
資源群組的名稱。 您可以使用 az configure --defaults group=<name> 來設定預設群組。
原則指派的範圍。
全域參數
提高日誌詳細程度以顯示所有調試日誌。
| 屬性 | 值 |
|---|---|
| 預設值: | 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 {0, 1, f, false, n, no, t, true, y, yes}]
[--expand]
[--filter]
[--management-group]
[--max-items]
[--next-token]
[--resource-group]
[--scope]
範例
列出適用於資源群組的政策指派
az policy assignment list --resource-group TestResourceGroup --filter atScope() --expand LatestDefinitionVersion, EffectiveDefinitionVersion
適用於管理群組的清單政策指派
az policy assignment list --management-group TestManagementGroup --filter atScope()
列出適用於訂閱的政策指派
az policy assignment list --filter atScope()
選擇性參數
下列參數是選擇性參數,但視內容而定,命令可能需要一或多個參數才能成功執行。
包含從父範圍繼承或子範圍繼承的政策指派。
| 屬性 | 值 |
|---|---|
| 接受的值: | 0, 1, f, false, n, no, t, true, y, yes |
要包含在輸出中的其他屬性。
篩選清單結果。
管理小組。
命令輸出中要傳回的項目總數。 如果可用的專案總數超過指定的值,則會在命令的輸出中提供令牌。 若要繼續分頁,請在後續命令的 --next-token 自變數中提供令牌值。
| 屬性 | 值 |
|---|---|
| 參數群組: | Pagination Arguments |
標記,指定要開始分頁的位置。 這是先前截斷回應中的令牌值。
| 屬性 | 值 |
|---|---|
| 參數群組: | Pagination Arguments |
資源群組。
列出適用保單指派的範圍。 如果未提供範圍,則範圍會是隱含或指定的訂閱。
全域參數
提高日誌詳細程度以顯示所有調試日誌。
| 屬性 | 值 |
|---|---|
| 預設值: | 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
[--expand]
[--resource-group]
[--scope]
範例
顯示資源政策指派
az policy assignment show --name MyPolicyAssignment
必要參數
原則指派的名稱。
選擇性參數
下列參數是選擇性參數,但視內容而定,命令可能需要一或多個參數才能成功執行。
要包含在輸出中的其他屬性。
資源群組的名稱。 您可以使用 az configure --defaults group=<name> 來設定預設群組。
原則指派的範圍。
全域參數
提高日誌詳細程度以顯示所有調試日誌。
| 屬性 | 值 |
|---|---|
| 預設值: | 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 --name
[--acquire-policy-token]
[--add]
[--change-reference]
[--definition-version]
[--description]
[--display-name]
[--enforcement-mode {Default, DoNotEnforce}]
[--force-string {0, 1, f, false, n, no, t, true, y, yes}]
[--location]
[--metadata]
[--non-compliance-messages]
[--not-scopes]
[--overrides]
[--params]
[--policy]
[--policy-set-definition]
[--remove]
[--resource-group]
[--resource-selectors]
[--scope]
[--set]
範例
更新資源政策指派的描述
az policy assignment update --name myPolicy --description 'My policy description'
必要參數
原則指派的名稱。
選擇性參數
下列參數是選擇性參數,但視內容而定,命令可能需要一或多個參數才能成功執行。
自動取得 Azure 原則 令牌以進行此資源操作。
| 屬性 | 值 |
|---|---|
| 參數群組: | Global Policy Arguments |
藉由指定路徑和索引鍵值組,將物件加入物件清單。 範例:--add property.listProperty <key=value, string or JSON string>。
| 屬性 | 值 |
|---|---|
| 參數群組: | Generic Update Arguments |
相關變更的 ID 是為此資源操作所參考的。
| 屬性 | 值 |
|---|---|
| 參數群組: | Global Policy Arguments |
要指派的政策版本。
| 屬性 | 值 |
|---|---|
| 參數群組: | Properties Arguments |
政策指派說明。
| 屬性 | 值 |
|---|---|
| 參數群組: | Properties Arguments |
原則指派的顯示名稱。
| 屬性 | 值 |
|---|---|
| 參數群組: | Properties Arguments |
原則指派強制模式。
| 屬性 | 值 |
|---|---|
| 參數群組: | Properties Arguments |
| 接受的值: | Default, DoNotEnforce |
使用 'set' 或 'add' 時,請保留字串常值,而不是嘗試轉換成 JSON。
| 屬性 | 值 |
|---|---|
| 參數群組: | Generic Update Arguments |
| 接受的值: | 0, 1, f, false, n, no, t, true, y, yes |
原則指派的位置。
| 屬性 | 值 |
|---|---|
| 參數群組: | Parameters Arguments |
原則指派元數據。 支援速記語法、json-file 和 yaml-file。 請嘗試 “??” 以顯示更多。
| 屬性 | 值 |
|---|---|
| 參數群組: | Properties Arguments |
描述資源不符合原則之原因的訊息。 支援速記語法、json-file 和 yaml-file。 請嘗試 “??” 以顯示更多。
| 屬性 | 值 |
|---|---|
| 參數群組: | non-compliance-message Arguments |
政策指派不包含範圍。 支援速記語法、json-file 和 yaml-file。 請嘗試 “??” 以顯示更多。
| 屬性 | 值 |
|---|---|
| 參數群組: | Properties Arguments |
原則屬性值覆寫。 支援速記語法、json-file 和 yaml-file。 請嘗試 “??” 以顯示更多。
| 屬性 | 值 |
|---|---|
| 參數群組: | Properties Arguments |
指派原則規則的參數值。 支援速記語法、json-file 和 yaml-file。 請嘗試 “??” 以顯示更多。
| 屬性 | 值 |
|---|---|
| 參數群組: | Properties Arguments |
要指派的政策定義或政策集定義的名稱或資源 ID。
要指派的政策定義或政策集合定義。
| 屬性 | 值 |
|---|---|
| 參數群組: | Properties Arguments |
從清單中移除屬性或專案。 範例: --remove property.list <indexToRemove> 或 --remove propertyToRemove。
| 屬性 | 值 |
|---|---|
| 參數群組: | Generic Update Arguments |
資源群組的名稱。 您可以使用 az configure --defaults group=<name> 來設定預設群組。
資源選取器清單可依資源內容篩選原則。 支援速記語法、json-file 和 yaml-file。 請嘗試 “??” 以顯示更多。
| 屬性 | 值 |
|---|---|
| 參數群組: | Properties Arguments |
原則指派的範圍。
指定要設定的屬性路徑和值,以更新物件。 範例:--set property1.property2=<value>。
| 屬性 | 值 |
|---|---|
| 參數群組: | Generic Update Arguments |
全域參數
提高日誌詳細程度以顯示所有調試日誌。
| 屬性 | 值 |
|---|---|
| 預設值: | False |
顯示此說明訊息並結束。
只顯示錯誤,隱藏警告。
| 屬性 | 值 |
|---|---|
| 預設值: | False |
輸出格式。
| 屬性 | 值 |
|---|---|
| 預設值: | json |
| 接受的值: | json, jsonc, none, table, tsv, yaml, yamlc |
JMESPath 查詢字串。 如需詳細資訊和範例,請參閱 http://jmespath.org/。
訂用帳戶的名稱或標識碼。 您可以使用 az account set -s NAME_OR_ID來設定預設訂用帳戶。
增加記錄的詳細程度。 針對完整偵錯記錄使用 --debug。
| 屬性 | 值 |
|---|---|
| 預設值: | False |