Register Azure Functions binding extensions

In Azure Functions version 2.x, bindings are available as separate packages from the functions runtime. While .NET functions access bindings through NuGet packages, extension bundles allow other functions access to all bindings through a configuration setting.

Consider the following items related to binding extensions:

The following table indicates when and how you register bindings.

Development environment Registration
in Functions 1.x
Registration
in Functions 2.x
Azure portal Automatic Automatic
Non-.NET languages or local Azure Core Tools development Automatic Use Azure Functions Core Tools and extension bundles
C# class library using Visual Studio Use NuGet tools Use NuGet tools
C# class library using Visual Studio Code N/A Use .NET Core CLI

Extension bundles for local development

Extension bundles is a deployment technology that lets you add a compatible set of Functions binding extensions to your function app. A predefined set of extensions are added when you build your app. Extension packages defined in a bundle are compatible with each other, which helps you avoid conflicts between packages. You enable extension bundles in the app's host.json file.

You can use extension bundles with version 2.x and later versions of the Functions runtime. When developing locally, make sure you are using the latest version of Azure Functions Core Tools.

Use extension bundles for local development using Azure Functions Core Tools, Visual Studio Code, and when you build remotely.

If you don't use extension bundles, you must install the .NET Core 2.x SDK on your local computer before you install any binding extensions. Extension bundles removes this requirement for local development.

To use extension bundles, update the host.json file to include the following entry for extensionBundle:

{
    "version": "2.0",
    "extensionBundle": {
        "id": "Microsoft.Azure.Functions.ExtensionBundle",
        "version": "[1.*, 2.0.0)"
    }
}

The following properties are available in extensionBundle:

Property Description
id The namespace for Microsoft Azure Functions extension bundles.
version The version of the bundle to install. The Functions runtime always picks the maximum permissible version defined by the version range or interval. The version value above allows all bundle versions from 1.0.0 up to but not including 2.0.0. For more information, see the interval notation for specifying version ranges.

Bundle versions increment as packages in the bundle change. Major version changes occur when packages in the bundle increment by a major version. Major version changes in the bundle usually coincide with a change in the major version of the Functions runtime.

The current set of extensions installed by the default bundle is enumerated in this extensions.json file.

C# class library with Visual Studio

In Visual Studio, you can install packages from the Package Manager Console using the Install-Package command, as shown in the following example:

Install-Package Microsoft.Azure.WebJobs.Extensions.ServiceBus -Version <TARGET_VERSION>

The name of the package used for a given binding is provided in the reference article for that binding. For an example, see the Packages section of the Service Bus binding reference article.

Replace <TARGET_VERSION> in the example with a specific version of the package, such as 3.0.0-beta5. Valid versions are listed on the individual package pages at NuGet.org. The major versions that correspond to Functions runtime 1.x or 2.x are specified in the reference article for the binding.

If you use Install-Package to reference a binding, you don't need to use extension bundles. This approach is specific for class libraries built in Visual Studio.

C# class library with Visual Studio Code

Note

We recommend using extension bundles to have Functions automatically install a compatible set of binding extension packages.

In Visual Studio Code, install packages for a C# class library project from the command prompt using the dotnet add package command in the .NET Core CLI. The following example demonstrates how you add a binding:

dotnet add package Microsoft.Azure.WebJobs.Extensions.<BINDING_TYPE_NAME> --version <TARGET_VERSION>

The .NET Core CLI can only be used for Azure Functions 2.x development.

Replace <BINDING_TYPE_NAME> with the name of the package that contains the binding you need. You can find the desired binding reference article in the list of supported bindings.

Replace <TARGET_VERSION> in the example with a specific version of the package, such as 3.0.0-beta5. Valid versions are listed on the individual package pages at NuGet.org. The major versions that correspond to Functions runtime 1.x or 2.x are specified in the reference article for the binding.

Next steps