1
votes

I am trying to hook up my static site hosted on azure blob storage to an azure function (hosted in a docker container) via event grid. My plan is for the function to optimise images added to blob storage to reduce the file size.

I appreciate that its somewhat of a contrived example but I am looking to get some exposure to event grid & docker and this would be useful to me.

At the moment I am unable to connect event grid to my azure function. Adding a subscription to event grid from the function isn't available from the portal because its in a docker container.

I am following these steps from the microsoft guide on getting the function system key from the master key. (This is then later used in setting up the subscription)

When I hit the the link: http://<func-app>.azurewebsites.net/admin/host/systemkeys/eventgrid_extension?code=<master_key> I get a 404 (Same when using HTTPS).

I replaced the function app name and got the master_key from here (named _master): Azure functions app settings

I can only assume I am doing something wrong but I have no idea what, any help appreciated!

3

3 Answers

1
votes

There seems some problem about generating system keys for linux function. I did meet the same error, while on Windows everything works.

Workaround is to directly use master key to configure the endpoint, it worked like a charm on my side.

https://{functionappname}.azurewebsites.net/runtime/webhooks/eventgrid?functionName={functionname}&code={masterkey}
1
votes

Finally got to the bottom of this, there were 2 steps required to fix it:

  • Ensure that you are using the correct method signature. I had added an IActionResult as the return type to my function instead of this method signature: public static void EventGridTest([EventGridTrigger]EventGridEvent eventGridEvent, ILogger log) (Using async Task instead of void is also acceptable). With an incorrect signature the functions runtime failed to find a valid function signature, this error wasn't surfaced until I actually ran func host start at which point I got the following:
Microsoft.Azure.WebJobs.Host: Error indexing method '<funcName>'.
Microsoft.Azure.WebJobs.Host: Cannot bind parameter '$return' to type IActionResult&. Make sure the parameter Type is supported by the binding. If you're using binding extensions (e.g. Azure Storage, ServiceBus, Timers, etc.) make sure you've called the registration method for the extension(s) in your startup code (e.g. builder.AddAzureStorage(), builder.AddServiceBus(), builder.AddTimers(), etc.).
  • Secondly, the endpoint for getting a system key as described in the docs does not exist (Returns 404). As described by Jerry Liu https://stackoverflow.com/a/54763760/537821 using the '_master' key works in place of a system key.

So thanks both to Roman Kiss & Jerry Lui who helped me solve this.

0
votes

I have been experiencing the same issues. When deploying a FunctionApp with EventGridTriggers in a Docker container the eventgrid_extension key sometimes doesn't show up. Sometimes it shows up immediately, sometimes after couple of hours, sometimes never.

I noticed that even though the eventgrid_extension key is not shown in the Azure Portal, it is available in the Storage Blob associated with the FunctionApp.

Perhaps extracting the key directly from the blob may be used as a workaround.