Azure Logic Apps: Creating a URL for a run

Author:

Navigating Runs

Azure Logic Apps is a useful utility for cloud automation & integration. One difficulty that both it and its sibling product Power Automate Flows face is runtime reporting. Previous runs are listed by date and include a status, start time, identifier, and duration. However, you must click into the runtime to view more detailed information. This post will give you the knowledge to recreate the Azure Logic App run URL so that you can link directly to a specific run.

 

List of Azure Logic App runs where our URL will direct to

Logic Apps Workflow() Expression

First, we need to utilize the workflow() expression. If you are interested in learning more about Logic Apps expressions, I recommend heading over to Microsoft’s documentation on the subject. For now, we will explore this expression using the ‘compose’ action:

Logic Apps workflow expression

The description of this expression says: ‘This function provides you details for the workflow itself at runtime’. That description is not very detailed. But, we will populate the compose action and run our Logic App. This will allow us to review the outputs upon completion o

{
"id": "/subscriptions/a123b4cc-d5e6-676f-g89d-acccc9193d440/resourceGroups/BlogExample/providers/Microsoft.Logic/workflows/HelloWorld",
"name": "HelloWorld",
"type": "Microsoft.Logic/workflows",
"location": "location",
"run": {
"id": "/subscriptions/a123b4cc-d5e6-676f-g89d-acccc9193d440/resourceGroups/BlogExample/providers/Microsoft.Logic/workflows/HelloWorld/runs/08585275520790700602611706602CU25",
"name": "08585275520790700602611706602CU25",
"type": "Microsoft.Logic/workflows/runs"
}
}

The workflow() expression provides some useful information for logging scenarios and the key to creating a run URL in Logic Apps. The JSON attribute id (highlighted in purple below) inside the JSON "run": {} object contains half the information necessary to create an Azure Logic Apps run URL:

{
"id": "/subscriptions/a123b4cc-d5e6-676f-g89d-acccc9193d440/resourceGroups/BlogExample/providers/Microsoft.Logic/workflows/HelloWorld",
"name": "HelloWorld",
"type": "Microsoft.Logic/workflows",
"location": "location",
"run": {
"id": "/subscriptions/a123b4cc-d5e6-676f-g89d-acccc9193d440/resourceGroups/BlogExample/providers/Microsoft.Logic/workflows/HelloWorld/runs/08585275520790700602611706602CU25"
,
"name": "08585275520790700602611706602CU25",
"type": "Microsoft.Logic/workflows/runs"
}
}

However, if we try to access this attribute in the Dynamic content pane, we are only provided the ‘output’ attribute of our previous compose step.

Compose workflow() output in a Logic App run

Accessing Logic App Workflow() Attributes

There are two ways we can access the attributes: First, there is adding more detail to our workflow() expression. We will populate a new compose action with the following expression: workflow()['run']['id'] and the output returns the value of that attribute. Examples of the expression and the output below:

Azure Logic Apps workflow expression with JSON attributes

Output of expression workflow()[run][id]

An alternate method is to utilize the ‘Parse JSON’ data operations action in Logic Apps:

Logic Apps Parse JSON with workflow() expression

I was able to generate a schema for the JSON by using our output from the workflow() ‘compose’ action. Now, we have access to the workflow() expression’s attributes in our Dynamic content pane:

Parse workflow() dynamic content

JSON schemas that re-use attribute names or contain objects with duplicate names do not translate well into the dynamic content pane.

For example, we have two attributes named id and we need the one contained inside the run JSON object. Generally, you can use the order they appear in the JSON schema to determine the correct value.

In this case, the id contained in the run object appears after the initial id attribute. As a result, we should select the second id value in the dynamic content pane.

You can validate that you have the correct attribute by hovering over the attribute once you have populated it somewhere:

Alt text when hovering in logic apps

Crafting the Azure Logic Apps Run URL

Now that we have our run ID, we can craft the URL by appending it to the following: https://portal.azure.com/#view/Microsoft_Azure_EMA/LogicAppsMonitorBlade/runid/

I have done this inside a compose action:

Logic Apps Run URL concatenation with id

In some scenarios, you will need to wrap the id attribute in an expression called encodeUriComponent() that replaces URL unsafe characters with escape characters. I found that this example is one of those situations. So, my previous compose step ends up looking like this:

Run url with encode URI

Testing our URL

To test this, I will pass the outputs of the compose action in an email to myself: Outlook email with compose \output

Upon running this, we receive an email with our URL:

URL

That URL directs us to our specific Logic App run:

Logic App Run

 

I hope this helps you all in your Azure Logic Apps journey. If you are interested in learning more about Logic Apps or Power Automate, check out my ongoing blog series where I detail the differences between the two platforms:

Power Automate or Logic Apps: Price Matters

Power Automate or Logic Apps: Community Counts

Coming soon: Power Automate or Logic Apps: Feature Frenzy

Leave a Reply

Your email address will not be published. Required fields are marked *

en_USEnglish