Is there any way to export the effective policy assigned to API and operation level to an XML file?

67 Views Asked by At

I tried below option, but its not fetching the effective policy assigned to an API or operation, where as its fetching just the policy assigned to them alone

curl --location 'https://management.azure.com/subscriptions/xxxxxxxxxxxx/resourceGroups/xxxxxxxxx/providers/Microsoft.ApiManagement/service/xxxxxxxxxx/apis/apiname/policies/policy?format=xml&api-version=2022-08-01' --header 'Content-Type: application/json' --header 'Authorization: Bearer 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
1

There are 1 best solutions below

1
Ikhtesam Afrin On BEST ANSWER

You can use the below URL to find out the effective policy in API level.

GET https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/policies/policy?effective=true&format=xml&api-version=2022-08-01

CURL Request-

curl -H "Content-Type: application/json" -H "Authorization: Bearer eyJ0e************" "https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/policies/policy?effective=true&format=xml&api-version=2022-08-01"

I am getting below response-

enter image description here

To get the effective policy in operation level, you can use the below URL.

GET https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/policies/policy?effective=true&format=xml&api-version=2022-08-01

CURL Request-

curl -H "Content-Type: application/json" -H "Authorization: Bearer eyJ0eX******" "https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/{apiId}/operations/{operationId}/policies/policy?effective=true&format=xml&api-version=2022-08-01"

Response-

enter image description here