I’ve been having some issues with my Azure Function that monitors a blob storage. I’ve followed the tutorial here: https://learn.microsoft.com/en-us/azure/azure-functions/functions-event-grid-blob-trigger?pivots=programming-language-csharp
I have my Azure Function setup, my event grid webhook setup and my blob storage ready.
In application insights, I can see no errors for my app:
Then monitoring the event grid, I can see the uploads are triggered.
However, my Azure Function never triggers. I’m using the template code Visual Studio Code provides, the function also works fine when running locally.
Any suggestions on what I’m perhaps doing wrong, or someone that can point me in the right direction?
** UPDATE:
I’ve run the function locally too and set the webhook to route via ngrok. It runs as expected. So it does seem the issue seem to be the webhook receiving the information or the running of the Azure Function.
There is nothing or no errors on the logs at all. I’m not sure what else to do here. Any guidance on debugging would be appreciated.
My code looks as follows:
using System.IO;
using System.Threading.Tasks;
using Microsoft.Azure.Functions.Worker;
using Microsoft.Extensions.Logging;
namespace initroot.io
{
public class XXX
{
private readonly ILogger<XXX> _logger;
public XXXX(ILogger<XXX> logger)
{
_logger = logger;
}
[Function(nameof(XXXX))]
public async Task Run([BlobTrigger("XXXX/{name}", Source = BlobTriggerSource.EventGrid, Connection = "420bee_STORAGE")] Stream stream, string name)
{
using var blobStreamReader = new StreamReader(stream);
var content = await blobStreamReader.ReadToEndAsync();
_logger.LogInformation($"C# Blob Trigger (using Event Grid) processed blobn Name: {name} n Data: {content}");
}
}
}
When looking into the Azure Metric, I can see that each time I upload a new file, an instance is started for the Azure Function, indicating that the webhook is working. However, it seems the execution just never happens, or no output.
2
Answers
Just for anyone else that wants a full solution to read the blobs too. This is not using isolated runtimes.
Initially, I was also getting same issue. In this case while adding the type of blob events in event grid subscription blob trigger is not available.
For getting the same requirement I have created event grid trigger function with runtime stack .NET 8.0 isolated.
Function code:
I have deployed the function into azure portal successfully.
storage events
.When i uploaded or deleted the blobs in container function got triggered successfully. check below:
Event grid output:
Function output: