skip to Main Content

I’m developing an Azure function which should trigger with blob events based on an Event Grid subscription as explained in the following article.

I’ve been able to go through all the steps in the tutorial but cannot successfully create the subscription for the events.

This is my function’s code:

[FunctionName(nameof(TrainingsCsvUploaded))]    
public async Task Run(
    [BlobTrigger("%AccessAzureStorage:ProfessionalDevelopmentContainerName%/{name}", 
    Source = BlobTriggerSource.EventGrid, 
    Connection = "AccessAzureStorage:ConnectionString")] Stream myBlob, 
    string name, ILogger log)   
{
    log.LogError("C# Blob trigger function Processed blob name: '{name}'", name);       

    var endpoint = await _bus.GetSendEndpoint(new Uri("queue:" + Configuration["AccessSystem-CommandQueueName"]));
    
    var command = new RefreshTrainingsInformationCommand() { BlobName = name };
    log.LogInformation("Queueing command {command}", command);
    await endpoint.Send(command);       
}

It is deployed and the requiered configuration settings are set.
Configuration

More over, the blob_extensions app key is set too.
App keys

And this is how I build the webhook URL to be provided when creating the subscription:
https://accesssystem-pre-01-fnapp.azurewebsites.net/runtime/webhooks/blobs?functionName=TrainingsCsvUploaded&code=<blob_extensions_key>

Now following the same steps in the tutorial I get the following message in the portal:

Error message

Clearly I’m missing something but I cannot figure out what, could you point me where the issue is?

Thanks in advance!
Best,

2

Answers


  1. Chosen as BEST ANSWER

    Posting the solution to my problem. There were some access rules set in the function app which were blocking the traffic. Because of that the POST request to register the subscription was blocked and the the handshake process was failing.


  2. Steps to configure Azure Blob Trigger in Event Subscription with WebHook Endpoint Type:

    • Create an Azure Function with a blob trigger in the Azure Function App.
    [FunctionName("BlobTriggerCSharp")]
    public static void Run([BlobTrigger("samples-workitems/{name}", Source = BlobTriggerSource.EventGrid, Connection = "<NAMED_STORAGE_CONNECTION>")]Stream myBlob, string name, ILogger log)
    {
        log.LogInformation($"C# Blob trigger function processed blobn Name:{name} n Size: {myBlob.Length} Bytes");
    }
    
    • Once the Azure Function is created, the URL that points to the function will be like below:

    https://<FUNCTION_APP_NAME>.azurewebsites.net/runtime/webhooks/blobs?functionName=<FUNCTION_NAME>&code=<BLOB_EXTENSION_KEY>

    You can find the BLOB_EXTENSION_KEY:

    • Open the Azure portal.
    • Select the function app you created or deployed from local to Azure.
    • Under the "Functions" section, click on "App keys".
    • Under "System keys", locate the key named "blobs_extension" and copy its "Value".

    enter image description here

    • Create Event Subscription:

    • Create the Event Grid Topic to which you want to subscribe and replace the URL.

    Enter image description here

    enter image description here

    enter image description here

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search