Hi, Hello!
I'm having an Event Grid that is targeting Azure Functions with slots on consumption plans.
Deployment process looks like this:
- Deploy application to slot.
- Swap slots.
- Use ARM template to create/update EG subscriptions.
At first in the ARM templates we had
"properties.destination.endpointType": "AzureFunction"
"properties.destination.properties.resourceId": "[resourceId(...)]"
However it appears that ARM templates do not update Function system key for Event Grid, so every other deployment we got Unauthrized errors when EG was trying to deliver event.
So we decided to change to use webhooks
"properties.destination.endpointType": "Webhook"
"properties.destination.properties.endpointUrl": [concat(variables('ingestVehicleFunction_function_url'), listKeys(resourceId(variables('resource_groups_data_name'), 'Microsoft.Web/sites/host/', variables('functions_company_data_name'), 'default'),'2016-08-01').systemkeys.eventgrid_extension)]"
but some of EG Subscriptions throws errors for handshakes
2021-05-26T09:19:01.7281161Z ##[error]Url validation: Webhook validation handshake failed for https://myfunction.azurewebsites.net/runtime/webhooks/EventGrid. Http POST request failed with response code Unknown. For troublehooting, visit https://aka.ms/esvalidation. Activity id:2111b58f-c9f4-4ba8-96ac-530289c5c6f2, timestamp: 5/26/2021 9:18:43 AM (UTC).
"Funny" thing is that this occurs only when ARM template is deployed in DevOps Releases, sometimes for one function, sometimes for all - no consistency here ;(
When I run the template locally no issues are there.
What is the most convenient way to make EG subscription to Azure Function when swap of the AF slots changes host keys?
Or
What is going on with those ARM templates?