0

I'm trying to display the backend base-url info of an operation's API in my apim instance, i can achieve my goal with the Azure Powershell Module command:

Get-AzApiManagementPolicy -Context $mycontextvar -ApiId "myapiid" -OperationId "myoperationid" -Subscription "mysub" | Select-Xml -XPath '/policies/inbound/set-backend-service' | ForEach-Object { $_.Node."base-url" }

However, i want to display it with an azure cli command. I tried with

az apim api operation list --api-id myapiid --resource-group myrg --service-name myservname --subscription mysub

and

az apim api list --resource-group myrg --service-name myservname --subscription mysub

without results.

I should take into consideration the az policy or the az network commands but i don't know how to start to use them to retrieve this info and, once i saw the documentation, i don’t even know if they can help me. ' Which Azure CLI command should i use to gather the backend base-url?

Venkataraman R
  • 12,181
  • 2
  • 31
  • 58
elmales
  • 3
  • 2

1 Answers1

2

What you can do until the GET policy operation is available in CLI:

  1. get operation id / URL with az apim api operation show --api-id myapi --operation-id myop -g myrg -n myapim

  2. you will see an id like "id": "/subscriptions/12345678-1234-5678-90ab-cdef12345678/resourceGroups/myrg/providers/Microsoft.ApiManagement/service/myapim/apis/myapi/operations/myop",

  3. mix with policy GET operation https://learn.microsoft.com/en-us/rest/api/apimanagement/2019-12-01/api-operation-policy/get into

az rest --method get --url "https://management.azure.com/subscriptions/12345678-1234-5678-90ab-cdef12345678/resourceGroups/myrg/providers/Microsoft.ApiManagement/service/myapim/apis/myapi/operations/myop/policies/policy?api-version=2019-12-01"

which should give you the policy.

Kai Walter
  • 3,485
  • 2
  • 32
  • 62