Policy Set Definition Versions - Create Or Update
此操作會在給定訂閱中建立或更新一個包含名稱與版本的政策集定義版本。
PUT https://management.azure.com/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}/versions/{policyDefinitionVersion}?api-version=2025-11-01
URI 參數
| 名稱 | 位於 | 必要 | 類型 | Description |
|---|---|---|---|---|
|
policy
|
path | True |
string pattern: ^\d+\.\d+\.\d+$ |
原則集定義版本。 格式為 x.y.z,其中 x 是主要版本號,y 是次要版本號,z 是補丁號 |
|
policy
|
path | True |
string pattern: ^[^<>*%&:\?.+/]*[^<>*%&:\?.+/ ]+$ |
原則集定義的名稱。 |
|
subscription
|
path | True |
string (uuid) |
目標訂用帳戶的標識碼。 此值必須是 UUID。 |
|
api-version
|
query | True |
string minLength: 1 |
用於此作業的 API 版本。 |
要求本文
| 名稱 | 必要 | 類型 | Description |
|---|---|---|---|
| properties.policyDefinitions | True |
原則定義參考的陣列。 |
|
| properties.description |
string |
原則集定義描述。 |
|
| properties.displayName |
string |
原則集定義的顯示名稱。 |
|
| properties.metadata |
原則集定義元數據。 元數據是開放式物件,通常是索引鍵值組的集合。 |
||
| properties.parameters |
<string,
Parameter |
原則集定義參數,可用於原則定義參考。 |
|
| properties.policyDefinitionGroups |
元數據,描述原則集定義內的原則定義參考群組。 |
||
| properties.policyType |
原則定義的類型。 可能的值為 NotSpecified、BuiltIn、Custom 和 Static。 |
||
| properties.version |
string |
原則會以 #.#.# 格式設定定義版本。 |
回應
| 名稱 | 類型 | Description |
|---|---|---|
| 200 OK |
資源「PolicySetDefinitionVersion」更新操作成功 |
|
| 201 Created |
資源「PolicySetDefinitionVersion」創建操作成功 |
|
| Other Status Codes |
未預期的錯誤回應。 |
安全性
azure_auth
Azure Active Directory OAuth2 Flow.
類型:
oauth2
Flow:
implicit
授權 URL:
https://login.microsoftonline.com/common/oauth2/authorize
範圍
| 名稱 | Description |
|---|---|
| user_impersonation | 模擬您的用戶帳戶 |
範例
Create or update a policy set definition version
範例要求
PUT https://management.azure.com/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policySetDefinitions/CostManagement/versions/1.2.1?api-version=2025-11-01
{
"properties": {
"description": "Policies to enforce low cost storage SKUs",
"displayName": "Cost Management",
"metadata": {
"category": "Cost Management"
},
"parameters": {
"namePrefix": {
"type": "String",
"defaultValue": "myPrefix",
"metadata": {
"displayName": "Prefix to enforce on resource names"
}
}
},
"policyDefinitions": [
{
"parameters": {
"listOfAllowedSKUs": {
"value": [
"Standard_GRS",
"Standard_LRS"
]
}
},
"policyDefinitionId": "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1",
"policyDefinitionReferenceId": "Limit_Skus"
},
{
"parameters": {
"prefix": {
"value": "[parameters('namePrefix')]"
},
"suffix": {
"value": "-LC"
}
},
"policyDefinitionId": "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming",
"policyDefinitionReferenceId": "Resource_Naming"
}
],
"version": "1.2.1"
}
}
範例回覆
{
"name": "1.2.1",
"type": "Microsoft.Authorization/policySetDefinitions/versions",
"id": "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policySetDefinitions/CostManagement/versions/1.2.1",
"properties": {
"description": "Policies to enforce low cost storage SKUs",
"displayName": "Cost Management",
"metadata": {
"category": "Cost Management"
},
"parameters": {
"namePrefix": {
"type": "String",
"defaultValue": "myPrefix",
"metadata": {
"displayName": "Prefix to enforce on resource names"
}
}
},
"policyDefinitions": [
{
"definitionVersion": "1.*.*",
"parameters": {
"listOfAllowedSKUs": {
"value": [
"Standard_GRS",
"Standard_LRS"
]
}
},
"policyDefinitionId": "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1",
"policyDefinitionReferenceId": "Limit_Skus"
},
{
"definitionVersion": "1.*.*",
"parameters": {
"prefix": {
"value": "[parameters('namePrefix')]"
},
"suffix": {
"value": "-LC"
}
},
"policyDefinitionId": "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming",
"policyDefinitionReferenceId": "Resource_Naming"
}
],
"version": "1.2.1"
}
}
{
"name": "1.2.1",
"type": "Microsoft.Authorization/policySetDefinitions/versions",
"id": "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policySetDefinitions/CostManagement/versions/1.2.1",
"properties": {
"description": "Policies to enforce low cost storage SKUs",
"displayName": "Cost Management",
"metadata": {
"category": "Cost Management"
},
"parameters": {
"namePrefix": {
"type": "String",
"defaultValue": "myPrefix",
"metadata": {
"displayName": "Prefix to enforce on resource names"
}
}
},
"policyDefinitions": [
{
"definitionVersion": "1.*.*",
"parameters": {
"listOfAllowedSKUs": {
"value": [
"Standard_GRS",
"Standard_LRS"
]
}
},
"policyDefinitionId": "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1",
"policyDefinitionReferenceId": "Limit_Skus"
},
{
"definitionVersion": "1.*.*",
"parameters": {
"prefix": {
"value": "[parameters('namePrefix')]"
},
"suffix": {
"value": "-LC"
}
},
"policyDefinitionId": "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming",
"policyDefinitionReferenceId": "Resource_Naming"
}
],
"version": "1.2.1"
}
}
定義
| 名稱 | Description |
|---|---|
|
created |
建立資源的身分識別類型。 |
|
Error |
資源管理錯誤其他資訊。 |
|
Error |
錯誤詳細數據。 |
|
Error |
錯誤回應 |
|
Parameter |
定義一個參數,可以提供給政策。 |
|
Parameter |
參數的一般元數據。 |
|
Parameter |
參數的數據類型。 |
|
Parameter |
參數的值。 |
|
Policy |
政策定義小組。 |
|
Policy |
保單定義參考。 |
|
Policy |
原則集定義版本。 |
|
Policy |
原則定義的類型。 可能的值為 NotSpecified、BuiltIn、Custom 和 Static。 |
|
system |
與建立和上次修改資源相關的元數據。 |
createdByType
建立資源的身分識別類型。
| 值 | Description |
|---|---|
| User | |
| Application | |
| ManagedIdentity | |
| Key |
ErrorAdditionalInfo
資源管理錯誤其他資訊。
| 名稱 | 類型 | Description |
|---|---|---|
| info |
object |
其他資訊。 |
| type |
string |
其他信息類型。 |
ErrorDetail
錯誤詳細數據。
| 名稱 | 類型 | Description |
|---|---|---|
| additionalInfo |
錯誤其他資訊。 |
|
| code |
string |
錯誤碼。 |
| details |
錯誤詳情 |
|
| message |
string |
錯誤訊息。 |
| target |
string |
錯誤目標。 |
ErrorResponse
錯誤回應
| 名稱 | 類型 | Description |
|---|---|---|
| error |
error 物件。 |
ParameterDefinitionsValue
定義一個參數,可以提供給政策。
| 名稱 | 類型 | Description |
|---|---|---|
| allowedValues |
Allowed |
參數的允許值。 |
| defaultValue |
如果未提供任何值,則為 參數的預設值。 |
|
| metadata |
參數的一般元數據。 |
|
| schema |
使用自我定義 JSON 架構,在指派期間提供參數輸入的驗證。 此屬性僅支援物件型態參數,並遵循 Json.NET Schema 2019-09 實作。 你可以在 https://json-schema.org/ 學習如何使用 schema,並在 https://www.jsonschemavalidator.net/ 測試草稿 schema。 |
|
| type |
參數的數據類型。 |
ParameterDefinitionsValueMetadata
參數的一般元數據。
| 名稱 | 類型 | Description |
|---|---|---|
| assignPermissions |
boolean |
設定為 true,讓 Azure 入口在政策指派時,根據該參數的資源 ID 或資源範圍值建立角色指派。 如果您想要在指派範圍之外指派許可權,這個屬性就很有用。 |
| description |
string |
參數的描述。 |
| displayName |
string |
參數的顯示名稱。 |
| strongType |
string |
透過入口網站指派原則定義時使用。 提供內容感知值清單,供用戶選擇。 |
ParameterType
參數的數據類型。
| 值 | Description |
|---|---|
| String |
字串參數型別。 |
| Array |
陣列參數類型。 |
| Object |
物件參數類型。 |
| Boolean |
布林參數型態。 |
| Integer |
整數參數類型。 |
| Float |
浮點參數類型。 |
| DateTime |
日期-時間參數型態。 |
ParameterValuesValue
參數的值。
| 名稱 | 類型 | Description |
|---|---|---|
| value |
參數的值。 |
PolicyDefinitionGroup
政策定義小組。
| 名稱 | 類型 | Description |
|---|---|---|
| additionalMetadataId |
string |
資源的資源標識碼,其中包含群組的其他元數據。 |
| category |
string |
群組的類別。 |
| description |
string |
群組的描述。 |
| displayName |
string |
群組的顯示名稱。 |
| name |
string |
群組的名稱。 |
PolicyDefinitionReference
保單定義參考。
| 名稱 | 類型 | Description |
|---|---|---|
| definitionVersion |
string |
要使用的原則定義版本。 |
| effectiveDefinitionVersion |
string |
目前使用的政策定義的有效版本。 只有在透過 $expand 查詢參數請求時才會存在。 |
| groupNames |
string[] |
此原則定義參考所屬的組名。 |
| latestDefinitionVersion |
string |
最新版本的保單定義可供參考。 只有在透過 $expand 查詢參數請求時才會存在。 |
| parameters |
<string,
Parameter |
參考原則規則的參數值。 索引鍵是參數名稱。 |
| policyDefinitionId |
string |
原則定義或原則集定義的標識碼。 |
| policyDefinitionReferenceId |
string |
此原則定義參考的唯一標識碼(在原則集定義內)。 |
PolicySetDefinitionVersion
原則集定義版本。
| 名稱 | 類型 | Description |
|---|---|---|
| id |
string (arm-id) |
資源的完整資源標識碼。 例如 “/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}” |
| name |
string |
資源的名稱 |
| properties.description |
string |
原則集定義描述。 |
| properties.displayName |
string |
原則集定義的顯示名稱。 |
| properties.metadata |
原則集定義元數據。 元數據是開放式物件,通常是索引鍵值組的集合。 |
|
| properties.parameters |
<string,
Parameter |
原則集定義參數,可用於原則定義參考。 |
| properties.policyDefinitionGroups |
元數據,描述原則集定義內的原則定義參考群組。 |
|
| properties.policyDefinitions |
原則定義參考的陣列。 |
|
| properties.policyType |
原則定義的類型。 可能的值為 NotSpecified、BuiltIn、Custom 和 Static。 |
|
| properties.version |
string |
原則會以 #.#.# 格式設定定義版本。 |
| systemData |
Azure Resource Manager 包含 createdBy 與 modifiedBy 資訊的元資料。 |
|
| type |
string |
資源的類型。 例如“Microsoft.Compute/virtualMachines” 或 “Microsoft.Storage/storageAccounts” |
PolicyType
原則定義的類型。 可能的值為 NotSpecified、BuiltIn、Custom 和 Static。
| 值 | Description |
|---|---|
| NotSpecified |
未指定的政策定義類型。 |
| BuiltIn |
內建的政策定義類型。 |
| Custom |
自訂政策定義類型。 |
| Static |
靜態政策定義類型。 |
systemData
與建立和上次修改資源相關的元數據。
| 名稱 | 類型 | Description |
|---|---|---|
| createdAt |
string (date-time) |
資源建立的時間戳(UTC)。 |
| createdBy |
string |
建立資源的身分識別。 |
| createdByType |
建立資源的身分識別類型。 |
|
| lastModifiedAt |
string (date-time) |
上次修改的資源時間戳 (UTC) |
| lastModifiedBy |
string |
上次修改資源的身分識別。 |
| lastModifiedByType |
上次修改資源的身分識別類型。 |