Čitajte na engleskom Uređivanje

Dijeli putem


Azure Blob storage bindings for Azure Functions overview

Choose a programming language

Azure Functions integrates with Azure Storage via triggers and bindings. Integrating with Blob storage allows you to build functions that react to changes in blob data as well as read and write values.

Action Type
Run a function as blob storage data changes Trigger
Read blob storage data in a function Input binding
Allow a function to write blob storage data Output binding

Install extension

The extension NuGet package you install depends on the C# mode you're using in your function app:

Functions execute in the same process as the Functions host. To learn more, see Develop C# class library functions using Azure Functions.

In a variation of this model, Functions can be run using C# scripting, which is supported primarily for C# portal editing. To update existing binding extensions for C# script apps running in the portal without having to republish your function app, see Update your extensions.

The functionality of the extension varies depending on the extension version:

This section describes using a class library. For C# scripting, you would need to instead install the extension bundle, version 4.x.

This version introduces the ability to connect using an identity instead of a secret. For a tutorial on configuring your function apps with managed identities, see the creating a function app with identity-based connections tutorial.

This version allows you to bind to types from Azure.Storage.Blobs. Learn more about how these new types are different from WindowsAzure.Storage and Microsoft.Azure.Storage and how to migrate to them from the Azure.Storage.Blobs Migration Guide.

This extension is available by installing the Microsoft.Azure.WebJobs.Extensions.Storage.Blobs NuGet package, version 5.x.

Using the .NET CLI:

.NET CLI
dotnet add package Microsoft.Azure.WebJobs.Extensions.Storage.Blobs --version 5.0.0

Napomena

Azure Blobs, Azure Queues, and Azure Tables now use separate extensions and are referenced individually. For example, to use the triggers and bindings for all three services in your .NET in-process app, you should add the following packages to your project:

Previously, the extensions shipped together as Microsoft.Azure.WebJobs.Extensions.Storage, version 4.x. This same package also has a 5.x version, which references the split packages for blobs and queues only. When upgrading your package references from older versions, you may therefore need to additionally reference the new Microsoft.Azure.WebJobs.Extensions.Tables NuGet package. Also, when referencing these newer split packages, make sure you are not referencing an older version of the combined storage package, as this will result in conflicts from two definitions of the same bindings.

Install bundle

The Blob storage binding is part of an extension bundle, which is specified in your host.json project file. You may need to modify this bundle to change the version of the binding, or if bundles aren't already installed. To learn more, see extension bundle.

This version introduces the ability to connect using an identity instead of a secret. For a tutorial on configuring your function apps with managed identities, see the creating a function app with identity-based connections tutorial.

You can add this version of the extension from the extension bundle v3 by adding or replacing the following code in your host.json file:

JSON
{
    "version": "2.0",
    "extensionBundle": {
        "id": "Microsoft.Azure.Functions.ExtensionBundle",
        "version": "[3.3.0, 4.0.0)"
    }
}

To learn more, see Update your extensions.

Binding types

The binding types supported for .NET depend on both the extension version and C# execution mode, which can be one of the following:

An in-process class library is a compiled C# function runs in the same process as the Functions runtime.

Choose a version to see binding type details for the mode and version.

The Azure Blobs extension supports parameter types according to the table below.

Binding scenario Parameter types
Blob trigger Stream
TextReader
string
byte[]
BinaryData
BlobClient1
BlockBlobClient1
PageBlobClient1
AppendBlobClient1
BlobBaseClient1
Blob input (single blob) Stream
TextReader
string
byte[]
BinaryData
BlobClient1
BlockBlobClient1
PageBlobClient1
AppendBlobClient1
BlobBaseClient1
Blob input (multiple blobs from a container) IEnumerable<T> where T is one of the single blob input binding types
Blob output (single blob) Stream
TextWriter
string
byte[]
Blob output (multiple blobs) ICollector<T> or IAsyncCollector<T> where T is one of the single blob output binding types

1 The client types require the Access property of the attribute to be set to FileAccess.ReadWrite.

For examples using these types, see the GitHub repository for the extension. Learn more about types from the Azure SDK, how they are different from earlier versions, and how to migrate to them from the Azure.Storage.Blobs Migration Guide.

host.json settings

This section describes the function app configuration settings available for functions that use this binding. These settings only apply when using extension version 5.0.0 and higher. The example host.json file below contains only the version 2.x+ settings for this binding. For more information about function app configuration settings in versions 2.x and later versions, see host.json reference for Azure Functions.

Napomena

This section doesn't apply to extension versions before 5.0.0. For those earlier versions, there aren't any function app-wide configuration settings for blobs.

JSON
{
    "version": "2.0",
    "extensions": {
        "blobs": {
            "maxDegreeOfParallelism": 4,
            "poisonBlobThreshold": 1
        }
    }
}
Property Default Description
maxDegreeOfParallelism 8 * (the number of available cores) The integer number of concurrent invocations allowed for all blob-triggered functions in a given function app. The minimum allowed value is 1.
poisonBlobThreshold 5 The integer number of times to try processing a message before moving it to the poison queue. The minimum allowed value is 1.

Next steps