Policy Definitions - Create Or Update At Management Group
在管理群組中建立或更新原則定義。
此作業會使用指定的名稱,在指定的管理群組中建立或更新原則定義。
PUT https://management.azure.com/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}?api-version=2023-04-01
URI 參數
名稱 | 位於 | 必要 | 類型 | Description |
---|---|---|---|---|
management
|
path | True |
string |
管理群組的標識碼。 |
policy
|
path | True |
string pattern: ^[^<>*%&:\?.+/]*[^<>*%&:\?.+/ ]+$ |
要建立的原則定義名稱。 |
api-version
|
query | True |
string minLength: 1 |
要用於這項作業的 API 版本。 |
要求本文
名稱 | 類型 | Description |
---|---|---|
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[] |
此原則定義的可用版本清單。 |
回應
名稱 | 類型 | Description |
---|---|---|
201 Created |
建立 - 傳回原則定義的相關信息。 |
|
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 definition at management group level
範例要求
PUT https://management.azure.com/providers/Microsoft.Management/managementGroups/MyManagementGroup/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": "/providers/Microsoft.Management/managementgroups/MyManagementGroup/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"
}
}
定義
名稱 | Description |
---|---|
Cloud |
原則作業的錯誤回應。 |
created |
建立資源的身分識別類型。 |
Error |
資源管理錯誤其他資訊。 |
Error |
錯誤回應 |
Metadata |
參數的一般元數據。 |
Parameter |
可提供給原則的參數定義。 |
parameter |
參數的數據類型。 |
Policy |
原則定義。 |
policy |
原則定義的類型。 可能的值為 NotSpecified、BuiltIn、Custom 和 Static。 |
system |
與建立和上次修改資源相關的元數據。 |
CloudError
原則作業的錯誤回應。
名稱 | 類型 | Description |
---|---|---|
error |
錯誤回應 |
createdByType
建立資源的身分識別類型。
值 | Description |
---|---|
Application | |
Key | |
ManagedIdentity | |
User |
ErrorAdditionalInfo
資源管理錯誤其他資訊。
名稱 | 類型 | Description |
---|---|---|
info |
object |
其他資訊。 |
type |
string |
其他信息類型。 |
ErrorResponse
錯誤回應
名稱 | 類型 | Description |
---|---|---|
additionalInfo |
錯誤其他資訊。 |
|
code |
string |
錯誤碼。 |
details |
錯誤詳細數據。 |
|
message |
string |
錯誤訊息。 |
target |
string |
錯誤目標。 |
Metadata
參數的一般元數據。
名稱 | 類型 | Description |
---|---|---|
assignPermissions |
boolean |
設定為 true,讓 Azure 入口網站在原則指派期間,於此參數的資源標識碼或資源範圍值上建立角色指派。 如果您想要在指派範圍之外指派許可權,這個屬性就很有用。 |
description |
string |
參數的描述。 |
displayName |
string |
參數的顯示名稱。 |
strongType |
string |
透過入口網站指派原則定義時使用。 提供內容感知值清單,供用戶選擇。 |
ParameterDefinitionsValue
可提供給原則的參數定義。
名稱 | 類型 | Description |
---|---|---|
allowedValues |
object[] |
參數的允許值。 |
defaultValue |
object |
如果未提供任何值,則為 參數的預設值。 |
metadata |
參數的一般元數據。 |
|
schema |
object |
使用自我定義 JSON 架構,在指派期間提供參數輸入的驗證。 此屬性僅支持物件類型參數,並遵循架構 2019-09 實作 Json.NET。 您可以在 https://json-schema.org/ 深入瞭解如何使用架構,並在 https://www.jsonschemavalidator.net/測試草稿架構。 |
type |
參數的數據類型。 |
parameterType
參數的數據類型。
值 | Description |
---|---|
Array | |
Boolean | |
DateTime | |
Float | |
Integer | |
Object | |
String |
PolicyDefinition
原則定義。
名稱 | 類型 | 預設值 | Description |
---|---|---|---|
id |
string |
原則定義的標識碼。 |
|
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。
值 | Description |
---|---|
BuiltIn | |
Custom | |
NotSpecified | |
Static |
systemData
與建立和上次修改資源相關的元數據。
名稱 | 類型 | Description |
---|---|---|
createdAt |
string (date-time) |
資源建立的時間戳(UTC)。 |
createdBy |
string |
建立資源的身分識別。 |
createdByType |
建立資源的身分識別類型。 |
|
lastModifiedAt |
string (date-time) |
上次修改的資源時間戳 (UTC) |
lastModifiedBy |
string |
上次修改資源的身分識別。 |
lastModifiedByType |
上次修改資源的身分識別類型。 |