简体   繁体   中英

Trivial Azure Logic App fails when installed via ARM template

I created a trivial Azure Logic App workflow using the designer. The trigger is an Outlook.com connector When_a_new_email_arrives_(V2) that triggers when an email arrives at the configured account with logicapp1 in the subject line.

There is a single action configured which uses another Outlook.com connector Send_an_email_(V2) . Both connectors use the same configured connection.

The workflow built in the designer works fine.

The Logic App and its connection are in a Resource Group by themselves. I export the app and connection from the Resource Group and then deploy it to a new Resource Group using the Azure CLI using the following commands:

az group create --name TestGroup1 --location uksouth
az deployment group create --resource-group TestGroup1 --template-file EmailIn-EmailOut.json

The logic app and its connection are correctly created in the new resource group and appear in the designer exactly the same as the original manually created app that works. The connection needs to be manually authenticated by opening it in the Azure Portal and entering the credentials, this is expected.

However the Logic App installed by the cli using the template does not respond to its trigger at all. Manually running the trigger from the Designer in the Azure Portal appears to just hang.

There is no indication given anywhere as to what is failing.

I've spent many hours Googling and trying various things, all to no avail. I don't know what else I can do to get to the bottom of this.

The complete template is included below. I would really appreciate any guidance at all.

{
    "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "connections_outlook_name": {
            "defaultValue": "outlook",
            "type": "String"
        },
        "workflows_EmailIn_EmailOut_name": {
            "defaultValue": "EmailIn-EmailOut",
            "type": "String"
        }
    },
    "variables": {},
    "resources": [
        {
            "type": "Microsoft.Web/connections",
            "apiVersion": "2016-06-01",
            "name": "[parameters('connections_outlook_name')]",
            "location": "uksouth",
            "kind": "V1",
            "properties": {
                "displayName": "Outlook.com",
                "api": {
                    "name": "[parameters('connections_outlook_name')]",
                    "displayName": "Outlook.com",
                    "description": "Outlook.com connector allows you to manage your mail, calendars, and contacts. You can perform various actions such as send mail, schedule meetings, add contacts, etc.",
                    "iconUri": "[concat('https://connectoricons-prod.azureedge.net/releases/v1.0.1559/1.0.1559.2723/', parameters('connections_outlook_name'), '/icon.png')]",
                    "brandColor": "#0078D4",
                    "id": "[concat('/subscriptions/d2e05926-6db6-4d9d-a091-6f4b5e03a2ec/providers/Microsoft.Web/locations/uksouth/managedApis/', parameters('connections_outlook_name'))]",
                    "type": "Microsoft.Web/locations/managedApis"
                }
            }
        },
        {
            "type": "Microsoft.Logic/workflows",
            "apiVersion": "2017-07-01",
            "name": "[parameters('workflows_EmailIn_EmailOut_name')]",
            "location": "uksouth",
            "dependsOn": [
                "[resourceId('Microsoft.Web/connections', parameters('connections_outlook_name'))]"
            ],
            "properties": {
                "state": "Enabled",
                "definition": {
                    "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
                    "contentVersion": "1.0.0.0",
                    "parameters": {
                        "$connections": {
                            "defaultValue": {},
                            "type": "Object"
                        }
                    },
                    "triggers": {
                        "When_a_new_email_arrives_(V2)": {
                            "splitOn": "@triggerBody()?['value']",
                            "type": "ApiConnectionNotification",
                            "inputs": {
                                "fetch": {
                                    "method": "get",
                                    "pathTemplate": {
                                        "template": "/v2/Mail/OnNewEmail"
                                    },
                                    "queries": {
                                        "folderPath": "Inbox",
                                        "subjectFilter": "logicapp1"
                                    }
                                },
                                "host": {
                                    "connection": {
                                        "name": "@parameters('$connections')['outlook']['connectionId']"
                                    }
                                },
                                "subscribe": {
                                    "body": {
                                        "NotificationUrl": "@{listCallbackUrl()}"
                                    },
                                    "method": "post",
                                    "pathTemplate": {
                                        "template": "/MailSubscriptionPoke/$subscriptions"
                                    },
                                    "queries": {
                                        "folderPath": "Inbox"
                                    }
                                }
                            }
                        }
                    },
                    "actions": {
                        "Send_an_email_(V2)": {
                            "runAfter": {},
                            "type": "ApiConnection",
                            "inputs": {
                                "body": {
                                    "Body": "<p>The logic app executed successfully.</p>",
                                    "Subject": "Logic App executed",
                                    "To": "neutrino_sunset@hotmail.com"
                                },
                                "host": {
                                    "connection": {
                                        "name": "@parameters('$connections')['outlook']['connectionId']"
                                    }
                                },
                                "method": "post",
                                "path": "/v2/Mail"
                            }
                        }
                    },
                    "outputs": {}
                },
                "parameters": {
                    "$connections": {
                        "value": {
                            "outlook": {
                                "connectionId": "[resourceId('Microsoft.Web/connections', parameters('connections_outlook_name'))]",
                                "connectionName": "outlook",
                                "id": "/subscriptions/d2e05926-6db6-4d9d-a091-6f4b5e03a2ec/providers/Microsoft.Web/locations/uksouth/managedApis/outlook"
                            }
                        }
                    }
                }
            }
        }
    ]
}

One work around would be that instead of defining the triggers and action in the Resource try defining them individually in the template

{
"definition": { 
        "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",

 "actions": {
   "Send_an_email_(V2)": {
"inputs": {
"body": {
"Body": "<p>&lt;p&gt;The logic app executed successfully.&lt;/p&gt;</p>",
"Subject": "Logic App executed",
"To": "neutrino_sunset@hotmail.com"
},
"host": {
"connection": {
"referenceName": "outlook"
}
},
"method": "post",
"path": "/v2/Mail"
},
"runAfter": {},
"type": "ApiConnection"
}
},
"contentVersion": "1.0.0.0",
"outputs": {},
"triggers": {
"When_a_new_email_arrives_(V2)": {
"inputs": {
"fetch": {
"method": "get",
"pathTemplate": {
"template": "/v2/Mail/OnNewEmail"
},
"queries": {
"fetchOnlyWithAttachment": false,
"folderPath": "Inbox",
"importance": "Any",
"includeAttachments": false,
"subjectFilter": "app"
}
},
"host": {
"connection": {
"referenceName": "outlook"
}
},
"subscribe": {
"body": {
"NotificationUrl": "@{listCallbackUrl()}"
},
"method": "post",
"pathTemplate": {
"template": "/MailSubscriptionPoke/$subscriptions"
},
"queries": {
"fetchOnlyWithAttachment": false,
"folderPath": "Inbox",
"importance": "Any"
}
}
},
"splitOn": "@triggerBody()?['value']",
"type": "ApiConnectionNotification"
} 
}
},
"kind": "Stateful"
}

Also along with this the logic app kind must be defined as stateful as the above triggers and actions are not available for stateless.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM