Forum Discussion
Logic App Workflow() function returning un-expected results
I am new to Logic Apps, but fairly well-versed in Power Automate. In Power Automate I have a small child flow that I use as an error handler and call it from other flows to send me an email with a link to the failed flow run. I re-created this for my Logic Apps but I have run into a problem.
The Error Handler Logic App is triggered by an HTTP request that takes the outputs of the workflow() expression from the calling app. Within the error handler app I parse through the definition to build a clickable link back to the calling app run that failed.
When I was testing, the workflow() outputs from my ERROR_TESTER app looked like this:
{
"id": "/subscriptions/<SUBSCRIPTION ID>/resourceGroups/<RESOURCE GROUP NAME>/providers/Microsoft.Logic/workflows/ERROR_TESTER",
"name": "ERROR_TESTER",
"type": "Microsoft.Logic/workflows",
"location": "centralus",
"run": {
"id": "/subscriptions/<SUBSCRIPTION ID>/resourceGroups/<RESOURCE GROUP NAME>/providers/Microsoft.Logic/workflows/ERROR_TESTER/runs/<RUN ID>",
"name": "<RUN ID>",
"type": "Microsoft.Logic/workflows/runs"
}
}
I just caught an error from an actual app I was running. The link didn't work and on further inspection I realized that the failed app's workflow() outputs looked like this instead:
{
"id": "/workflows/<WORKFLOW ID>",
"name": "<LOGIC APP NAME>",
"type": "Microsoft.Logic/workflows",
"location": "centralus",
"run": {
"id": "/workflows/<WORKFLOW ID>/runs/<RUN ID>",
"name": "<RUN ID>",
"type": "Microsoft.Logic/workflows/runs"
}
}
Despite the other differences, I was using the "run.id" property to build the URL to the flow run. Now that it seems to be getting truncated my original error handler app doesn't work.
Can anyone enlighten me on why the outputs are so different and potentially how to fix or plan for the differing outputs?
1 Reply
The difference you are seeing comes from the two hosting models of Logic Apps. In Consumption (multi-tenant) Logic Apps, the workflow() function returns a fully qualified resource ID with subscription, resource group, and provider details. In Standard Logic Apps, the workflow() function returns a shorter, relative path (/workflows/<workflowId>). That’s why your error handler logic works in one case but not the other. To fix this, you are required to normalize the run identifiers or construct the portal URL differently depending on the hosting model.