This repository provides examples demonstrating how to use Azure Storage Blob SDK bindings with Azure Functions in Node.js (TypeScript). These examples showcase enhanced SDK-binding capabilities, enabling direct access to Azure Storage Blob SDK objects.
The repository contains three example projects illustrating different aspects of working with Azure Blob Storage in Azure Functions:
- blobClientSdkBinding: Demonstrates using SDK bindings with Blob triggers.
- blobClientWithReadableStream: Shows how to work with blob content as readable streams.
- containerClientInputBinding: Illustrates using container client input bindings with HTTP triggers.
- Node.js (v20 or later)
- Azure Functions Core Tools (v4 or later)
- Azure Storage Account or Azurite emulator for local testing
This example shows how to use the SDK binding with a Blob trigger. The function is triggered when a blob is added to a container and demonstrates:
- Accessing blob properties using the SDK
- Downloading blob content
// Key points:
import "@azure/functions-extensions-blob"; // Required first import
// ...
export async function storageBlobTrigger(
blobStorageClient: StorageBlobClient, // SDK binding provides this client
context: InvocationContext
): Promise<void> {
// Access full SDK capabilities
const blobProperties = await blobStorageClient.blobClient.getProperties();
}
This example demonstrates how to work with blob content as a readable stream:
- Downloading blob content as a stream
- Converting stream content to string
- Error handling for blob operations
This example shows how to use container client input bindings with HTTP triggers:
- Listing all blobs in a container
- Accessing container client through input binding
- Returning blob list as JSON response
Each project can be run locally using Azure Functions Core Tools.
Install dependencies:
cd [project-folder]
npm install
Configure local settings by creating a local.settings.json
file with your storage connection string:
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"FUNCTIONS_WORKER_RUNTIME": "node"
}
}
Start the function app:
func start
- Direct access to Azure Blob Storage SDK objects and methods
- Simplified streaming of blob content
- Enhanced error handling and blob property access
- Reduced boilerplate code compared to traditional bindings
This project is licensed under the MIT License - see the LICENSE.md file for details.