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 参数
| 名称 | 在 | 必需 | 类型 | 说明 |
|---|---|---|---|---|
|
policy
|
path | True |
string pattern: ^\d+\.\d+\.\d+$ |
策略集定义版本。 格式为 x.y.z,其中 x 是主要版本号,y 是次要版本号,z 是补丁号 |
|
policy
|
path | True |
string pattern: ^[^<>*%&:\?.+/]*[^<>*%&:\?.+/ ]+$ |
策略集定义的名称。 |
|
subscription
|
path | True |
string (uuid) |
目标订阅的 ID。 该值必须是 UUID。 |
|
api-version
|
query | True |
string minLength: 1 |
用于此作的 API 版本。 |
请求正文
| 名称 | 必需 | 类型 | 说明 |
|---|---|---|---|
| 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 |
策略以 #.#.# 格式设置定义版本。 |
响应
| 名称 | 类型 | 说明 |
|---|---|---|
| 200 OK |
资源“PolicySetDefinitionVersion”更新作成功 |
|
| 201 Created |
资源“PolicySetDefinitionVersion” 创建作成功 |
|
| Other Status Codes |
意外的错误响应。 |
安全性
azure_auth
Azure Active Directory OAuth2 Flow.
类型:
oauth2
流向:
implicit
授权 URL:
https://login.microsoftonline.com/common/oauth2/authorize
作用域
| 名称 | 说明 |
|---|---|
| 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"
}
}
定义
| 名称 | 说明 |
|---|---|
|
created |
创建资源的标识的类型。 |
|
Error |
资源管理错误附加信息。 |
|
Error |
错误详细信息。 |
|
Error |
错误响应 |
|
Parameter |
定义一个可以为策略提供的参数。 |
|
Parameter |
参数的常规元数据。 |
|
Parameter |
参数的数据类型。 |
|
Parameter |
参数的值。 |
|
Policy |
政策定义组。 |
|
Policy |
政策定义参考。 |
|
Policy |
策略集定义版本。 |
|
Policy |
策略定义的类型。 可能的值为 NotSpecified、BuiltIn、Custom 和 Static。 |
|
system |
与创建和上次修改资源相关的元数据。 |
createdByType
创建资源的标识的类型。
| 值 | 说明 |
|---|---|
| User | |
| Application | |
| ManagedIdentity | |
| Key |
ErrorAdditionalInfo
资源管理错误附加信息。
| 名称 | 类型 | 说明 |
|---|---|---|
| info |
object |
其他信息。 |
| type |
string |
其他信息类型。 |
ErrorDetail
错误详细信息。
| 名称 | 类型 | 说明 |
|---|---|---|
| additionalInfo |
错误附加信息。 |
|
| code |
string |
错误代码。 |
| details |
错误详细信息。 |
|
| message |
string |
错误消息。 |
| target |
string |
错误目标。 |
ErrorResponse
错误响应
| 名称 | 类型 | 说明 |
|---|---|---|
| error |
错误对象。 |
ParameterDefinitionsValue
定义一个可以为策略提供的参数。
| 名称 | 类型 | 说明 |
|---|---|---|
| allowedValues |
Allowed |
参数的允许值。 |
| defaultValue |
如果未提供任何值,则为参数的默认值。 |
|
| metadata |
参数的常规元数据。 |
|
| schema |
使用自定义 JSON 架构在分配期间提供参数输入的验证。 该属性仅支持对象类型参数,并遵循 Json.NET 模式 2019-09 实现。 可以了解更多关于在 https://json-schema.org/ 使用架构和在 https://www.jsonschemavalidator.net/ 测试草稿架构的信息。 |
|
| type |
参数的数据类型。 |
ParameterDefinitionsValueMetadata
参数的常规元数据。
| 名称 | 类型 | 说明 |
|---|---|---|
| assignPermissions |
boolean |
设置为 true,以便 Azure 门户在策略分配时根据该参数的资源 ID 或资源范围值创建角色分配。 如果希望在分配范围之外分配权限,此属性会很有用。 |
| description |
string |
参数的说明。 |
| displayName |
string |
参数的显示名称。 |
| strongType |
string |
通过门户分配策略定义时使用。 提供可供用户选择的值的上下文感知列表。 |
ParameterType
参数的数据类型。
| 值 | 说明 |
|---|---|
| String |
字符串参数类型。 |
| Array |
数组参数类型。 |
| Object |
对象参数类型。 |
| Boolean |
布尔参数类型。 |
| Integer |
整数参数类型。 |
| Float |
浮点参数类型。 |
| DateTime |
日期-时间参数类型。 |
ParameterValuesValue
参数的值。
| 名称 | 类型 | 说明 |
|---|---|---|
| value |
参数的值。 |
PolicyDefinitionGroup
政策定义组。
| 名称 | 类型 | 说明 |
|---|---|---|
| additionalMetadataId |
string |
包含有关组的其他元数据的资源的资源 ID。 |
| category |
string |
组的类别。 |
| description |
string |
组的说明。 |
| displayName |
string |
组的显示名称。 |
| name |
string |
组的名称。 |
PolicyDefinitionReference
政策定义参考。
| 名称 | 类型 | 说明 |
|---|---|---|
| definitionVersion |
string |
要使用的策略定义的版本。 |
| effectiveDefinitionVersion |
string |
所使用的政策定义的有效版本。 只有通过$expand查询参数请求时才会存在。 |
| groupNames |
string[] |
此策略定义引用所属的组的名称。 |
| latestDefinitionVersion |
string |
最新版本的保单定义可供使用。 只有通过$expand查询参数请求时才会存在。 |
| parameters |
<string,
Parameter |
引用的策略规则的参数值。 键是参数名称。 |
| policyDefinitionId |
string |
策略定义或策略集定义的 ID。 |
| policyDefinitionReferenceId |
string |
此策略定义引用的唯一 ID(在策略集定义中)。 |
PolicySetDefinitionVersion
策略集定义版本。
| 名称 | 类型 | 说明 |
|---|---|---|
| id |
string (arm-id) |
资源的完全限定资源 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。
| 值 | 说明 |
|---|---|
| NotSpecified |
未指定策略定义类型。 |
| BuiltIn |
内置的策略定义类型。 |
| Custom |
自定义策略定义类型。 |
| Static |
静态策略定义类型。 |
systemData
与创建和上次修改资源相关的元数据。
| 名称 | 类型 | 说明 |
|---|---|---|
| createdAt |
string (date-time) |
资源创建时间戳(UTC)。 |
| createdBy |
string |
创建资源的标识。 |
| createdByType |
创建资源的标识的类型。 |
|
| lastModifiedAt |
string (date-time) |
上次修改的资源时间戳(UTC) |
| lastModifiedBy |
string |
上次修改资源的标识。 |
| lastModifiedByType |
上次修改资源的标识的类型。 |