Reputation: 11
I have created a Logic app (consumption) to query the Microsoft Resource graph for some open alerts, using API. The app is working fine but only listing the result within that subscription . I need the result from all subscriptions- please help me to understand how can i change my logic app to change the scope without deploying it in all the subscriptions?
Used the connectors List all subscriptions from ARM with no luck.
being a novice , please redirect me to the correct way of doing
Expecting the result from all subscriptions than the only one ,where the logic app is deployed.
Upvotes: 1
Views: 542
Reputation: 1721
You can use rest api to list all subscriptions and using another rest api you can query open alerts in logic app. Before that you need to set AAD app for authentication and getting bearer token. Refer this document for getting token.
Taken another http action and method as Get with Url "https://management.azure.com/subscriptions?api-version=2019-06-01". Passing token obtained from previous step in Header as shown below,
This will provide list of all subscriptions.
Using for each loop to iterated over each subscription id and get alerts for that particular subscription using url "https://management.azure.com/subscriptions/{subscriptionId}/providers/Microsoft.Insights/activityLogAlerts?api-version=2020-10-01"
This will provide alerts for each subscription.
Ran logic app and able to get alerts for each subscription,
HTTP output:
Output of HTTP2:
Reference links SO, MS document.
Upvotes: 0