Search code examples
azure-api-managementazure-cliazure-policy

How do I get details for operation policies in Azure APIM


Is there a way to filter out and get all of the policies for the operations in my APIM. I am working on a project that was taken over and is using lots of operations in APIM. Some of them have filtering for inbound IP and some don't. The whole idea is to filter all of the operations with some specific policy.

I am passing this line in AZ CLI:

az apim api operation show --resource-group $myResourceGroup --api-id $apiId --service-name $serviceName --operation-id $operationId

However for the policies field I get null as an output.

policies: null

I've also tested the az apim api operation list but I still don't get the expected output.


Solution

  • You can retrieve the operation ID details using below CLI command.

    az apim api operation show --api-id mynew --operation-id new -g xxx -n policyj
    

    enter image description here

    Once it is done, you need to use az rest --method CLI command with Get method to retrieve the policy details of API's as shown below.

    az rest --method get --uri "/subscriptions/xxxx/resourceGroups/xxx/providers/Microsoft.ApiManagement/service/<APIM>/apis/<APIName>/operations/new/policies?api-version=2020-06-01-preview"
    

    enter image description here