I'm trying to replace the report I have been running via Powershell with a Logic App, to automate it and store the results in Sharepoint. However, I can't find a way to list the subscription tags and theit values within the logic app, only the tag names or the tag names and values for the resources hosted in the subscription. The main problem is all the tags aren't always present, so it has to be a dynamic list.
I have been trying to use the action "Get tags for each subscription", iterating theough the subscription list as it was the recommended one, but it lists the tags and values for all the nested resources.
I have also been trying to create a Kusta query to list the tags and their valules, but that only brought out the tag names.
In a Logic App, you need to use 2 HTTP
actions: the first one to get a list of subscriptions, and the second to get the tags from each subscription.
Your first GET
request goes to https://management.azure.com/subscriptions?api-version=2020-01-01
Response:
The For each
action will iterate the array with the subscription details:
The second GET
request goes to https://management.azure.com/subscriptions/@{item()?['subscriptionId']}/providers/Microsoft.Resources/tags/default?api-version=2021-04-01 -
Result:
Update: The other provided answer does the same but with the help of the Azure Resource Manager
connector, which might seem to be a better approach if you didn't want to use HTTP
actions :)