VS Azure Function Blob Trigger does not fire

Karn Dalmia 0 Reputation points Microsoft Employee
2025-02-07T02:27:36.99+00:00

When I configured an Azure Function on VS code, it did not fire whenever there was a change in blob storage in my PBIZeroTouchBlob.cs file, which was tested in three different locations - same directory as PBIZeroTouchBlob.cs file, Azure Storage Emulator directory, and Azure Storage directory. I'm also not quite sure where the blob-container is located. Is in on my local machine or storage explorer ?

Attached is my PBIZeroTouchBlob.cs file, host.json file, and local.settings.json file.

PBIZeroTouchBlob.cs:

using System.IO;

using System.Threading.Tasks;

using Microsoft.Azure.Functions.Worker;

using Microsoft.Extensions.Logging;

namespace PBIZeroTouchBlob

{

public class PBIZeroTouchBlob

{

private readonly ILogger<PBIZeroTouch> _logger;

public PBIZeroTouchBlob(ILogger<PBIZeroTouch> logger)

{

_logger = logger;

}

[Function(nameof(PBIZeroTouch))]

public async Task Run([BlobTrigger("samples-workitems/{name}", Connection = "AzureWebJobsStorage")] Stream stream, string name)

{

using var blobStreamReader = new StreamReader(stream);

var content = await blobStreamReader.ReadToEndAsync();

_logger.LogInformation($"C# Blob trigger function Processed blob\n Name: {name} \n Data: {content}");

}

}

}

host.json

{

"version": "2.0",

"logging": {

"applicationInsights": {

"samplingSettings": {

"isEnabled": true,

"excludedTypes": "Request"

},

"enableLiveMetricsFilters": true

}

}

}

local.settings.json:

{

"IsEncrypted": false,

"Values": {

"AzureWebJobsStorage": "UseDevelopmentStorage=true",

"FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated"

}

}

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,399 questions
Azure Blob Storage
Azure Blob Storage
An Azure service that stores unstructured data in the cloud as blobs.
3,068 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Pinaki Ghatak 5,575 Reputation points Microsoft Employee
    2025-02-07T09:54:38.9233333+00:00

    Hello colleague @Karn Dalmia

    It seems that there might be a few issues with your configuration. Here are some suggestions that might help:

    1. Blob container location: The blob container is located in your Azure Storage account, not on your local machine or Storage Explorer. You can find the name of the container in the [BlobTrigger(samples-workitems/{name}, Connection = AzureWebJobsStorage)] attribute in your code. In this case, the container name is samples-workitems.
    2. Connection string: In your local.settings.json file, you are using the UseDevelopmentStorage=true connection string, which is used to connect to the local Azure Storage emulator. However, it seems that you are trying to trigger the function using a blob in your actual Azure Storage account. To connect to your Azure Storage account, you need to use the connection string for your account. You can find this connection string in the Azure portal under your storage account's "Access keys" section.
    3. Function name: In your PBIZeroTouchBlob.cs file, you have named your function PBIZeroTouchBlob, but in the [Function(nameof(PBIZeroTouch))] attribute, you have named it PBIZeroTouch. Make sure that the function name in the attribute matches the actual function name.
    4. Blob path: In the [BlobTrigger(samples-workitems/{name}, Connection = AzureWebJobsStorage)] attribute, you are using samples-workitems/{name} as the blob path. This means that the function will only trigger when a blob is added or modified in the samples-workitems container with a name that matches the {name} parameter. Make sure that the blob path matches the actual path of the blob that you are trying to trigger the function with.
    5. Function trigger: Make sure that your function is actually being triggered by adding or modifying a blob in the specified container. You can check the logs of your function in the Azure portal to see if it is being triggered and if there are any errors. I hope this helps! Let me know if you have any further questions.

    I hope this helps.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.