Trivial Azure Logic App fails when installed via ARM template - azure

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><p>The logic app executed successfully.</p></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 .

Related

Using Event Grid, is it possible to trigger a logic app when a resource is created/deleted in Azure?

I would like to know if using Event Grid, is it possible to have a logic app triggered when any resource is deployed on a Azure Subscription.
The use case is :
Somebody creates/deletes a resource on a particular Azure subscription
It sends a event in Event Grid (not sure about that ?)
A logic app is then triggered when such event occurs, this logic app will send notification in a Teams channel.
The goal here is to have a simple and basic helicopter view on what's happening on this sub.
For testing purposes, I've created a logic app and add a "When a resource event occurs" trigger with Microsoft.Resources.ResourceGroups and these event types :
Microsoft.Resources.ResourceActionSuccess
Microsoft.Resources.ResourceDeleteSuccess
Microsoft.Resources.ResourceWriteSuccess
Not sure I'm exploring here.
Then I've deployed a storageaccount, but I get notifications even when "Reviewing" the deployment just before the resource is actually deployed.
Once deployed, I also have random notifications (even if the storage account is not used, some kind of background activities I guess ?)
As per this Official documentation:
Resource events are created for PUT, PATCH, POST, and DELETE operations that are sent to management.azure.com. GET operations don't create events.
Hence you are receiving multiple triggers. For minimal triggers you can add the filters for the deployment. Below is the flow I'm using.
Below is the complete JSON of my logic app
{
"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>#{triggerBody()?['subject']} has been created</p>",
"Importance": "Normal",
"Subject": "xxx",
"To": "xxx"
},
"host": {
"connection": {
"name": "#parameters('$connections')['office365']['connectionId']"
}
},
"method": "post",
"path": "/v2/Mail"
},
"runAfter": {},
"type": "ApiConnection"
}
},
"contentVersion": "1.0.0.0",
"outputs": {},
"parameters": {
"$connections": {
"defaultValue": {},
"type": "Object"
}
},
"triggers": {
"When_a_resource_event_occurs": {
"conditions": [],
"inputs": {
"body": {
"properties": {
"destination": {
"endpointType": "webhook",
"properties": {
"endpointUrl": "#{listCallbackUrl()}"
}
},
"filter": {
"includedEventTypes": [
"Microsoft.Resources.ResourceDeleteSuccess",
"Microsoft.Resources.ResourceActionSuccess"
],
"subjectBeginsWith": "/subscriptions/xxx/resourceGroups/xxx/providers/Microsoft.Resources/deployments"
},
"topic": "/subscriptions/xxx/resourceGroups/xxx"
}
},
"host": {
"connection": {
"name": "#parameters('$connections')['azureeventgrid']['connectionId']"
}
},
"path": "/subscriptions/#{encodeURIComponent('b83c1ed3-c5b6-44fb-b5ba-2b83a074c23f')}/providers/#{encodeURIComponent('Microsoft.Resources.ResourceGroups')}/resource/eventSubscriptions",
"queries": {
"x-ms-api-version": "2017-09-15-preview"
}
},
"splitOn": "#triggerBody()",
"type": "ApiConnectionWebhook"
}
}
},
"parameters": {
"$connections": {
"value": {
"azureeventgrid": {
"connectionId": "/subscriptions/xxx/resourceGroups/xxx/providers/Microsoft.Web/connections/azureeventgrid",
"connectionName": "azureeventgrid",
"id": "/subscriptions/xxx/providers/Microsoft.Web/locations/eastus/managedApis/azureeventgrid"
},
"office365": {
"connectionId": "/subscriptions/xxx/resourceGroups/xxx/providers/Microsoft.Web/connections/office365",
"connectionName": "office365",
"id": "/subscriptions/xxx/providers/Microsoft.Web/locations/eastus/managedApis/office365"
}
}
}
}
}
RESULTS:

Create a child resource by ARM connector in Logic App

How can you create a child resource (e.g. container for Blob Storage, or consumer group for Eventhub) using Logic App?
To create a resource with the ARM connector in Logic App, you need to specify provider and short resource id which are used to construct the path to the new service. However, they do not correspond to the "type" and "name" parameters from ARM template (which would be in the example "Microsoft.Eventhub/namespaces" and "vvtesteventhub").
"inputs": {
"body": {...},
"host": {
"connection": {
"name": "#parameters('$connections')['arm']['connectionId']"
}
},
"method": "put",
"path": "/subscriptions/#{variables('subscriptionId')}/resourcegroups/#{variables('resourceGroup')}/providers/Microsoft.EventHub/namespaces/vvtesteventhub",
"queries": {
"x-ms-api-version": "2021-06-01-preview"
}
}
For a child resource, it is necessary to somehow construct the full path including the parent resource name. However, I am not able to construct it even when editing the directly through the code view (see below). The run fails with error message "Resource not found", despite the fact that it includes the correct path to the existing eventhub where I want to create the consumer group.
{
"inputs": {
"host": {
"connection": {
"name": "#parameters('$connections')['arm']['connectionId']"
}
},
"method": "put",
"path": "/subscriptions/#{variables('subscriptionId')}/resourcegroups/#{variables('resourceGroup')}/providers/Microsoft.EventHub/namespaces/eventhubs/#{variables('eventhubNamespacesName')}/#{variables('eventhubName')}/consumergroups/#{variables('platformName')}",
"queries": {
"x-ms-api-version": "2021-06-01-preview"
}
}
}
We have tested this in our local environment it is working fine, Below statements are based on the analysis.
In our local environment, we have created an event hub Namespace & a logic app.
Using logic app Azure resource Manager connector actions Create or Update a Resource we are able to create EventHub & followed it by a consumer group in it.
Here is the logic app :
Here is the code view of the logic app:
{
"definition": {
"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
"actions": {
"Compose": {
"inputs": "Microsoft.EventHub/namespaces",
"runAfter": {},
"type": "Compose"
},
"Create_a_ConsumerGroup_to_existing_EventHub": {
"inputs": {
"body": {
"location": "westus"
},
"host": {
"connection": {
"name": "#parameters('$connections')['arm']['connectionId']"
}
},
"method": "put",
"path": "/subscriptions/#{encodeURIComponent('<sub-id>')}/resourcegroups/#{encodeURIComponent('<rgName>')}/providers/#{encodeURIComponent(outputs('Compose'))}/#{encodeURIComponent('/<EventHubNamespacesName>/eventhubs/<EventHubName>/consumergroups/<ConsumerGroupName>')}",
"queries": {
"x-ms-api-version": "2021-11-01"
}
},
"runAfter": {
"Creates_a_EventHub_to_existing_EventHubNamespaces_": [
"Succeeded"
]
},
"type": "ApiConnection"
},
"Creates_a_EventHub_to_existing_EventHubNamespaces_": {
"inputs": {
"body": {
"location": "westus"
},
"host": {
"connection": {
"name": "#parameters('$connections')['arm']['connectionId']"
}
},
"method": "put",
"path": "/subscriptions/#{encodeURIComponent('<sub-id>')}/resourcegroups/#{encodeURIComponent('<rgName>')}/providers/#{encodeURIComponent(outputs('Compose'))}/#{encodeURIComponent('/<EventHubNamespacesName>/eventhubs/<EventHubName>')}",
"queries": {
"x-ms-api-version": "2021-11-01"
}
},
"runAfter": {
"Compose": [
"Succeeded"
]
},
"type": "ApiConnection"
}
},
"contentVersion": "1.0.0.0",
"outputs": {},
"parameters": {
"$connections": {
"defaultValue": {},
"type": "Object"
}
},
"triggers": {
"Recurrence": {
"recurrence": {
"frequency": "Hour",
"interval": 3
},
"type": "Recurrence"
}
}
},
"parameters": {
"$connections": {
"value": {
"arm": {
"connectionId": "/subscriptions/<sub-id>/resourceGroups/<rgName>/providers/Microsoft.Web/connections/arm",
"connectionName": "arm",
"id": "/subscriptions/<sub-id>/providers/Microsoft.Web/locations/eastus/managedApis/arm"
}
}
}
}
}
Here is the sample output for reference:
Note:
In order to create a consumer group to EventHub you need to have an existing EventHub or you Need to create a New Event Hub.

How to create ARM template for logic App with API connection to Gmail?

{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"logicAppName": {
"type": "string",
"defaultValue": "la-send-mail",
"metadata": {
"description": "Name of the Logic App."
}
},
"logicAppLocation": {
"type": "string",
"defaultValue": "[resourceGroup().location]",
"metadata": {
"description": "Location of the Logic App."
}
},
"gmail_name": {
"type": "string",
"defaultValue": "gmail"
},
"gmail_displayName": {
"type": "string",
"defaultValue": "roman.dovhanyk#gmail.com"
}
},
"variables": {},
"resources": [
{
"type": "Microsoft.Logic/workflows",
"apiVersion": "2016-06-01",
"name": "[parameters('logicAppName')]",
"location": "[parameters('logicAppLocation')]",
"dependsOn": [
"[resourceId('Microsoft.Web/connections', parameters('gmail_name'))]"
],
"properties": {
"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": {
"manual": {
"type": "Request",
"kind": "Http",
"inputs": {
"schema": {
"properties": {
"body": {
"type": "string"
},
"bodyHTML": {
"type": "string"
},
"ccAddress": {
"type": "string"
},
"color": {
"type": "string"
},
"datafactoryName": {
"type": "string"
},
"pipelineName": {
"type": "string"
},
"pipelineRunId": {
"type": "string"
},
"time": {
"type": "string"
},
"title": {
"type": "string"
},
"toAddress": {
"type": "string"
}
},
"type": "object"
}
}
}
},
"actions": {
"Initialize_variable": {
"runAfter": {},
"type": "InitializeVariable",
"inputs": {
"variables": [
{
"name": "HTMLBody",
"type": "string",
"value": "<div>\n<h1 style=\"Color:#{triggerBody()?['color']};\"> Executed successfully </h1>\n<hr/>\nData Factory Name: <b>#{triggerBody()?['datafactoryName']}</b><br/>\nPipeline Name: <b>#{triggerBody()?['pipelineName']}</b><br/>\nPipeline Run Id<b>#{triggerBody()?['pipelineRunId']}</b><br/>\nTime: <b>#{triggerBody()?['time']}</b><br/>\n<hr/>\n<p>#{triggerBody()?['body']}</p>\n<div>#{triggerBody()?['bodyHTML']}</div>\n</div>"
}
]
}
},
"Send_email_(V2)": {
"runAfter": {
"Initialize_variable": [
"Succeeded"
]
},
"type": "ApiConnection",
"inputs": {
"body": {
"Body": "<p>#{variables('HTMLBody')}</p>",
"Cc": "#triggerBody()?['ccAddress']",
"Subject": "#triggerBody()?['title']",
"To": "#triggerBody()?['toAddress']"
},
"host": {
"connection": {
"name": "#parameters('$connections')['gmail']['connectionId']"
}
},
"method": "post",
"path": "/v2/Mail"
}
}
},
"outputs": {}
},
"parameters": {
"$connections": {
"value": {
"gmail": {
"id": "[concat('/subscriptions/',subscription().subscriptionId,'/providers/Microsoft.Web/locations/',parameters('logicAppLocation'),'/managedApis/gmail')]",
"connectionId": "[resourceId('Microsoft.Web/connections', parameters('gmail_name'))]",
"connectionName": "[parameters('gmail_name')]"
}
}
}
}
}
},
{
"type": "Microsoft.Web/connections",
"apiVersion": "2016-06-01",
"location": "[parameters('logicAppLocation')]",
"name": "[parameters('gmail_name')]",
"properties": {
"api": {
"id": "[concat('/subscriptions/',subscription().subscriptionId,'/providers/Microsoft.Web/locations/',parameters('logicAppLocation'),'/managedApis/gmail')]"
},
"displayName": "[parameters('gmail_displayName')]"
}
}
],
"outputs": {}
}
This is the template I use, it always gives the
"The deployment 'la-send-mail-1_2' failed with error(s). Showing 1 out of 1 error(s). Status Message: The operation on workflow 'la-send-mail' cannot be completed because it contains connections to 'gmail' connector which are not valid. Please re-authorize the connections and try again. (Code:GmailConnectorPolicyViolation)" error
I am run deployment from simple PowerShell script.
Could someone help me to fix this issue
Thank you Thomas. Posting your suggestions as an answer to help other community members.
The Authorize document will help you in authorizing the OAuth connections.
Manually authorize OAuth connections by opening your logic app in Logic App Designer, either in the Azure portal or in Visual Studio. When you authorize your connection, a confirmation page might appear for you to allow access.
For Oauth connection to ARM template you need to script it. But the easiest way is to create manually these connection then deploy ARM.
Refer Logic App Connection Auth Document for further information.
This script will retrieve a consent link for a connection (and can also create the connection at the same time) for an OAuth Logic Apps connector. It will then open the consent link and complete authorization to enable a connection. This can be used after deployment of connections to make sure a Logic App is working end-to-end.

Getting Error while trying to initiate Logic App Trigger

I am trying to configure a Logic App using Event Grid Trigger. The Trigger should be when my Azure CMK in my key vault is nearing expiry it should send me an email. I have configured the Logic App using the Logic App Designer, but when i try to run the trigger, it throws me the error as shown in the screenshot.
The screenshot for my designer is also attached. Any idea what do i need to do to fix this[![enter image description here][3]][3]
Also putting the code here for reference.
{
"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>Your CMK will expire in 30 days</p>",
"ReplyTo": "myemailaddress ",
"Subject": "Key Expiry",
"To": "myemailaddress"
},
"host": {
"connection": {
"name": "#parameters('$connections')['outlook']['connectionId']"
}
},
"method": "post",
"path": "/v2/Mail"
},
"runAfter": {},
"type": "ApiConnection"
}
},
"contentVersion": "1.0.0.0",
"outputs": {},
"parameters": {
"$connections": {
"defaultValue": {},
"type": "Object"
}
},
"triggers": {
"When_a_resource_event_occurs": {
"inputs": {
"body": {
"properties": {
"destination": {
"endpointType": "webhook",
"properties": {
"endpointUrl": "#{listCallbackUrl()}"
}
},
"filter": {
"includedEventTypes": [
"Microsoft.KeyVault.KeyNearExpiry"
]
},
"topic": "/subscriptions/<subscriptionid>/resourceGroups/pallabdev/providers/Microsoft.KeyVault/vaults/testhalvault"
}
},
"host": {
"connection": {
"name": "#parameters('$connections')['azureeventgrid_1']['connectionId']"
}
},
"path": "/subscriptions/#{encodeURIComponent('subscriptionId')}/providers/#{encodeURIComponent('Microsoft.KeyVault.vaults')}/resource/eventSubscriptions",
"queries": {
"x-ms-api-version": "2017-06-15-preview"
}
},
"splitOn": "#triggerBody()",
"type": "ApiConnectionWebhook"
}
}
},
"parameters": {
"$connections": {
"value": {
"azureeventgrid_1": {
"connectionId": "/subscriptions/<subscriptionId>/resourceGroups/PallabDev/providers/Microsoft.Web/connections/azureeventgrid",
"connectionName": "azureeventgrid",
"connectionProperties": {
"authentication": {
"type": "ManagedServiceIdentity"
}
},
"id": "/subscriptions/<subscriptionId>/providers/Microsoft.Web/locations/canadacentral/managedApis/azureeventgrid"
},
"outlook": {
"connectionId": "/subscriptions/<subscriptionId>/resourceGroups/PallabDev/providers/Microsoft.Web/connections/outlook",
"connectionName": "outlook",
"id": "/subscriptions/<subscriptionId>/providers/Microsoft.Web/locations/canadacentral/managedApis/outlook"
}
}
}
}
}
The reason is that the triggerbody is null, it needs to be an array, if it is null, it will cause your error.
According to the discussion in the comment area, turning off Split On can avoid this error.

Azure Logic App not sending Attachments to slack

Using Logic App in Azure to post message to slack. This works fine with standard text message.
When I change to also post attachment nothing gets sent:
"inputs": {
"host": {
"connection": {
"name": "#parameters('$connections')['slack']['connectionId']"
}
},
"method": "post",
"path": "/chat.postMessage",
"queries": {
"attachments": [
{
"color": "danger",
"fallback": "Azure alert attachment.",
"fields": [
{
"title": "Check list"
},
{
"value": "Check services on VM0 and VM1"
},
{
"value": "If you cannot fix this issue make sure someone else can"
}
],
"pretext": "<!channel> Action required",
"text": "`'#{triggerBody()['context']['name']}'` API down - '#{triggerBody()['context']['resourceName']}' Details: #{body('Http')['id']}",
"ts": 123456789
}
],
"channel": "#devops",
"text": "SYST ALERT"
}
}
Looking into this, it seems that Logic Apps does not support Attachment type. Please upvote in uservoice #
https://feedback.azure.com/forums/287593-logic-apps/suggestions/31896379-add-support-for-attachments-with-slack-post-messag
So with that being the case, how do we do this today. Slack Supports Incoming Webhooks as well as APIs. I enabled this in Logic Apps using chat.PostMessage API for more details on the API look at :
https://api.slack.com/methods/chat.postMessage/test
The basic problem in this approach is the requirement for a token, in my sample i used a test token from
https://api.slack.com/custom-integrations/legacy-tokens
This isn't the best approach (but i was having some issues using the Incoming WebHook will continue trying that approach and post if i have success there) from a Security PoV but does get the Job done. Final working code is as following :
{
"$connections": {
"value": {
"office365": {
"connectionId": "<ConnectionID",
"connectionName": "office365",
"id": "<ID>"
}
}
},
"definition": {
"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
"actions": {
"Condition_3": {
"actions": {
"HTTP": {
"inputs": {
"body": "?token=<Token>&channel=C8270DY6L&attachments=%5B%7B%22fallback%22%3A%22Requiredplain-textsummaryoftheattachment.%22%2C%22color%22%3A%22%2336a64f%22%2C%22pretext%22%3A%22Optionaltextthatappearsabovetheattachmentblock%22%2C%22author_name%22%3A%22BobbyTables%22%2C%22author_link%22%3A%22http%3A%2F%2Fflickr.com%2Fbobby%2F%22%2C%22author_icon%22%3A%22http%3A%2F%2Fflickr.com%2Ficons%2Fbobby.jpg%22%2C%22title%22%3A%22SlackAPIDocumentation%22%2C%22title_link%22%3A%22https%3A%2F%2Fapi.slack.com%2F%22%2C%22text%22%3A%22Optionaltextthatappearswithintheattachment%22%2C%22fields%22%3A%5B%7B%22title%22%3A%22Priority%22%2C%22value%22%3A%22High%22%2C%22short%22%3Afalse%7D%5D%2C%22image_url%22%3A%22http%3A%2F%2Fmy-website.com%2Fpath%2Fto%2Fimage.jpg%22%2C%22thumb_url%22%3A%22http%3A%2F%2Fexample.com%2Fpath%2Fto%2Fthumb.png%22%2C%22footer%22%3A%22SlackAPI%22%2C%22footer_icon%22%3A%22https%3A%2F%2Fplatform.slack-edge.com%2Fimg%2Fdefault_application_icon.png%22%2C%22ts%22%3A123456789%7D%5D&pretty=1",
"method": "POST",
"uri": "https://slack.com/api/chat.postMessage"
},
"runAfter": {},
"type": "Http"
}
},
"expression": "#equals(triggerBody()?['HasAttachment'], True)",
"runAfter": {},
"type": "If"
}
},
"contentVersion": "1.0.0.0",
"outputs": {},
"parameters": {
"$connections": {
"defaultValue": {},
"type": "Object"
}
},
"triggers": {
"When_a_new_email_arrives": {
"inputs": {
"host": {
"connection": {
"name": "#parameters('$connections')['office365']['connectionId']"
}
},
"method": "get",
"path": "/Mail/OnNewEmail",
"queries": {
"folderPath": "Inbox",
"importance": "Normal"
}
},
"recurrence": {
"frequency": "Minute",
"interval": 3
},
"splitOn": "#triggerBody()?['value']",
"type": "ApiConnection"
}
}
}
}

Resources