Last week I was working with a partner on creating some cloud-based workflows for Dynamics 365 Business Central integrations with Azure Logic Apps. The partner has multiple Azure subscriptions and multiple workflows running on the different subscriptions and it raises the following requests:
- Is it possible to have an overview of all the workflows I have (and their state) across subscriptions?
- Can I know the connectors they’re using?
- For timer-based workflows (recurrencies) can I have an overview of the scheduling?
Here is where Azure Resource Graph Explorer and KQL comes in handy.
Azure Resource Graph is an Azure service designed to extend Azure Resource Management by providing efficient and performant resource exploration with the ability to query at scale across a given set of subscriptions so that you can effectively govern your environment. These queries provide the following abilities:
- Query resources with complex filtering, grouping, and sorting by resource properties.
- Explore resources iteratively based on governance requirements.
- Assess the impact of applying policies in a vast cloud environment.
- Query changes made to resource properties (currently in preview at the time of writing this post).
How can I solve the above requirements with Azure Resource Graph Explorer and KQL?
To have an overview of all the Azure Logic Apps workflows in your Azure subscriptions and their state, you can execute the following KQL query:
resources | where type == "microsoft.logic/workflows" | extend state = properties.state | extend trigger = properties.definition.triggers | extend createdTime = properties.createdTime | extend changedTime = properties.changedTime | extend connections = properties.parameters.$connections.value | project name, createdTime, changedTime, state, subscriptionId, connections, location, resourceGroup
Result is a table like the following:
In the connections field you can see the connectors used by the workflow (useful if you need to do some checks).
To have a clear overview of all the scheduled workflows you have in your Azure subscriptions and to quickly having an overview of the scheduling plan, oyu can execute the following KQL query:
resources | where type == "microsoft.logic/workflows" | where properties contains "recurrence" | extend state = properties.state | extend trigger = properties.definition.triggers | where isnotnull(properties.definition.triggers.Recurrence.type) | extend startTime = properties.definition.triggers.Recurrence.recurrence.startTime | extend frequency = properties.definition.triggers.Recurrence.recurrence.frequency | extend interval = properties.definition.triggers.Recurrence.recurrence.interval | extend createdTime = properties.createdTime | extend changedTime = properties.changedTime | extend connections = properties.parameters.$connections.value | project name, createdTime, changedTime, state, startTime, frequency, interval, subscriptionId, connections, location, resourceGroup
The result is the following table, clearly showing the schedule plan:
I think this is very useful if you have a lot of scheduled tasks. You can see how the workflows are scheduled, their recurrence, their state and so on.
And if you want to monitor resource configuration changes? What is changed in my Azure Logic Apps workflows in the last N days (maybe to discover why one of your workflows starts failing from a particular day)? This is a new powerful feature of Azure Resource Graph Explorer.
You can execute the following KQL query for that:
resourcechanges | extend changeTime = todatetime(properties.changeAttributes.timestamp), targetResourceId = tostring(properties.targetResourceId), targetResourceTye = tostring(properties.targetResourceType), changeType = tostring(properties.changeType), correlationId = properties.changeAttributes.correlationId, changedProperties = properties.changes, changeCount = properties.changeAttributes.changesCount | where targetResourceTye == "microsoft.logic/workflows" | where changeTime > ago(1d) | order by changeTime desc | project changeTime, targetResourceId, targetResourceTye , changeType, correlationId, changeCount, changedProperties
The life with your cloud workflows will be more easy with these arms at your fingertips…
P.S. I think I will upload this queries also in the Business Central BCTech repository on GitHub because they could be useful for everyone working on creating workflows for Dynamics 365 Business Central. Just need the time to ask Kennie the right place for the upload