Unable to subscribe to storage event in standard logic app workflow

214 views Asked by At

I am trying to subscribe to storage account (Blob Created ) event using the event grid connector (Workflow URL) in the standard logic app and it fails with the below error. However, if i use the same connector in consumption logic app it works fine.

Error

Event Grid Connector

1

There are 1 answers

1
Ikhtesam Afrin On BEST ANSWER

I have create a workflow using When a resource event occurs trigger and got the same error alike you.

However, if i use the same connector in consumption logic app it works fine.

Yes, In consumption logic app it will work because the validation happens internally but as given in this blog, you need to explicitly validate the subscription handshake in order to receive the events in standard logic app.

enter image description here

Then I modified my workflow as below and it started working for me.

enter image description here

It will check for event type Microsoft.EventGrid.SubscriptionValidationEvent which will be received at the time of event creation.

enter image description here

Below step is added for handshake validation.

enter image description here

Code:

{
    "definition": {
        "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
        "actions": {
            "Condition": {
                "actions": {
                    "HTTP": {
                        "inputs": {
                            "body": "@triggerBody()?['data']?['validationCode']",
                            "method": "POST",
                            "uri": "@{triggerBody()?['data']?['validationUrl']}"
                        },
                        "runtimeConfiguration": {
                            "contentTransfer": {
                                "transferMode": "Chunked"
                            }
                        },
                        "type": "Http"
                    }
                },
                "else": {
                    "actions": { }
                },
                "expression": {
                    "and": [
                        {
                        "equals": [
                                "@triggerBody()?['eventType']",
                                "Microsoft.EventGrid.SubscriptionValidationEvent"
                            ]
                        }
                    ]
                },
                "runAfter": { },
                "type": "If"
            },
            "Send_an_email_(V2)": {
                "inputs": {
                    "body": {
                        "Body": "<p>@{triggerBody()?['data']}</p>",
                        "Importance": "Normal",
                        "Subject": "Blob Created",
                        "To": "***********.com"
                    },
                    "host": {
                        "connection": {
                            "referenceName": "office365"
                        }
                    },
                    "method": "post",
                    "path": "/v2/Mail"
                },
                "runAfter": {
                    "Condition": [
                        "SUCCEEDED"
                    ]
                },
                "type": "ApiConnection"
            }
        },
        "contentVersion": "1.0.0.0",
        "outputs": { },
        "triggers": {
            "When_a_resource_event_occurs": {
                "inputs": {
                    "body": {
                        "properties": {
                            "destination": {
                                "endpointType": "webhook",
                                "properties": {
                                    "endpointUrl": "@{listCallbackUrl()}"
                                }
                            },
                            "filter": {
                                "includedEventTypes": [
                                    "Microsoft.Storage.BlobCreated"
                                ]
                            },
                            "topic": "afreenstorage"
                        }
                    },
                    "host": {
                        "connection": {
                            "referenceName": "azureeventgrid"
                        }
                    },
                    "path": "/subscriptions/@{encodeURIComponent('*********')}/providers/@{encodeURIComponent('Microsoft.Storage.StorageAccounts')}/resource/eventSubscriptions",
                    "queries": {
                        "x-ms-api-version": "2017-09-15-preview"
                    }
                },
                "splitOn": "@triggerBody()",
                "type": "ApiConnectionWebhook"
            }
        }
    },
    "kind": "Stateful"
}

Then I created the event by using the below URL-

enter image description here

Event Creation:

enter image description here

enter image description here

Output:

enter image description here

Please ensure to add all the actions in your workflow specifically the handshake validation condition action then create the event.