Api Policy - Create Or Update
API için ilke yapılandırmasını oluşturur veya güncelleştirir.
PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/policies/policy?api-version=2022-08-01
URI Parametreleri
Name | İçinde | Gerekli | Tür | Description |
---|---|---|---|---|
api
|
path | True |
string |
API düzeltme tanımlayıcısı. Geçerli API Management hizmet örneğinde benzersiz olmalıdır. Geçerli olmayan düzeltmede ; rev=n sonek olarak, burada n düzeltme numarasıdır. Normal ifade deseni: |
policy
|
path | True |
İlkenin tanımlayıcısı. |
|
resource
|
path | True |
string |
Kaynak grubunun adı. Ad büyük/küçük harfe duyarlı değildir. |
service
|
path | True |
string |
API Management hizmetinin adı. Normal ifade deseni: |
subscription
|
path | True |
string |
Hedef aboneliğin kimliği. |
api-version
|
query | True |
string |
Bu işlem için kullanılacak API sürümü. |
İstek Başlığı
Name | Gerekli | Tür | Description |
---|---|---|---|
If-Match |
string |
Varlığın ETag'i. Varlık oluştururken gerekli değildir, ancak varlığı güncelleştirirken gereklidir. |
İstek Gövdesi
Name | Gerekli | Tür | Description |
---|---|---|---|
properties.value | True |
string |
İlkenin biçimiyle tanımlandığı şekilde içeriği. |
properties.format |
policyContent biçimi. |
Yanıtlar
Name | Tür | Description |
---|---|---|
200 OK |
Kiracının API ilkesi yapılandırması başarıyla güncelleştirildi. Üst Bilgiler ETag: string |
|
201 Created |
Api ilkesi yapılandırması başarıyla oluşturuldu. Üst Bilgiler ETag: string |
|
Other Status Codes |
İşlemin neden başarısız olduğunu açıklayan hata yanıtı. |
Güvenlik
azure_auth
Azure Active Directory OAuth2 Flow.
Tür:
oauth2
Akış:
implicit
Yetkilendirme URL’si:
https://login.microsoftonline.com/common/oauth2/authorize
Kapsamlar
Name | Description |
---|---|
user_impersonation | kullanıcı hesabınızın kimliğine bürünme |
Örnekler
Api |
Api |
ApiManagementCreateApiPolicy
Örnek isteği
PUT https://management.azure.com/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/5600b57e7e8880006a040001/policies/policy?api-version=2022-08-01
{
"properties": {
"format": "xml",
"value": "<policies> <inbound /> <backend> <forward-request /> </backend> <outbound /></policies>"
}
}
Örnek yanıt
{
"id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/5600b57e7e8880006a040001/policies/policy",
"type": "Microsoft.ApiManagement/service/apis/policies",
"name": "policy",
"properties": {
"value": "<policies>\r\n <inbound />\r\n <backend>\r\n <forward-request />\r\n </backend>\r\n <outbound />\r\n</policies>"
}
}
{
"id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/5600b57e7e8880006a040001/policies/policy",
"type": "Microsoft.ApiManagement/service/apis/policies",
"name": "policy",
"properties": {
"value": "<policies>\r\n <inbound />\r\n <backend>\r\n <forward-request />\r\n </backend>\r\n <outbound />\r\n</policies>"
}
}
ApiManagementCreateApiPolicyNonXmlEncoded
Örnek isteği
PUT https://management.azure.com/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/5600b57e7e8880006a040001/policies/policy?api-version=2022-08-01
{
"properties": {
"value": "<policies>\r\n <inbound>\r\n <base />\r\n <set-header name=\"newvalue\" exists-action=\"override\">\r\n <value>\"@(context.Request.Headers.FirstOrDefault(h => h.Ke==\"Via\"))\" </value>\r\n </set-header>\r\n </inbound>\r\n </policies>",
"format": "rawxml"
}
}
Örnek yanıt
{
"id": "/subscriptions/4c1a3bc6-89f9-46fe-a175-5d8984b25095/resourcegroups/Api-DF-West-US/providers/Microsoft.ApiManagement/service/samirmsiservice2/apis/echo-api/operations/create-resource/policies/policy",
"type": "Microsoft.ApiManagement/service/apis/operations/policies",
"name": "policy",
"properties": {
"value": "<policies>\r\n <inbound>\r\n <base />\r\n <set-header name=\"newvalue\" exists-action=\"override\">\r\n <value>\"@(context.Request.Headers.FirstOrDefault(h => h.Ke==\"Via\"))\" </value>\r\n </set-header>\r\n </inbound>\r\n</policies>"
}
}
{
"id": "/subscriptions/4c1a3bc6-89f9-46fe-a175-5d8984b25095/resourcegroups/Api-DF-West-US/providers/Microsoft.ApiManagement/service/samirmsiservice2/apis/echo-api/operations/create-resource/policies/policy",
"type": "Microsoft.ApiManagement/service/apis/operations/policies",
"name": "policy",
"properties": {
"value": "<policies>\r\n <inbound>\r\n <base />\r\n <set-header name=\"newvalue\" exists-action=\"override\">\r\n <value>\"@(context.Request.Headers.FirstOrDefault(h => h.Ke==\"Via\"))\" </value>\r\n </set-header>\r\n </inbound>\r\n</policies>"
}
}
Tanımlar
Name | Description |
---|---|
Error |
Hata Alanı sözleşmesi. |
Error |
Hata Yanıtı. |
Policy |
policyContent biçimi. |
Policy |
İlke Sözleşmesi ayrıntıları. |
Policy |
İlkenin tanımlayıcısı. |
ErrorFieldContract
Hata Alanı sözleşmesi.
Name | Tür | Description |
---|---|---|
code |
string |
Özellik düzeyi hata kodu. |
message |
string |
Özellik düzeyi hatanın insan tarafından okunabilir gösterimi. |
target |
string |
Özellik adı. |
ErrorResponse
Hata Yanıtı.
Name | Tür | Description |
---|---|---|
error.code |
string |
Hizmet tanımlı hata kodu. Bu kod, yanıtta belirtilen HTTP hata kodu için bir alt durum görevi görür. |
error.details |
Doğrulama hatası durumunda istekte gönderilen geçersiz alanların listesi. |
|
error.message |
string |
Hatanın insan tarafından okunabilen gösterimi. |
PolicyContentFormat
policyContent biçimi.
Name | Tür | Description |
---|---|---|
rawxml |
string |
İçerikler satır içidir ve İçerik türü XML ile kodlanmamış bir ilke belgesidir. |
rawxml-link |
string |
İlke belgesi XML olarak kodlanmaz ve API Management hizmetinden erişilebilen bir HTTP uç noktasında barındırılır. |
xml |
string |
İçerikler satır içidir ve İçerik türü bir XML belgesidir. |
xml-link |
string |
İlke XML belgesi, API Management hizmetinden erişilebilen bir HTTP uç noktasında barındırılır. |
PolicyContract
İlke Sözleşmesi ayrıntıları.
Name | Tür | Default value | Description |
---|---|---|---|
id |
string |
Kaynağın tam kaynak kimliği. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} |
|
name |
string |
Kaynağın adı |
|
properties.format | xml |
policyContent biçimi. |
|
properties.value |
string |
İlkenin biçimiyle tanımlandığı şekilde içeriği. |
|
type |
string |
Kaynağın türü. Örneğin, "Microsoft.Compute/virtualMachines" veya "Microsoft.Storage/storageAccounts" |
PolicyIdName
İlkenin tanımlayıcısı.
Name | Tür | Description |
---|---|---|
policy |
string |