Aracılığıyla paylaş


Policy Set Definitions - Create Or Update

Bu işlem, verilen abonelikte belirtilen adla bir ilke kümesi tanımı oluşturur veya güncelleştirir.

PUT https://management.azure.com/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}?api-version=2023-04-01

URI Parametreleri

Name İçinde Gerekli Tür Description
policySetDefinitionName
path True

string

Oluşturulacak ilke kümesi tanımının adı.

Regex pattern: ^[^<>*%&:\?.+/]*[^<>*%&:\?.+/ ]+$

subscriptionId
path True

string

uuid

Hedef aboneliğin kimliği. Değer bir UUID olmalıdır.

api-version
query True

string

Bu işlem için kullanılacak API sürümü.

İstek Gövdesi

Name Gerekli Tür Description
properties.policyDefinitions True

PolicyDefinitionReference[]

İlke tanımı başvuru dizisi.

properties.description

string

İlke kümesi tanım açıklaması.

properties.displayName

string

İlke kümesi tanımının görünen adı.

properties.metadata

object

İlke kümesi tanım meta verileri. Meta veriler açık uçlu bir nesnedir ve genellikle anahtar değer çiftlerinden oluşan bir koleksiyondur.

properties.parameters

<string,  ParameterDefinitionsValue>

İlke tanımı başvurularında kullanılabilecek ilke kümesi tanım parametreleri.

properties.policyDefinitionGroups

PolicyDefinitionGroup[]

İlke tanımı gruplarını açıklayan meta veriler, ilke kümesi tanımı içinde başvurur.

properties.policyType

policyType

İlke kümesi tanımının türü. Olası değerler NotSpecified, BuiltIn, Custom ve Static değerleridir.

properties.version

string

#.#.# biçiminde ilke kümesi tanım sürümü.

properties.versions

string[]

Bu ilke kümesi tanımı için kullanılabilir sürümlerin listesi.

Yanıtlar

Name Tür Description
200 OK

PolicySetDefinition

Tamam - İlke kümesi tanımı hakkında bilgi döndürür.

201 Created

PolicySetDefinition

Oluşturuldu - İlke kümesi tanımı hakkındaki bilgileri döndürür.

Other Status Codes

CloudError

İşlemin neden başarısız olduğunu açıklayan hata yanıtı.

Güvenlik

azure_auth

Azure Active Directory OAuth2 Flow.

Type: oauth2
Flow: implicit
Authorization URL: https://login.microsoftonline.com/common/oauth2/authorize

Scopes

Name Description
user_impersonation kullanıcı hesabınızın kimliğine bürünme

Örnekler

Create or update a policy set definition
Create or update a policy set definition with groups

Create or update a policy set definition

Sample Request

PUT https://management.azure.com/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policySetDefinitions/CostManagement?api-version=2023-04-01

{
  "properties": {
    "displayName": "Cost Management",
    "description": "Policies to enforce low cost storage SKUs",
    "metadata": {
      "category": "Cost Management"
    },
    "parameters": {
      "namePrefix": {
        "type": "String",
        "defaultValue": "myPrefix",
        "metadata": {
          "displayName": "Prefix to enforce on resource names"
        }
      }
    },
    "policyDefinitions": [
      {
        "policyDefinitionId": "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1",
        "policyDefinitionReferenceId": "Limit_Skus",
        "parameters": {
          "listOfAllowedSKUs": {
            "value": [
              "Standard_GRS",
              "Standard_LRS"
            ]
          }
        }
      },
      {
        "policyDefinitionId": "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming",
        "policyDefinitionReferenceId": "Resource_Naming",
        "parameters": {
          "prefix": {
            "value": "[parameters('namePrefix')]"
          },
          "suffix": {
            "value": "-LC"
          }
        }
      }
    ]
  }
}

Sample Response

{
  "id": "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policySetDefinitions/CostManagement",
  "type": "Microsoft.Authorization/policySetDefinitions",
  "name": "CostManagement",
  "properties": {
    "displayName": "Cost Management",
    "description": "Policies to enforce low cost storage SKUs",
    "metadata": {
      "category": "Cost Management"
    },
    "version": "1.2.1",
    "versions": [
      "1.2.1",
      "1.0.0"
    ],
    "parameters": {
      "namePrefix": {
        "type": "String",
        "defaultValue": "myPrefix",
        "metadata": {
          "displayName": "Prefix to enforce on resource names"
        }
      }
    },
    "policyDefinitions": [
      {
        "policyDefinitionId": "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1",
        "policyDefinitionReferenceId": "Limit_Skus",
        "parameters": {
          "listOfAllowedSKUs": {
            "value": [
              "Standard_GRS",
              "Standard_LRS"
            ]
          }
        }
      },
      {
        "policyDefinitionId": "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming",
        "policyDefinitionReferenceId": "Resource_Naming",
        "parameters": {
          "prefix": {
            "value": "[parameters('namePrefix')]"
          },
          "suffix": {
            "value": "-LC"
          }
        }
      }
    ]
  }
}
{
  "id": "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policySetDefinitions/CostManagement",
  "type": "Microsoft.Authorization/policySetDefinitions",
  "name": "CostManagement",
  "properties": {
    "displayName": "Cost Management",
    "description": "Policies to enforce low cost storage SKUs",
    "metadata": {
      "category": "Cost Management"
    },
    "parameters": {
      "namePrefix": {
        "type": "String",
        "defaultValue": "myPrefix",
        "metadata": {
          "displayName": "Prefix to enforce on resource names"
        }
      }
    },
    "policyDefinitions": [
      {
        "policyDefinitionId": "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1",
        "policyDefinitionReferenceId": "Limit_Skus",
        "parameters": {
          "listOfAllowedSKUs": {
            "value": [
              "Standard_GRS",
              "Standard_LRS"
            ]
          }
        }
      },
      {
        "policyDefinitionId": "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming",
        "policyDefinitionReferenceId": "Resource_Naming",
        "parameters": {
          "prefix": {
            "value": "[parameters('namePrefix')]"
          },
          "suffix": {
            "value": "-LC"
          }
        }
      }
    ]
  }
}

Create or update a policy set definition with groups

Sample Request

PUT https://management.azure.com/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policySetDefinitions/CostManagement?api-version=2023-04-01

{
  "properties": {
    "displayName": "Cost Management",
    "description": "Policies to enforce low cost storage SKUs",
    "metadata": {
      "category": "Cost Management"
    },
    "policyDefinitionGroups": [
      {
        "name": "CostSaving",
        "displayName": "Cost Management Policies",
        "description": "Policies designed to control spend within a subscription."
      },
      {
        "name": "Organizational",
        "displayName": "Organizational Policies",
        "description": "Policies that help enforce resource organization standards within a subscription."
      }
    ],
    "policyDefinitions": [
      {
        "policyDefinitionId": "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1",
        "policyDefinitionReferenceId": "Limit_Skus",
        "groupNames": [
          "CostSaving"
        ],
        "parameters": {
          "listOfAllowedSKUs": {
            "value": [
              "Standard_GRS",
              "Standard_LRS"
            ]
          }
        }
      },
      {
        "policyDefinitionId": "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming",
        "policyDefinitionReferenceId": "Resource_Naming",
        "groupNames": [
          "Organizational"
        ],
        "parameters": {
          "prefix": {
            "value": "DeptA"
          },
          "suffix": {
            "value": "-LC"
          }
        }
      }
    ]
  }
}

Sample Response

{
  "id": "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policySetDefinitions/CostManagement",
  "type": "Microsoft.Authorization/policySetDefinitions",
  "name": "CostManagement",
  "properties": {
    "displayName": "Cost Management",
    "description": "Policies to enforce low cost storage SKUs",
    "metadata": {
      "category": "Cost Management"
    },
    "version": "1.2.1",
    "versions": [
      "1.2.1",
      "1.0.0"
    ],
    "policyDefinitionGroups": [
      {
        "name": "CostSaving",
        "displayName": "Cost Management Policies",
        "description": "Policies designed to control spend within a subscription."
      },
      {
        "name": "Organizational",
        "displayName": "Organizational Policies",
        "description": "Policies that help enforce resource organization standards within a subscription."
      }
    ],
    "policyDefinitions": [
      {
        "policyDefinitionId": "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1",
        "policyDefinitionReferenceId": "Limit_Skus",
        "groupNames": [
          "CostSaving"
        ],
        "parameters": {
          "listOfAllowedSKUs": {
            "value": [
              "Standard_GRS",
              "Standard_LRS"
            ]
          }
        }
      },
      {
        "policyDefinitionId": "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming",
        "policyDefinitionReferenceId": "Resource_Naming",
        "groupNames": [
          "Organizational"
        ],
        "parameters": {
          "prefix": {
            "value": "DeptA"
          },
          "suffix": {
            "value": "-LC"
          }
        }
      }
    ]
  }
}
{
  "id": "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policySetDefinitions/CostManagement",
  "type": "Microsoft.Authorization/policySetDefinitions",
  "name": "CostManagement",
  "properties": {
    "displayName": "Cost Management",
    "description": "Policies to enforce low cost storage SKUs",
    "metadata": {
      "category": "Cost Management"
    },
    "version": "1.2.1",
    "versions": [
      "1.2.1",
      "1.0.0"
    ],
    "policyDefinitionGroups": [
      {
        "name": "CostSaving",
        "displayName": "Cost Management Policies",
        "description": "Policies designed to control spend within a subscription."
      },
      {
        "name": "Organizational",
        "displayName": "Organizational Policies",
        "description": "Policies that help enforce resource organization standards within a subscription."
      }
    ],
    "policyDefinitions": [
      {
        "policyDefinitionId": "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1",
        "policyDefinitionReferenceId": "Limit_Skus",
        "groupNames": [
          "CostSaving"
        ],
        "parameters": {
          "listOfAllowedSKUs": {
            "value": [
              "Standard_GRS",
              "Standard_LRS"
            ]
          }
        }
      },
      {
        "policyDefinitionId": "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming",
        "policyDefinitionReferenceId": "Resource_Naming",
        "groupNames": [
          "Organizational"
        ],
        "parameters": {
          "prefix": {
            "value": "DeptA"
          },
          "suffix": {
            "value": "-LC"
          }
        }
      }
    ]
  }
}

Tanımlar

Name Description
CloudError

İlke işleminden bir hata yanıtı.

createdByType

Kaynağı oluşturan kimliğin türü.

ErrorAdditionalInfo

Kaynak yönetimi hatası ek bilgileri.

ErrorResponse

Hata Yanıtı

Metadata

parametresi için genel meta veriler.

ParameterDefinitionsValue

İlkeye sağlanabilir bir parametrenin tanımı.

parameterType

Parametrenin veri türü.

ParameterValuesValue

Parametrenin değeri.

PolicyDefinitionGroup

İlke tanımı grubu.

PolicyDefinitionReference

İlke tanımı başvurusu.

PolicySetDefinition

İlke kümesi tanımı.

policyType

İlke kümesi tanımının türü. Olası değerler NotSpecified, BuiltIn, Custom ve Static değerleridir.

systemData

Kaynağın oluşturulması ve son değiştirilmesiyle ilgili meta veriler.

CloudError

İlke işleminden bir hata yanıtı.

Name Tür Description
error

ErrorResponse

Hata Yanıtı
Başarısız işlemlerin hata ayrıntılarını döndürmek için tüm Azure Resource Manager API'leri için genel hata yanıtı. (Bu, OData hata yanıtı biçimini de izler.)

createdByType

Kaynağı oluşturan kimliğin türü.

Name Tür Description
Application

string

Key

string

ManagedIdentity

string

User

string

ErrorAdditionalInfo

Kaynak yönetimi hatası ek bilgileri.

Name Tür Description
info

object

Ek bilgiler.

type

string

Ek bilgi türü.

ErrorResponse

Hata Yanıtı

Name Tür Description
additionalInfo

ErrorAdditionalInfo[]

Hata ek bilgileri.

code

string

Hata kodu.

details

ErrorResponse[]

Hata ayrıntıları.

message

string

Hata iletisi.

target

string

Hata hedefi.

Metadata

parametresi için genel meta veriler.

Name Tür Description
assignPermissions

boolean

İlke ataması sırasında Azure portal bu parametrenin kaynak kimliğinde veya kaynak kapsamı değerinde rol atamaları oluşturmasını sağlamak için true olarak ayarlayın. Bu özellik, atama kapsamı dışında izinler atamak istemeniz durumunda kullanışlıdır.

description

string

Parametresinin açıklaması.

displayName

string

Parametrenin görünen adı.

strongType

string

portal aracılığıyla ilke tanımı atanırken kullanılır. Kullanıcının aralarından seçim yapabileceğiniz değerlerin bağlam bilgisi olan bir listesi sağlar.

ParameterDefinitionsValue

İlkeye sağlanabilir bir parametrenin tanımı.

Name Tür Description
allowedValues

object[]

parametresi için izin verilen değerler.

defaultValue

object

Değer sağlanmazsa parametresinin varsayılan değeri.

metadata

Metadata

parametresi için genel meta veriler.

schema

object

Kendi kendine tanımlanmış bir JSON şeması kullanarak atama sırasında parametre girişlerinin doğrulanması sağlar. Bu özellik yalnızca nesne türü parametreler için desteklenir ve Json.NET Schema 2019-09 uygulamasını izler. şemaları kullanma hakkında daha fazla bilgiyi adresinden https://json-schema.org/ ve taslak şemaları https://www.jsonschemavalidator.net/test edebilirsiniz.

type

parameterType

Parametrenin veri türü.

parameterType

Parametrenin veri türü.

Name Tür Description
Array

string

Boolean

string

DateTime

string

Float

string

Integer

string

Object

string

String

string

ParameterValuesValue

Parametrenin değeri.

Name Tür Description
value

object

Parametre değeri.

PolicyDefinitionGroup

İlke tanımı grubu.

Name Tür Description
additionalMetadataId

string

Grup hakkında ek meta veriler içeren bir kaynağın kaynak kimliği.

category

string

Grubun kategorisi.

description

string

Grubun açıklaması.

displayName

string

Grubun görünen adı.

name

string

Grubun adı.

PolicyDefinitionReference

İlke tanımı başvurusu.

Name Tür Description
groupNames

string[]

Bu ilke tanımı başvurusunun ait olduğu grupların adı.

parameters

<string,  ParameterValuesValue>

Başvuruda bulunan ilke kuralı için parametre değerleri. Anahtarlar parametre adlarıdır.

policyDefinitionId

string

İlke tanımının veya ilke kümesi tanımının kimliği.

policyDefinitionReferenceId

string

Bu ilke tanımı başvurusu için benzersiz bir kimlik (ilke kümesi tanımı içinde).

PolicySetDefinition

İlke kümesi tanımı.

Name Tür Description
id

string

İlke kümesi tanımının kimliği.

name

string

İlke kümesi tanımının adı.

properties.description

string

İlke kümesi tanım açıklaması.

properties.displayName

string

İlke kümesi tanımının görünen adı.

properties.metadata

object

İlke kümesi tanım meta verileri. Meta veriler açık uçlu bir nesnedir ve genellikle anahtar değer çiftlerinden oluşan bir koleksiyondur.

properties.parameters

<string,  ParameterDefinitionsValue>

İlke tanımı başvurularında kullanılabilecek ilke kümesi tanım parametreleri.

properties.policyDefinitionGroups

PolicyDefinitionGroup[]

İlke tanımı gruplarını açıklayan meta veriler, ilke kümesi tanımı içinde başvurur.

properties.policyDefinitions

PolicyDefinitionReference[]

İlke tanımı başvuru dizisi.

properties.policyType

policyType

İlke kümesi tanımının türü. Olası değerler NotSpecified, BuiltIn, Custom ve Static değerleridir.

properties.version

string

#.#.# biçiminde ilke kümesi tanım sürümü.

properties.versions

string[]

Bu ilke kümesi tanımı için kullanılabilir sürümlerin listesi.

systemData

systemData

Bu kaynakla ilgili sistem meta verileri.

type

string

Kaynağın türü (Microsoft.Authorization/policySetDefinitions).

policyType

İlke kümesi tanımının türü. Olası değerler NotSpecified, BuiltIn, Custom ve Static değerleridir.

Name Tür Description
BuiltIn

string

Custom

string

NotSpecified

string

Static

string

systemData

Kaynağın oluşturulması ve son değiştirilmesiyle ilgili meta veriler.

Name Tür Description
createdAt

string

Kaynak oluşturma (UTC) zaman damgası.

createdBy

string

Kaynağı oluşturan kimlik.

createdByType

createdByType

Kaynağı oluşturan kimliğin türü.

lastModifiedAt

string

Kaynağın son değişikliğinin zaman damgası (UTC)

lastModifiedBy

string

Kaynağı son değiştiren kimlik.

lastModifiedByType

createdByType

Kaynağı en son değiştiren kimliğin türü.