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.