Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot set the workflow.id attribute for a Logic App HTTP request trigger for a Logic App calling another Logic App via Bicep files #1045

Closed
sbarkeratos opened this issue Apr 23, 2024 · 10 comments
Labels

Comments

@sbarkeratos
Copy link

sbarkeratos commented Apr 23, 2024

Describe the Bug with repro steps

I'm trying to deploy a parent-child logic app hierarchy via bicep files deployed from an Azure DevOps pipeline.

In the bicep file for the parent Logic App, include this section in the JSON to configure the trigger in the child logic app:

"name_of_trigger_in_child_logic_app": {
"inputs": {
"body": "@Body('name_of_item')",
"host": {
"triggerName": "name_of_trigger",
"workflow": {
"id": "/subscriptions/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/resourceGroups/rg_name/providers/Microsoft.Logic/workflows/child_logic_app_name"
}
}
}

If I hard code the subscription Id in the string it works fine, but when I try and pass using a variable I get the following error message:

{
"status": "Failed",
"error": {
"code": "DeploymentFailed",
"target": "/subscriptions/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/providers/Microsoft.Resources/deployments/main",
"message": "At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/arm-deployment-operations for usage details.",
"details": [
{
"code": "ResourceDeploymentFailure",
"target": "/subscriptions/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/resourceGroups/rg_name/providers/Microsoft.Resources/deployments/child_logic_app_name",
"message": "The resource write operation failed to complete successfully, because it reached terminal provisioning state 'Failed'.",
"details": [
{
"code": "DeploymentFailed",
"target": "/subscriptions/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/resourceGroups/rg_name/providers/Microsoft.Resources/deployments/child_logic_app_name",
"message": "At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/arm-deployment-operations for usage details.",
"details": [
{
"code": "LinkedInvalidPropertyId",
"message": "Property id '@encodeURIComponent(parameters('parameter_name'))' at path 'properties.definition.actions.Process_Users.actions.Loop_over_messages.actions.Get_latest_user_work_relationship_item.inputs.host.workflow.id' is invalid. Expect fully qualified resource Id that start with '/subscriptions/{subscriptionId}' or '/providers/{resourceProviderNamespace}/'."
}
]
}
]
}
]
}
}

I've tried to deploy this using a parameter but it won't work.

What type of Logic App Is this happening in?

Consumption (Portal)

Are you using new designer or old designer

New Designer

Did you refer to the TSG before filing this issue? https://aka.ms/lauxtsg

Yes

Workflow JSON

No response

Screenshots or Videos

No response

Browser

Edge

Additional context

No response

AB#27782888

@hartra344 hartra344 transferred this issue from Azure/LogicAppsUX Apr 23, 2024
@mikko-kunnari
Copy link

mikko-kunnari commented Apr 30, 2024

Hi, I have done this recently so I guess you just have some issue with the template itself. I used:

`resource OtherLogicApp 'Microsoft.Logic/workflows@2019-05-01' existing = {
name: otherLogicAppName
}

resource LogicApp... {
...
workFlow: {
id: OtherLogicApp.id
}
...
`

@sbarkeratos
Copy link
Author

Hi @mikko-kunnari - thanks very much for getting back to me on this.

This looks like it could be the answer, but I'm struggling to understand how you would access the ID of an action in the bicep file. Can you expand on the '...' so I can see how you'd access the particular action and it's properties please.

Thanks,

Steve.

@mikko-kunnari
Copy link

Sure thing. I'm not sure what you mean by ID of an action. You would give resource ID of the Logic App (workflow) and name of the trigger in that Logic App.

resource LogicApp 'Microsoft.Logic/workflows@2019-05-01' = {
name: logicAppName
location: location
properties: {
state: 'Enabled'
definition: {
'$schema': 'https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#'
contentVersion: '1.0.0.0'
outputs: {}
parameters: {}
triggers: {}
actions: {
'call_other_logic_app': {
inputs: {
host: {
triggerName: 'When_a_HTTP_request_is_received'
workFlow: {
id: LogicApp.id
}
}
}
type: 'Workflow'
runAfter: {}
}
...

@sbarkeratos
Copy link
Author

Ah! I see how you've done it - you're hard coding the JSON directly into the bicep file. Our logic apps are a little big for that so we're storing them separately in .json files and reading them in using loadJsonContent('{path}'). The approach you listed won't work in our case. The work around I currently have is to do a find and replace on the JSON files before I add them to the bicep files but it's not ideal. I've got a case open with MS to fix the bug I'm experiencing.

@mikko-kunnari
Copy link

I use bicep CLI to decompile the JSON file to bicep and use it as a bicep file. And I also use Logic Apps only as an orchestrator and Functions for any actual "logic" to keep Logic Apps simple. But yeah I agree working with Logic Apps as "code" (in my opinion JSON is not even code) is far from ideal.

Copy link

This issue is stale because it has been open for 45 days with no activity.

@github-actions github-actions bot added the stale label Jun 20, 2024
Copy link

github-actions bot commented Jul 4, 2024

This issue was closed because it has been inactive for 14 days since being marked as stale.

@github-actions github-actions bot closed this as completed Jul 4, 2024
@sbarkeratos
Copy link
Author

I think this should be re-opened because there is no good resolution at present.

@lambrianmsft
Copy link

lambrianmsft commented Aug 1, 2024

@sbarkeratos

Here is an example of how you can do the replacement for your specific case. If you need to do other replacements, you would need to nest the replace function call like the following:

(replace(replace(<original>, <old1>, <new1>), <old2>, <new2>))

testfile.json
parentla.bicep.txt

@sbarkeratos
Copy link
Author

sbarkeratos commented Aug 6, 2024

We have quite a lot of child logic apps being called by some parents, so the nesting approach gets messy quickly!

We've gone for this structure:

var rawText = {get JSON text from source file}

var editedText1 = replace(rawText, "{placeholder 1}", "{constructed child logic app URL 1}")
var editedText2 = replace(editedText1, "{placeholder 2}", "{constructed child logic app URL 2}")
var editedText3 = replace(editedText2, "{placeholder 3}", "{constructed child logic app URL 3}")
...
var editedText10 = replace(editedText9, "{placeholder 10}", "{constructed child logic app URL 10}")

// Load the JSON (with find and replaces completed) into the logic app:
logicApp....definition = editedText10

This is bit of a pain though, because if one uses the logic app designer to generate the JSON and then copy it into VS Code ready to check-in and push through CI/CD pipeline, one first has to remember to replace all the hard-coded child logic app URLs from the designer with the placeholders, so that the above "find-and-replace-in-the-bicep-files" approach will work. As you can imagine, this is pretty time consuming.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants