Policy Definitions - Create Or Update
サブスクリプション内のポリシー定義を作成または更新します。
この操作により、指定されたサブスクリプション内のポリシー定義が、指定された名前で作成または更新されます。
PUT https://management.azure.com/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}?api-version=2023-04-01
URI パラメーター
| 名前 | / | 必須 | 型 | 説明 |
|---|---|---|---|---|
|
policy
|
path | True |
string pattern: ^[^<>*%&:\?.+/]*[^<>*%&:\?.+/ ]+$ |
作成するポリシー定義の名前。 |
|
subscription
|
path | True |
string (uuid) |
ターゲット サブスクリプションの ID。 値は UUID である必要があります。 |
|
api-version
|
query | True |
string minLength: 1 |
この操作に使用する API バージョン。 |
要求本文
| 名前 | 型 | 説明 |
|---|---|---|
| properties.description |
string |
ポリシー定義の説明。 |
| properties.displayName |
string |
ポリシー定義の表示名。 |
| properties.metadata |
object |
ポリシー定義メタデータ。 メタデータはオープン エンド オブジェクトであり、通常はキーと値のペアのコレクションです。 |
| properties.mode |
string |
ポリシー定義モード。 たとえば、All、Indexed、Microsoft.KeyVault.Data などです。 |
| properties.parameters |
<string,
Parameter |
ポリシー規則で使用されるパラメーターのパラメーター定義。 キーはパラメーター名です。 |
| properties.policyRule |
object |
ポリシー ルール。 |
| properties.policyType |
ポリシー定義の種類。 指定できる値は、NotSpecified、BuiltIn、Custom、Static です。 |
|
| properties.version |
string |
#.#.# 形式のポリシー定義のバージョン。 |
| properties.versions |
string[] |
このポリシー定義で使用可能なバージョンの一覧。 |
応答
| 名前 | 型 | 説明 |
|---|---|---|
| 201 Created |
Created - ポリシー定義に関する情報を返します。 |
|
| Other Status Codes |
操作が失敗した理由を説明するエラー応答。 |
セキュリティ
azure_auth
Azure Active Directory OAuth2 フロー。
型:
oauth2
フロー:
implicit
Authorization URL (承認 URL):
https://login.microsoftonline.com/common/oauth2/authorize
スコープ
| 名前 | 説明 |
|---|---|
| user_impersonation | ユーザー アカウントを偽装する |
例
| Create or update a policy definition |
| Create or update a policy definition with advanced parameters |
Create or update a policy definition
要求のサンプル
PUT https://management.azure.com/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming?api-version=2023-04-01
{
"properties": {
"mode": "All",
"displayName": "Enforce resource naming convention",
"description": "Force resource names to begin with given 'prefix' and/or end with given 'suffix'",
"metadata": {
"category": "Naming"
},
"policyRule": {
"if": {
"not": {
"field": "name",
"like": "[concat(parameters('prefix'), '*', parameters('suffix'))]"
}
},
"then": {
"effect": "deny"
}
},
"parameters": {
"prefix": {
"type": "String",
"metadata": {
"displayName": "Prefix",
"description": "Resource name prefix"
}
},
"suffix": {
"type": "String",
"metadata": {
"displayName": "Suffix",
"description": "Resource name suffix"
}
}
}
}
}
応答のサンプル
{
"id": "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming",
"type": "Microsoft.Authorization/policyDefinitions",
"name": "ResourceNaming",
"properties": {
"mode": "All",
"displayName": "Naming Convention",
"description": "Force resource names to begin with 'prefix' and end with 'suffix'",
"metadata": {
"category": "Naming"
},
"version": "1.2.1",
"versions": [
"1.2.1",
"1.0.0"
],
"policyRule": {
"if": {
"not": {
"field": "name",
"like": "[concat(parameters('prefix'), '*', parameters('suffix'))]"
}
},
"then": {
"effect": "deny"
}
},
"parameters": {
"prefix": {
"type": "String",
"metadata": {
"displayName": "Prefix",
"description": "Resource name prefix"
}
},
"suffix": {
"type": "String",
"metadata": {
"displayName": "Suffix",
"description": "Resource name suffix"
}
}
},
"policyType": "Custom"
}
}
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=2023-04-01
{
"properties": {
"mode": "Indexed",
"displayName": "Event Hubs should have diagnostic logging enabled",
"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",
"metadata": {
"category": "Event Hub"
},
"policyRule": {
"if": {
"field": "type",
"equals": "Microsoft.EventHub/namespaces"
},
"then": {
"effect": "AuditIfNotExists",
"details": {
"type": "Microsoft.Insights/diagnosticSettings",
"existenceCondition": {
"allOf": [
{
"field": "Microsoft.Insights/diagnosticSettings/logs[*].retentionPolicy.enabled",
"equals": "true"
},
{
"field": "Microsoft.Insights/diagnosticSettings/logs[*].retentionPolicy.days",
"equals": "[parameters('requiredRetentionDays')]"
}
]
}
}
}
},
"parameters": {
"requiredRetentionDays": {
"type": "Integer",
"defaultValue": 365,
"allowedValues": [
0,
30,
90,
180,
365
],
"metadata": {
"displayName": "Required retention (days)",
"description": "The required diagnostic logs retention in days"
}
}
}
}
}
応答のサンプル
{
"id": "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming",
"type": "Microsoft.Authorization/policyDefinitions",
"name": "ResourceNaming",
"properties": {
"mode": "Indexed",
"displayName": "Event Hubs should have diagnostic logging enabled",
"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",
"metadata": {
"category": "Event Hub"
},
"version": "1.2.1",
"versions": [
"1.2.1",
"1.0.0"
],
"policyRule": {
"if": {
"field": "type",
"equals": "Microsoft.EventHub/namespaces"
},
"then": {
"effect": "AuditIfNotExists",
"details": {
"type": "Microsoft.Insights/diagnosticSettings",
"existenceCondition": {
"allOf": [
{
"field": "Microsoft.Insights/diagnosticSettings/logs[*].retentionPolicy.enabled",
"equals": "true"
},
{
"field": "Microsoft.Insights/diagnosticSettings/logs[*].retentionPolicy.days",
"equals": "[parameters('requiredRetentionDays')]"
}
]
}
}
}
},
"parameters": {
"requiredRetentionDays": {
"type": "Integer",
"defaultValue": 365,
"allowedValues": [
0,
30,
90,
180,
365
],
"metadata": {
"displayName": "Required retention (days)",
"description": "The required diagnostic logs retention in days"
}
}
}
}
}
定義
| 名前 | 説明 |
|---|---|
|
Cloud |
ポリシー操作からのエラー応答。 |
|
created |
リソースを作成した ID の種類。 |
|
Error |
リソース管理エラーの追加情報。 |
|
Error |
エラー応答 |
| Metadata |
パラメーターの一般的なメタデータ。 |
|
Parameter |
ポリシーに指定できるパラメーターの定義。 |
|
parameter |
パラメーターのデータ型。 |
|
Policy |
ポリシー定義。 |
|
policy |
ポリシー定義の種類。 指定できる値は、NotSpecified、BuiltIn、Custom、Static です。 |
|
system |
リソースの作成と最後の変更に関連するメタデータ。 |
CloudError
ポリシー操作からのエラー応答。
| 名前 | 型 | 説明 |
|---|---|---|
| error |
エラー応答 |
createdByType
リソースを作成した ID の種類。
| 値 | 説明 |
|---|---|
| User | |
| Application | |
| ManagedIdentity | |
| Key |
ErrorAdditionalInfo
リソース管理エラーの追加情報。
| 名前 | 型 | 説明 |
|---|---|---|
| info |
object |
追加情報。 |
| type |
string |
追加情報の種類。 |
ErrorResponse
エラー応答
| 名前 | 型 | 説明 |
|---|---|---|
| additionalInfo |
エラーの追加情報。 |
|
| code |
string |
エラー コード。 |
| details |
エラーの詳細。 |
|
| message |
string |
エラー メッセージ。 |
| target |
string |
エラーターゲット。 |
Metadata
パラメーターの一般的なメタデータ。
| 名前 | 型 | 説明 |
|---|---|---|
| assignPermissions |
boolean |
ポリシーの割り当て中に Azure portal でこのパラメーターのリソース ID またはリソース スコープ値にロールの割り当てを作成するには、true に設定します。 このプロパティは、割り当てスコープ外でアクセス許可を割り当てる場合に便利です。 |
| description |
string |
パラメーターの説明。 |
| displayName |
string |
パラメーターの表示名。 |
| strongType |
string |
ポータルを使用してポリシー定義を割り当てるときに使用されます。 ユーザーが選択する値のコンテキスト対応リストを提供します。 |
ParameterDefinitionsValue
ポリシーに指定できるパラメーターの定義。
| 名前 | 型 | 説明 |
|---|---|---|
| allowedValues |
object[] |
パラメーターに使用できる値。 |
| defaultValue |
object |
値が指定されていない場合のパラメーターの既定値。 |
| metadata |
パラメーターの一般的なメタデータ。 |
|
| schema |
object |
自己定義 JSON スキーマを使用した割り当て時のパラメーター入力の検証を提供します。 このプロパティは、オブジェクト型パラメーターでのみサポートされ、Json.NET Schema 2019-09 の実装に従います。 スキーマの使用の詳細については、「https://json-schema.org/」を参照し、https://www.jsonschemavalidator.net/で下書きスキーマをテストします。 |
| type |
パラメーターのデータ型。 |
parameterType
パラメーターのデータ型。
| 値 | 説明 |
|---|---|
| String | |
| Array | |
| Object | |
| Boolean | |
| Integer | |
| Float | |
| DateTime |
PolicyDefinition
ポリシー定義。
| 名前 | 型 | 規定値 | 説明 |
|---|---|---|---|
| id |
string |
ポリシー定義の ID。 |
|
| name |
string |
ポリシー定義の名前。 |
|
| properties.description |
string |
ポリシー定義の説明。 |
|
| properties.displayName |
string |
ポリシー定義の表示名。 |
|
| properties.metadata |
object |
ポリシー定義メタデータ。 メタデータはオープン エンド オブジェクトであり、通常はキーと値のペアのコレクションです。 |
|
| properties.mode |
string |
Indexed |
ポリシー定義モード。 たとえば、All、Indexed、Microsoft.KeyVault.Data などです。 |
| properties.parameters |
<string,
Parameter |
ポリシー規則で使用されるパラメーターのパラメーター定義。 キーはパラメーター名です。 |
|
| properties.policyRule |
object |
ポリシー ルール。 |
|
| properties.policyType |
ポリシー定義の種類。 指定できる値は、NotSpecified、BuiltIn、Custom、Static です。 |
||
| properties.version |
string |
#.#.# 形式のポリシー定義のバージョン。 |
|
| properties.versions |
string[] |
このポリシー定義で使用可能なバージョンの一覧。 |
|
| systemData |
このリソースに関連するシステム メタデータ。 |
||
| type |
string |
リソースの種類 (Microsoft.Authorization/policyDefinitions)。 |
policyType
ポリシー定義の種類。 指定できる値は、NotSpecified、BuiltIn、Custom、Static です。
| 値 | 説明 |
|---|---|
| NotSpecified | |
| BuiltIn | |
| Custom | |
| Static |
systemData
リソースの作成と最後の変更に関連するメタデータ。
| 名前 | 型 | 説明 |
|---|---|---|
| createdAt |
string (date-time) |
リソース作成のタイムスタンプ (UTC)。 |
| createdBy |
string |
リソースを作成した ID。 |
| createdByType |
リソースを作成した ID の種類。 |
|
| lastModifiedAt |
string (date-time) |
リソースの最終変更のタイムスタンプ (UTC) |
| lastModifiedBy |
string |
リソースを最後に変更した ID。 |
| lastModifiedByType |
リソースを最後に変更した ID の種類。 |