0
votes

I've got an Azure Logic App that I want to run whenever a file is uploaded to a specific Azure Storage Account. The Logic App is deployed via an ARM template (which has also been configured to create the Event Grid and Blob Storage API connections).

When I deploy the ARM template, the Event Grid trigger isn't working as there's no event subscription in the Azure Storage Account.

FYI., I can get event subscriptions to work if I create a Logic App via the quick start option i.e. from my Azure Storage Account under Events > Get Started > Logic Apps > When a new blob is uploaded > Create.

^^ This creates a new Logic App with an Azure Event Grid trigger (When a resource event occurs), but I actually want to create/link the event subscription to an existing Logic App i.e. the one that I deployed via the ARM template, and I want to be able to automate this.

If I reverse engineer the event subscription that was created by the Logic App quick start; I can see it's got an endpoint type of WebHook with an endpoint of the form {logic-app-access-endpoint}/triggers/{name-of-trigger}/versions/{logic-app-version}/run. I can reconstruct this to something like the following by getting the params from my Logic App:

https://prod-24.australiaeast.logic.azure.com:443/workflows/12433cc68f0e916dc3048c1775333506/triggers/When_blah_blah_blah/versions/12345678901234567890/run

I can enter the Subscriber Endpoint and Confirm Selection, but when I try to create it; I'm getting the following error:

Deploying Event Subscription: Test123
Deployment has failed with the following error: {"code":"Url validation","message":"The attempt to validate the provided endpoint https://prod-24.australiaeast.logic.azure.com:443/workflows/12433cc68f0e916dc3048c1775333506/triggers/When_blah_blah_blah/versions/12345678901234567890/run failed. For more details, visit https://aka.ms/esvalidation."

What's strange is if I go into my logic app and change the event grid connection to a different one (but with the exact same properties) and then save my logic app; I can then create my event grid subscription without the error. It seems a bit temperamental...

I've tried a few things such as authorizing my event grid API connection, but it doesn't work...

Does anyone know if how set up event grid subscriptions to an existing Logic App without the errors / temperamental behavior... also how would one go about automating the creation of the event grid subscriptions (given there's some dynamic properties such as the logic app version).

TIA - Ryan.

1

1 Answers

1
votes

It looks like your Logic App trigger endpoint is a bit off. It should look something like this:

https://prod-24.australiaeast.logic.azure.com:443/workflows/12433cc68f0e916dc3048c1775333506/triggers/When_blah_blah_blah/paths/invoke?api-version=2016-10-01&sp=%2Ftriggers% When_blah_blah_blah%2Frun&sv=1.0&sig=1234567890abcdefghij

You can find the exact value by clicking See trigger history from your Logic App overview blade.

From the ARM template automated deployment standpoint, you can get the trigger endpoint using the following code:

[listCallbackUrl(concat(resourceId('Microsoft.Logic/workflows',variables('myLogicAppName')),'/triggers/When_blah_blah_blah'), '2016-10-01').value]

I highly recommend either deploying your Logic App and Event Grid subscriptions together or adding a "Logic App was changed" trigger to your Event Grid subscription deployment. You'll need this in case your Logic App trigger endpoint changes which should only happen at deployment time (friends don't let friends save in the portal).