Azure APIM- Custom policy file applying in different scopes idempotently

53 views Asked by At

We are trying to achieve automated way of policy creation in different scopes as per a developer providing input yaml files . The above task will create a customized policy.xml as per the developer input and the scopes also will be decided from the conditions.

To further automate this process, we couldn't find a way over the MS docs, how we can apply the customized policies idempotently in the scope of API or operation (if policy is applied in API, the same will be over written to operations).

  • can we apply same policy in API and same policy again in the operation inside the API with a custom range using the generated policy.xml file

  • How to apply multiple custom policy.xml files in the API or operation level.

1

There are 1 answers

0
Vitaliy Kurokhtin On

There are a few things to keep in mind:

  1. Many policies manipulate request context and also may depend on information in that context, so policy order matters. In general, policy document is imperative, not declarative, description of what should be done with request.
  2. Every API, Operation, Product in APIM can have only one policy attached. So if your API policy is comprised of multiple parts, those need to be unified into a single document.
  3. Refere to policy documentation (https://learn.microsoft.com/en-us/azure/api-management/api-management-policies). Amy policies can only be used in certain scopes (API, Operation, Product, Global), some only in certain sections (inbound, outbound).

With above in mind you should be able to build a process where single policy document is produced based on declarative settings.