Event Grid Trigger: Validation handshake Failed on Event subscription deployment
Published Jun 04 2024 07:57 AM 735 Views
Microsoft

Symptom:

In logic app standard, you might face the issue of being unable to create the event grid subscription with endpoint type=webhook where the URL refers to logic app workflow that has event grid trigger When a resource event occurs, below error on saving event subscription will appear:

Deployment has failed with the following error: {"code":"Url validation","message":"Webhook validation handshake failed Http POST request retuned 2XX response with response body . When a validation request is accepted without validation code in the response body, Http GET is expected on the validation url included in the validation event(within 10 minutes). For troubleshooting, visit

https://aka.ms/esvalidation.

 

Cause:

If you work from outside logic app designer on creating event grid subscription or editing it such as adding a filter or advanced filter to the event subscription, a validation request is sent to the configured event subscription web hook URL but logic app standard workflow with event grid trigger fails to respond back by invoking validation URL, and the event subscription will fail to be deployed.

However, if you try the same through logic app designer, logic app workflow with this event grid trigger is able to create the event subscription and complete the validation on saving the workflow with this trigger and using the values inside the trigger parameters for event subscription name and basic subject filters

Ibrahim_Ali81_1-1717510135686.png

 

 

 

Resolution:

Adding below condition in the workflow to check if the received event is subscription validation by checking the existence of validation URL in the incoming event body and invoking this validation URL

code:

{

  "type": "If",

  "expression": {

    "and": [

      {

        "not": {

          "equals": [

            "@triggerOutputs()?['body']?['data']?['validationCode']",

            "@null"

          ]

        }

      }

    ]

  },

  "actions": {

    "Handshake_Validation_": {

      "type": "Http",

      "inputs": {

        "uri": "@triggerOutputs()?['body']?['data']?['validationUrl']",

        "method": "GET",

        "headers": {

          "WebHook-Request-Origin": "WF7"

        }

      }

    }

  },

  "else": {

    "actions": {}

  },

  "runAfter": {}

}

 

designer view

 

 

Ibrahim_Ali81_0-1717507444291.png

 

Note:

 

Another recommended option is to use When http request is received trigger to set the event grid subscription web hook URL to the trigger URL. When http request is received trigger is in-app trigger, so its run cost is included by the app service plan fees while when a resource event grid trigger is shared trigger whose usage fees depends on the number of its calls. please refer to the link below for more information of how to use When http request is received trigger with event grid subscription:

Using Single Tenant Logic App workflow endpoint as Event Grid Subscription - Microsoft Community Hu...

 

 

 

 

Co-Authors
Version history
Last update:
‎Jun 04 2024 08:02 AM
Updated by: