Azure / logicapps

Azure Logic Apps labs, samples, and tools
MIT License
348 stars 291 forks source link

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

Open sbarkeratos opened 2 months ago

sbarkeratos commented 2 months ago

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

mikko-kunnari commented 2 months ago

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 commented 2 months ago

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 commented 2 months ago

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 commented 2 months ago

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 commented 1 month ago

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.

github-actions[bot] commented 1 week ago

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