Delen via


Api Policy - Create Or Update

Hiermee maakt of werkt u beleidsconfiguratie voor de API bij.

PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/policies/policy?api-version=2024-05-01

URI-parameters

Name In Vereist Type Description
apiId
path True

string

minLength: 1
maxLength: 256
pattern: ^[^*#&+:<>?]+$

API-revisie-id. Moet uniek zijn in het huidige EXEMPLAAR van de API Management-service. Niet-huidige herziening heeft ; rev=n als achtervoegsel waarbij n het revisienummer is.

policyId
path True

PolicyIdName

De id van het beleid.

resourceGroupName
path True

string

minLength: 1
maxLength: 90

De naam van de resourcegroep. De naam is niet hoofdlettergevoelig.

serviceName
path True

string

minLength: 1
maxLength: 50
pattern: ^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$

De naam van de API Management-service.

subscriptionId
path True

string (uuid)

De id van het doelabonnement. De waarde moet een UUID zijn.

api-version
query True

string

minLength: 1

De API-versie die voor deze bewerking moet worden gebruikt.

Aanvraagkoptekst

Name Vereist Type Description
If-Match

string

ETag van de entiteit. Niet vereist bij het maken van een entiteit, maar vereist bij het bijwerken van een entiteit.

Aanvraagbody

Name Vereist Type Description
properties.value True

string

Inhoud van het beleid zoals gedefinieerd door de indeling.

properties.format

PolicyContentFormat

Indeling van de policyContent.

Antwoorden

Name Type Description
200 OK

PolicyContract

Api-beleidsconfiguratie van de tenant is bijgewerkt.

Kopteksten

ETag: string

201 Created

PolicyContract

De configuratie van api-beleid is gemaakt.

Kopteksten

ETag: string

Other Status Codes

ErrorResponse

Foutreactie waarin wordt beschreven waarom de bewerking is mislukt.

Beveiliging

azure_auth

Azure Active Directory OAuth2 Flow.

Type: oauth2
Stroom: implicit
Autorisatie-URL: https://login.microsoftonline.com/common/oauth2/authorize

Bereiken

Name Description
user_impersonation Uw gebruikersaccount imiteren

Voorbeelden

ApiManagementCreateApiPolicy
ApiManagementCreateApiPolicyNonXmlEncoded

ApiManagementCreateApiPolicy

Voorbeeldaanvraag

PUT https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/5600b57e7e8880006a040001/policies/policy?api-version=2024-05-01


{
  "properties": {
    "format": "xml",
    "value": "<policies> <inbound /> <backend>    <forward-request />  </backend>  <outbound /></policies>"
  }
}

Voorbeeldrespons

{
  "id": "/subscriptions/00000000-0000-0000-0000-000000000000/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/00000000-0000-0000-0000-000000000000/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

Voorbeeldaanvraag

PUT https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/5600b57e7e8880006a040001/policies/policy?api-version=2024-05-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"
  }
}

Voorbeeldrespons

{
  "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 =&gt; 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 =&gt; h.Ke==\"Via\"))\" </value>\r\n    </set-header>\r\n  </inbound>\r\n</policies>"
  }
}

Definities

Name Description
ErrorAdditionalInfo

Aanvullende informatie over de resourcebeheerfout.

ErrorDetail

De foutdetails.

ErrorResponse

Foutreactie

PolicyContentFormat

Indeling van de policyContent.

PolicyContract

Beleidscontractgegevens.

PolicyIdName

De id van het beleid.

ErrorAdditionalInfo

Aanvullende informatie over de resourcebeheerfout.

Name Type Description
info

object

De aanvullende informatie.

type

string

Het extra informatietype.

ErrorDetail

De foutdetails.

Name Type Description
additionalInfo

ErrorAdditionalInfo[]

De fout bevat aanvullende informatie.

code

string

De foutcode.

details

ErrorDetail[]

De foutdetails.

message

string

Het foutbericht.

target

string

Het foutdoel.

ErrorResponse

Foutreactie

Name Type Description
error

ErrorDetail

Het foutobject.

PolicyContentFormat

Indeling van de policyContent.

Waarde Description
rawxml

De inhoud is inline en het inhoudstype is een niet-XML-gecodeerd beleidsdocument.

rawxml-link

Het beleidsdocument is niet xml-gecodeerd en wordt gehost op een HTTP-eindpunt dat toegankelijk is vanuit de API Management-service.

xml

De inhoud is inline en het inhoudstype is een XML-document.

xml-link

Het XML-document van het beleid wordt gehost op een HTTP-eindpunt dat toegankelijk is vanuit de API Management-service.

PolicyContract

Beleidscontractgegevens.

Name Type Default value Description
id

string

Volledig gekwalificeerde resource-id voor de resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}

name

string

De naam van de resource

properties.format

PolicyContentFormat

xml

Indeling van de policyContent.

properties.value

string

Inhoud van het beleid zoals gedefinieerd door de indeling.

type

string

Het type resource. Bijvoorbeeld 'Microsoft.Compute/virtualMachines' of 'Microsoft.Storage/storageAccounts'

PolicyIdName

De id van het beleid.

Waarde Description
policy