@azure/functions-extensions-blob
TypeScript icon, indicating that this package has built-in type declarations

0.1.0-preview • Public • Published

Azure Functions Node.js Extensions - Blob

This project provides extensions for working with Azure Blob Storage in Azure Functions using Node.js. It simplifies the integration and interaction with Blob Storage, enabling developers to build scalable and efficient serverless applications.

Features

  • Blob Trigger: Automatically trigger Azure Functions when a blob is created or updated in a specified container.
  • Blob Input Binding: Read blob content as input to your function.
  • Cached Client Management: Optimized client reuse with intelligent caching
  • Resource Management: Proper disposal patterns for Azure resource clients
  • Performance Optimizations: Reduced overhead for blob operations

Prerequisites

Installation

To install the required dependencies, run:

npm install @azure/functions-extensions-blob

Usage

  1. Set up your Azure Blob Storage account:

    • Create a storage account in the Azure portal.
    • Create a container within the storage account.
  2. Configure your function:

    • Update the function.json file to include the appropriate bindings for Blob Storage.
  3. Import and initialize the extension:

import '@azure/functions-extensions-blob'; // Ensures at the top of the file

Using in Azure Functions

import "@azure/functions-extensions-blob"; // Ensures side effects run
import { StorageBlobClient } from "@azure/functions-extensions-blob";
import { app, InvocationContext } from "@azure/functions";

export async function storageBlobTrigger1(
  blobStorageClient: StorageBlobClient,
  context: InvocationContext
): Promise<void> {
  context.log(
    `Storage blob function processed blob "${context.triggerMetadata.name}"`
  );
  try {
     // Use the cached client for better performance
    const downloadBlockBlobResponse =
      await blobStorageClient.blobClient.download();
// Additional operations...

  }
}

app.storageBlob("storageBlobTrigger1", {
  path: "snippets/SomeFolder/{name}",
  connection: "AzureWebJobsStorage",
  sdkBinding: true, //Ensure this is set to true
  handler: storageBlobTrigger1,
});
  1. Run locally:
  • Use the Azure Functions Core Tools to run your function locally: bash func start
  1. Deploy to Azure:
  • Deploy your function to Azure using the following command: bash func azure functionapp publish <YourFunctionAppName>

Contributing

Contributions are welcome! Please follow the contribution guidelines when submitting issues or pull requests.

License

This project is licensed under the MIT License.

Resources

Package Sidebar

Install

npm i @azure/functions-extensions-blob

Weekly Downloads

15

Version

0.1.0-preview

License

MIT

Unpacked Size

103 kB

Total Files

19

Last publish

Collaborators

  • pgopa
  • paulbatum
  • facavalcante
  • ahmelsayed
  • mahoeger
  • anatolib
  • gaaguiar
  • victoriahall