Blob trigger binding
The Blob trigger allows Azure Functions to react to changes in Azure Blob Storage. A function with a Blob trigger is invoked each time a new blob is added or an existing blob is updated in the specified container.
When to use
- Processing uploaded files (images, videos, documents)
- Generating thumbnails or extracting metadata
- Data ingestion pipelines that start with blob uploads
Function signature
public static void Run(
[BlobTrigger("samples-workitems/{name}", Connection = "AzureWebJobsStorage")] Stream myBlob,
string name,
ILogger log)
Configuration
path | Pattern that identifies the container and blob name. Use {name} to capture the blob name. |
connection | Name of the app setting containing the storage account connection string. |
cardinality | many or one – determines whether the trigger receives a single blob or a batch. |
Sample function
using System.IO;
using Microsoft.Azure.WebJobs;
using Microsoft.Extensions.Logging;
public static class BlobTriggerSample
{
[FunctionName("BlobTriggerSample")]
public static void Run(
[BlobTrigger("input/{filename}", Connection = "AzureWebJobsStorage")] Stream blob,
string filename,
ILogger log)
{
log.LogInformation($"Blob trigger processed file: {filename}, Size: {blob.Length} bytes");
// Add your processing logic here
}
}
Local development
- Install the Azure Functions Core Tools.
- Set
AzureWebJobsStorage
inlocal.settings.json
to your storage emulator or account. - Run
func start
and upload a blob to the defined container.