Skip to content

Latest commit

 

History

History
224 lines (132 loc) · 11.5 KB

File metadata and controls

224 lines (132 loc) · 11.5 KB
title Azure Tables bindings for Azure Functions
description Understand how to use Azure Tables bindings in Azure Functions.
ms.topic reference
ms.date 11/11/2022
ms.custom devx-track-csharp, devx-track-python, devx-track-extended-java, devx-track-js
zone_pivot_groups programming-languages-set-functions-lang-workers

Azure Tables bindings for Azure Functions

Azure Functions integrates with Azure Tables via triggers and bindings. Integrating with Azure Tables allows you to build functions that read and write data using Azure Cosmos DB for Table and Azure Table Storage.

Action Type
Read table data in a function Input binding
Allow a function to write table data Output binding

::: zone pivot="programming-language-csharp"

Install extension

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

Functions execute in an isolated C# worker process. To learn more, see Guide for running C# Azure Functions in an isolated worker process.

[!INCLUDE functions-in-process-model-retirement-note]

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 process for installing 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.

[!INCLUDE functions-bindings-supports-identity-connections-note]

This version allows you to bind to types from Azure.Data.Tables. It also introduces the ability to use Azure Cosmos DB for Table.

This extension is available by installing the Microsoft.Azure.WebJobs.Extensions.Tables NuGet package into a project using version 5.x or higher of the extensions for blobs and queues.

Using the .NET CLI:

# Install the Azure Tables extension
dotnet add package Microsoft.Azure.WebJobs.Extensions.Tables

# Update the combined Azure Storage extension (to a version which no longer includes Azure Tables)
dotnet add package Microsoft.Azure.WebJobs.Extensions.Storage

[!INCLUDE functions-bindings-storage-extension-v5-tables-note]

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

Working with the bindings requires that you reference the appropriate NuGet package. Tables are included in a combined package for Azure Storage. Install the Microsoft.Azure.WebJobs.Extensions.Storage NuGet package, version 3.x or 4.x.

Note

Tables have been moved out of this package starting in its 5.x version. You need to instead use version 4.x of the extension NuGet package or additionally include the Azure Tables extension when using version 5.x.

[!INCLUDE functions-runtime-1x-retirement-note]

Functions 1.x apps automatically have a reference the Microsoft.Azure.WebJobs NuGet package, version 2.x.

[!INCLUDE functions-storage-sdk-version]

[!INCLUDE functions-bindings-supports-identity-connections-note]

This version allows you to bind to types from Azure.Data.Tables. It also introduces the ability to use Azure Cosmos DB for Table.

This extension is available by installing the Microsoft.Azure.Functions.Worker.Extensions.Tables NuGet package into a project using version 5.x or higher of the extensions for blobs and queues.

Using the .NET CLI:

# Install the Azure Tables extension
dotnet add package Microsoft.Azure.Functions.Worker.Extensions.Tables --version 1.0.0

# Update the combined Azure Storage extension (to a version which no longer includes Azure Tables)
dotnet add package Microsoft.Azure.Functions.Worker.Extensions.Storage --version 5.0.0

[!INCLUDE functions-bindings-storage-extension-v5-isolated-worker-tables-note]

If you're writing your application using F#, you must also configure this extension as part of the app's startup configuration. In the call to ConfigureFunctionsWorkerDefaults() or ConfigureFunctionsWebApplication(), add a delegate that takes an IFunctionsWorkerApplication parameter. Then within the body of that delegate, call ConfigureTablesExtension() on the object:

let hostBuilder = new HostBuilder()
hostBuilder.ConfigureFunctionsWorkerDefaults(fun (context: HostBuilderContext) (appBuilder: IFunctionsWorkerApplicationBuilder) ->
    appBuilder.ConfigureTablesExtension() |> ignore
) |> ignore

Tables are included in a combined package for Azure Storage. Install the Microsoft.Azure.Functions.Worker.Extensions.Storage NuGet package, version 4.x.

Note

Tables have been moved out of this package starting in its 5.x version. You need to instead use version 4.x of the extension NuGet package or additionally include the Azure Tables extension when using version 5.x.

Functions version 1.x doesn't support isolated worker process.


::: zone-end

::: zone pivot="programming-language-javascript,programming-language-python,programming-language-java,programming-language-powershell"

[!INCLUDE functions-install-extension-bundle]

::: zone-end

::: zone pivot="programming-language-csharp"

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 isolated worker process class library compiled C# function runs in a process isolated from the runtime.

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 Tables extension supports parameter types according to the table below.

Binding scenario Parameter types
Table input (single entity) A type deriving from ITableEntity
Table input (multiple entities from query) IEnumerable<T> where T derives from ITableEntity
TableClient
Table output (single entity) A type deriving from ITableEntity
Table output (multiple entities) TableClient
ICollector<T> or IAsyncCollector<T> where T implements ITableEntity

Earlier versions of the extension exposed types from the now deprecated Microsoft.Azure.Cosmos.Table namespace. Newer types from Azure.Data.Tables are exclusive to the Azure Tables extension.

This version of the extension supports parameter types according to the table below.

Binding scenario Parameter types
Table input A plain old CLR object (POCO) representing the entity
CloudTable
Table output A plain old CLR object (POCO) representing the entity
CloudTable

Functions 1.x exposed types from the deprecated Microsoft.WindowsAzure.Storage.Table namespace. Newer types from Azure.Data.Tables are exclusive to the Azure Tables extension. To use these, you will need to upgrade your application to Functions 4.x.

The isolated worker process supports parameter types according to the tables below. Support for binding to types from Azure.Data.Tables is in preview.

Azure Tables input binding

[!INCLUDE functions-bindings-table-input-dotnet-isolated-types]

Azure Tables output binding

[!INCLUDE functions-bindings-table-output-dotnet-isolated-types]

Earlier versions of extensions in the isolated worker process only support binding to plain-old CLR object (POCO) types. Additional options are available to the Azure Tables extension.

Functions version 1.x doesn't support isolated worker process. To use the isolated worker model, upgrade your application to Functions 4.x.


:::zone-end

Next steps