Policy Definitions - Create Or Update
이 작업은 주어진 구독 내에서 해당 이름으로 정책 정의를 생성하거나 업데이트합니다.
PUT https://management.azure.com/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}?api-version=2025-11-01
URI 매개 변수
| Name | In(다음 안에) | 필수 | 형식 | Description |
|---|---|---|---|---|
|
policy
|
path | True |
string pattern: ^[^<>*%&:\?.+/]*[^<>*%&:\?.+/ ]+$ |
가져올 정책 정의의 이름입니다. |
|
subscription
|
path | True |
string (uuid) |
대상 구독의 ID입니다. 값은 UUID여야 합니다. |
|
api-version
|
query | True |
string minLength: 1 |
이 작업에 사용할 API 버전입니다. |
요청 본문
| Name | 형식 | Description |
|---|---|---|
| properties.description |
string |
정책 정의 설명입니다. |
| properties.displayName |
string |
정책 정의의 표시 이름입니다. |
| properties.externalEvaluationEnforcementSettings |
적용 평가 중에 정책에 필요한 외부 평가 결과의 원본에 대한 세부 정보입니다. |
|
| properties.metadata |
정책 정의 메타데이터입니다. 메타데이터는 열려 있는 종료된 개체이며 일반적으로 키 값 쌍의 컬렉션입니다. |
|
| properties.mode |
string |
정책 정의 모드입니다. 일부 예는 All, Indexed, Microsoft.KeyVault.Data입니다. |
| properties.parameters |
<string,
Parameter |
정책 규칙에 사용되는 매개 변수에 대한 매개 변수 정의입니다. 키는 매개 변수 이름입니다. |
| properties.policyRule |
정책 규칙입니다. |
|
| properties.policyType |
정책 정의의 형식입니다. 가능한 값은 NotSpecified, BuiltIn, Custom 및 Static입니다. |
|
| properties.version |
string |
#.#.# 형식의 정책 정의 버전입니다. |
| properties.versions |
string[] |
이 정책 정의에 사용할 수 있는 버전 목록입니다. |
응답
| Name | 형식 | Description |
|---|---|---|
| 201 Created |
리소스 'PolicyDefinition' create 작업 성공 |
|
| Other Status Codes |
예기치 않은 오류 응답입니다. |
보안
azure_auth
Azure Active Directory OAuth2 Flow.
형식:
oauth2
Flow:
implicit
권한 부여 URL:
https://login.microsoftonline.com/common/oauth2/authorize
범위
| Name | Description |
|---|---|
| user_impersonation | 사용자 계정 가장 |
예제
| Create or update a policy definition |
| Create or update a policy definition with advanced parameters |
| Create or update a policy definition with external evaluation enforcement settings |
Create or update a policy definition
샘플 요청
PUT https://management.azure.com/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming?api-version=2025-11-01
{
"properties": {
"description": "Force resource names to begin with given 'prefix' and/or end with given 'suffix'",
"displayName": "Enforce resource naming convention",
"metadata": {
"category": "Naming"
},
"mode": "All",
"parameters": {
"prefix": {
"type": "String",
"metadata": {
"description": "Resource name prefix",
"displayName": "Prefix"
}
},
"suffix": {
"type": "String",
"metadata": {
"description": "Resource name suffix",
"displayName": "Suffix"
}
}
},
"policyRule": {
"if": {
"not": {
"field": "name",
"like": "[concat(parameters('prefix'), '*', parameters('suffix'))]"
}
},
"then": {
"effect": "deny"
}
}
}
}
샘플 응답
{
"name": "ResourceNaming",
"type": "Microsoft.Authorization/policyDefinitions",
"id": "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming",
"properties": {
"description": "Force resource names to begin with 'prefix' and end with 'suffix'",
"displayName": "Naming Convention",
"metadata": {
"category": "Naming"
},
"mode": "All",
"parameters": {
"prefix": {
"type": "String",
"metadata": {
"description": "Resource name prefix",
"displayName": "Prefix"
}
},
"suffix": {
"type": "String",
"metadata": {
"description": "Resource name suffix",
"displayName": "Suffix"
}
}
},
"policyRule": {
"if": {
"not": {
"field": "name",
"like": "[concat(parameters('prefix'), '*', parameters('suffix'))]"
}
},
"then": {
"effect": "deny"
}
},
"policyType": "Custom",
"version": "1.2.1",
"versions": [
"1.2.1",
"1.0.0"
]
}
}
Create or update a policy definition with advanced parameters
샘플 요청
PUT https://management.azure.com/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/EventHubDiagnosticLogs?api-version=2025-11-01
{
"properties": {
"description": "Audit enabling of logs and retain them up to a year. This enables recreation of activity trails for investigation purposes when a security incident occurs or your network is compromised",
"displayName": "Event Hubs should have diagnostic logging enabled",
"metadata": {
"category": "Event Hub"
},
"mode": "Indexed",
"parameters": {
"requiredRetentionDays": {
"type": "Integer",
"allowedValues": [
0,
30,
90,
180,
365
],
"defaultValue": 365,
"metadata": {
"description": "The required diagnostic logs retention in days",
"displayName": "Required retention (days)"
}
}
},
"policyRule": {
"if": {
"equals": "Microsoft.EventHub/namespaces",
"field": "type"
},
"then": {
"effect": "AuditIfNotExists",
"details": {
"type": "Microsoft.Insights/diagnosticSettings",
"existenceCondition": {
"allOf": [
{
"equals": "true",
"field": "Microsoft.Insights/diagnosticSettings/logs[*].retentionPolicy.enabled"
},
{
"equals": "[parameters('requiredRetentionDays')]",
"field": "Microsoft.Insights/diagnosticSettings/logs[*].retentionPolicy.days"
}
]
}
}
}
}
}
}
샘플 응답
{
"name": "ResourceNaming",
"type": "Microsoft.Authorization/policyDefinitions",
"id": "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming",
"properties": {
"description": "Audit enabling of logs and retain them up to a year. This enables recreation of activity trails for investigation purposes when a security incident occurs or your network is compromised",
"displayName": "Event Hubs should have diagnostic logging enabled",
"metadata": {
"category": "Event Hub"
},
"mode": "Indexed",
"parameters": {
"requiredRetentionDays": {
"type": "Integer",
"allowedValues": [
0,
30,
90,
180,
365
],
"defaultValue": 365,
"metadata": {
"description": "The required diagnostic logs retention in days",
"displayName": "Required retention (days)"
}
}
},
"policyRule": {
"if": {
"equals": "Microsoft.EventHub/namespaces",
"field": "type"
},
"then": {
"effect": "AuditIfNotExists",
"details": {
"type": "Microsoft.Insights/diagnosticSettings",
"existenceCondition": {
"allOf": [
{
"equals": "true",
"field": "Microsoft.Insights/diagnosticSettings/logs[*].retentionPolicy.enabled"
},
{
"equals": "[parameters('requiredRetentionDays')]",
"field": "Microsoft.Insights/diagnosticSettings/logs[*].retentionPolicy.days"
}
]
}
}
}
},
"version": "1.2.1",
"versions": [
"1.2.1",
"1.0.0"
]
}
}
Create or update a policy definition with external evaluation enforcement settings
샘플 요청
PUT https://management.azure.com/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/RandomizeVMAllocation?api-version=2025-11-01
{
"properties": {
"description": "Randomly disable VM allocation in eastus by having policy rule reference the outcome of invoking an external endpoint using the CoinFlip endpoint that returns random values.",
"displayName": "Randomize VM Allocation",
"externalEvaluationEnforcementSettings": {
"endpointSettings": {
"kind": "CoinFlip",
"details": {
"successProbability": 0.5
}
},
"missingTokenAction": "audit",
"roleDefinitionIds": [
"subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/roleDefinitions/f0cc2aea-b517-48f6-8f9e-0c01c687907b"
]
},
"metadata": {
"category": "VM"
},
"mode": "Indexed",
"policyRule": {
"if": {
"allOf": [
{
"equals": "Microsoft.Compute/virtualMachines",
"field": "type"
},
{
"equals": "eastus",
"field": "location"
},
{
"equals": "false",
"value": "[claims().isValid]"
}
]
},
"then": {
"effect": "deny"
}
}
}
}
샘플 응답
{
"name": "RandomizeVMAllocation",
"type": "Microsoft.Authorization/policyDefinitions",
"id": "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/RandomizeVMAllocation",
"properties": {
"description": "Randomly disable VM allocation in eastus by having policy rule reference the outcome of invoking an external endpoint using the CoinFlip endpoint that returns random values.",
"displayName": "Randomize VM Allocation",
"externalEvaluationEnforcementSettings": {
"endpointSettings": {
"kind": "CoinFlip",
"details": {
"successProbability": 0.5
}
},
"missingTokenAction": "audit",
"roleDefinitionIds": [
"subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/roleDefinitions/f0cc2aea-b517-48f6-8f9e-0c01c687907b"
]
},
"metadata": {
"category": "VM"
},
"mode": "Indexed",
"policyRule": {
"if": {
"allOf": [
{
"equals": "Microsoft.Compute/virtualMachines",
"field": "type"
},
{
"equals": "eastus",
"field": "location"
},
{
"equals": "false",
"value": "[claims().isValid]"
}
]
},
"then": {
"effect": "deny"
}
},
"policyType": "Custom",
"version": "1.2.1",
"versions": [
"1.2.1",
"1.0.0"
]
}
}
정의
| Name | Description |
|---|---|
|
created |
리소스를 만든 ID의 형식입니다. |
|
Error |
리소스 관리 오류 추가 정보입니다. |
|
Error |
오류 세부 정보입니다. |
|
Error |
오류 응답 |
|
External |
평가 결과를 제공하는 외부 엔드포인트의 설정입니다. |
|
External |
적용 평가 중에 정책에 필요한 외부 평가 결과의 원본에 대한 세부 정보입니다. |
|
Parameter |
정책에 제공할 수 있는 매개변수의 정의. |
|
Parameter |
매개 변수에 대한 일반 메타데이터입니다. |
|
Parameter |
매개 변수의 데이터 형식입니다. |
|
Policy |
정책 정의. |
|
Policy |
정책 정의의 형식입니다. 가능한 값은 NotSpecified, BuiltIn, Custom 및 Static입니다. |
|
system |
리소스의 생성 및 마지막 수정과 관련된 메타데이터입니다. |
createdByType
리소스를 만든 ID의 형식입니다.
| 값 | Description |
|---|---|
| User | |
| Application | |
| ManagedIdentity | |
| Key |
ErrorAdditionalInfo
리소스 관리 오류 추가 정보입니다.
| Name | 형식 | Description |
|---|---|---|
| info |
object |
추가 정보입니다. |
| type |
string |
추가 정보 유형입니다. |
ErrorDetail
오류 세부 정보입니다.
| Name | 형식 | Description |
|---|---|---|
| additionalInfo |
오류 추가 정보입니다. |
|
| code |
string |
오류 코드입니다. |
| details |
오류 세부 정보입니다. |
|
| message |
string |
오류 메시지입니다. |
| target |
string |
오류 대상입니다. |
ErrorResponse
오류 응답
| Name | 형식 | Description |
|---|---|---|
| error |
오류 개체입니다. |
ExternalEvaluationEndpointSettings
평가 결과를 제공하는 외부 엔드포인트의 설정입니다.
| Name | 형식 | Description |
|---|---|---|
| details |
엔드포인트의 세부 정보입니다. |
|
| kind |
string |
엔드포인트의 종류입니다. |
ExternalEvaluationEnforcementSettings
적용 평가 중에 정책에 필요한 외부 평가 결과의 원본에 대한 세부 정보입니다.
| Name | 형식 | Description |
|---|---|---|
| endpointSettings |
평가 결과를 제공하는 외부 엔드포인트의 설정입니다. |
|
| missingTokenAction |
string |
외부 평가가 필요하고 토큰이 누락된 적용 정책을 평가할 때 수행할 일입니다. 가능한 값은 Audit 및 Deny이며 언어 식이 지원됩니다. |
| resultLifespan |
string |
엔드포인트 호출 결과의 수명은 더 이상 유효하지 않습니다. 값은 ISO 8601 기간 형식을 따라야 하며 언어 식이 지원됩니다. |
| roleDefinitionIds |
string[] |
엔드포인트를 호출하기 위해 할당의 MSI에 필요한 역할 정의 ID의 배열입니다. |
ParameterDefinitionsValue
정책에 제공할 수 있는 매개변수의 정의.
| Name | 형식 | Description |
|---|---|---|
| allowedValues |
Allowed |
매개 변수에 허용되는 값입니다. |
| defaultValue |
값이 제공되지 않은 경우 매개 변수의 기본값입니다. |
|
| metadata |
매개 변수에 대한 일반 메타데이터입니다. |
|
| schema |
자체 정의 JSON 스키마를 사용하여 할당하는 동안 매개 변수 입력의 유효성을 검사합니다. 이 속성은 객체 타입 매개변수에만 지원되며, Json.NET 스키마 2019-09 구현을 따릅니다. 스키마 사용법은 https://json-schema.org/에서, 초안 스키마는 https://www.jsonschemavalidator.net/에서 테스트할 수 있습니다. |
|
| type |
매개 변수의 데이터 형식입니다. |
ParameterDefinitionsValueMetadata
매개 변수에 대한 일반 메타데이터입니다.
| Name | 형식 | Description |
|---|---|---|
| assignPermissions |
boolean |
정책 할당 중 이 매개변수의 자원 ID 또는 자원 범위 값에 대해 Azure 포털이 역할 할당을 생성하도록 true로 설정하세요. 이 속성은 할당 범위 외부에서 권한을 할당하려는 경우에 유용합니다. |
| description |
string |
매개 변수에 대한 설명입니다. |
| displayName |
string |
매개 변수의 표시 이름입니다. |
| strongType |
string |
포털을 통해 정책 정의를 할당할 때 사용됩니다. 사용자가 선택할 수 있는 값의 컨텍스트 인식 목록을 제공합니다. |
ParameterType
매개 변수의 데이터 형식입니다.
| 값 | Description |
|---|---|
| String |
문자열 매개변수 타입. |
| Array |
배열 매개변수 타입. |
| Object |
객체 매개변수 타입. |
| Boolean |
불리언 매개변수 타입. |
| Integer |
정수 매개변수 유형입니다. |
| Float |
float 매개변수 유형입니다. |
| DateTime |
날짜-시간 매개변수 유형입니다. |
PolicyDefinition
정책 정의.
| Name | 형식 | Default value | Description |
|---|---|---|---|
| id |
string (arm-id) |
리소스에 대한 정규화된 리소스 ID입니다. 예: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" |
|
| name |
string |
리소스의 이름 |
|
| properties.description |
string |
정책 정의 설명입니다. |
|
| properties.displayName |
string |
정책 정의의 표시 이름입니다. |
|
| properties.externalEvaluationEnforcementSettings |
적용 평가 중에 정책에 필요한 외부 평가 결과의 원본에 대한 세부 정보입니다. |
||
| properties.metadata |
정책 정의 메타데이터입니다. 메타데이터는 열려 있는 종료된 개체이며 일반적으로 키 값 쌍의 컬렉션입니다. |
||
| properties.mode |
string |
Indexed |
정책 정의 모드입니다. 일부 예는 All, Indexed, Microsoft.KeyVault.Data입니다. |
| properties.parameters |
<string,
Parameter |
정책 규칙에 사용되는 매개 변수에 대한 매개 변수 정의입니다. 키는 매개 변수 이름입니다. |
|
| properties.policyRule |
정책 규칙입니다. |
||
| properties.policyType |
정책 정의의 형식입니다. 가능한 값은 NotSpecified, BuiltIn, Custom 및 Static입니다. |
||
| properties.version |
string |
#.#.# 형식의 정책 정의 버전입니다. |
|
| properties.versions |
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
리소스의 생성 및 마지막 수정과 관련된 메타데이터입니다.
| Name | 형식 | Description |
|---|---|---|
| createdAt |
string (date-time) |
리소스 만들기의 타임스탬프(UTC)입니다. |
| createdBy |
string |
리소스를 만든 ID입니다. |
| createdByType |
리소스를 만든 ID의 형식입니다. |
|
| lastModifiedAt |
string (date-time) |
리소스 마지막 수정의 타임스탬프(UTC) |
| lastModifiedBy |
string |
리소스를 마지막으로 수정한 ID입니다. |
| lastModifiedByType |
리소스를 마지막으로 수정한 ID의 형식입니다. |