0

I can able to fetch the resource details using the Azure CLI command. However, is there a way to fetch the specific resource details using Azure API Management URL? I have listed out the Azure API Management link to get the tag details. I need Azure API Management to get the resource details via API. Please help me.

CLI command (Get-AzResource -Tag @{ "ApplicationID"="XXX"})

Output Name : sample-dev-func ResourceGroupName : example-rg ResourceType : Microsoft.Web/sites Location : eastus ResourceId : /subscriptions/xxxxxxx/resourceGroups/xxxxx/providers/Microsoft.Web/sites/resourceName etc..,

Azure Management API

https://management.azure.com/subscriptions/{subscriptionId}/tagNames?api-version=2021-04-01

Rock
  • 21
  • 5

1 Answers1

1

However, is there a way to fetch the specific resource details using Azure API Management URL?

Yes. You can use Resources - List REST API to get the list of resources. This API supports filtering by tag name/value.

From the same link:

Resources can be filtered by tag names and values. For example, to filter for a tag name and value, use $filter=tagName eq 'tag1' and tagValue eq 'Value1'. Note that when resources are filtered by tag name and value, the original tags for each resource will not be returned in the results. Any list of additional properties queried via $expand may also not be compatible when filtering by tag names/values.

For tag names only, resources can be filtered by prefix using the following syntax: $filter=startswith(tagName, 'depart'). This query will return all resources with a tag name prefixed by the phrase depart (i.e.department, departureDate, departureTime, etc.)

Tip: Azure CLI essentially is a wrapper of Azure REST API. If you want to see the actual request sent by the CLI command and the response received, simply execute your CLI command with --debug switch. You will get all the details.

Gaurav Mantri
  • 128,066
  • 12
  • 206
  • 241
  • Gaurav, Thank you for your reply. I can able filter by tag using API Management. – Rock Sep 21 '21 at 16:34
  • However, I have run the below command to get verbose (To know the request send by CLI). But I do not get any verbose details. But I do get the resource details. I want to see what this command doing in backgrou. "az resource list --tag AppID=XXX --query [] --verbose" Am I missing something? – Rock Sep 21 '21 at 16:36
  • Sorry, my bad! Actually you will need to use `--debug` switch. Please try to use that instead of `--verbose`. I have edited my answer as well. – Gaurav Mantri Sep 21 '21 at 16:56