Microsoft.Azure.WebJobs.Extensions.Tables 1.2.1

The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org. Prefix Reserved
dotnet add package Microsoft.Azure.WebJobs.Extensions.Tables --version 1.2.1
NuGet\Install-Package Microsoft.Azure.WebJobs.Extensions.Tables -Version 1.2.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Tables" Version="1.2.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Microsoft.Azure.WebJobs.Extensions.Tables --version 1.2.1
#r "nuget: Microsoft.Azure.WebJobs.Extensions.Tables, 1.2.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Microsoft.Azure.WebJobs.Extensions.Tables as a Cake Addin
#addin nuget:?package=Microsoft.Azure.WebJobs.Extensions.Tables&version=1.2.1

// Install Microsoft.Azure.WebJobs.Extensions.Tables as a Cake Tool
#tool nuget:?package=Microsoft.Azure.WebJobs.Extensions.Tables&version=1.2.1

Azure WebJobs Tables client library for .NET

This extension provides functionality for accessing Azure Tables in Azure Functions.

Getting started

Install the package

Install the Tables extension with NuGet:

dotnet add package Microsoft.Azure.WebJobs.Extensions.Tables

Prerequisites

You need an Azure subscription and a Storage Account or Cosmos Tables Account to use this package.

Using Storage Tables

To create a new Storage Account, you can use the Azure Portal, Azure PowerShell, or the Azure CLI. Here's an example using the Azure CLI:

az storage account create --name <your-resource-name> --resource-group <your-resource-group-name> --location westus --sku Standard_LRS
Using Cosmos Tables

To create a new Cosmos Tables , you can use the Azure Portal, Azure PowerShell, or the Azure CLI.

Authenticate the client

Connection represents a set of information required to connect to a table service. It can contain a connection string, an endpoint, token credential or a shared key.

The Connection property of TableAttribute defines which connection is used for the Table Service access. For example, [Tables(Connection="MyTableService")] is going to use MyTableService connection.

The connection information can be set in local.settings.json or application settings in Azure portal.

When adding a setting to local.settings.json place it under the Values property:

{
  "IsEncrypted": false,
  "Values": {
    "MyTableService": "..."
  }
}

When adding a setting to application settings in Azure portal use the provided name directly:

MyTableService = ...

Tables extension uses the AzureWebJobsStorage connection name by default.

Connection string

To use connection strings authentication assign connection string value directly to the connection setting.

<ConnectionName> = DefaultEndpointsProtocol=https;AccountName=...;AccountKey=...;EndpointSuffix=core.windows.net

Using endpoint and token credential

NOTE: token credential authentication is supported only for storage tables.

<ConnectionName>__endpoint = https://...table.core.windows.net

If no credential information is provided the DefaultAzureCredential is used.

When using user-assigned manageed identity the clientId and credential settings need to be provided:

<ConnectionName>__credential = managedidentity

<ConnectionName>__clientId = <user-assigned client id>

Using shared key credential

When using shared key authentication the endpoint, accountKey and accountName need to be provided.

<ConnectionName>__endpoint = https://...table.core.windows.net

<ConnectionName>__credential__accountName = <account name>

<ConnectionName>__credential__accountKey = <account key>

Key concepts

The input binding allows you to read table as input to an Azure Function. The output binding allows you to modify and delete table rows in an Azure Function.

Please follow the input binding tutorial and output binding tutorial to learn about using this extension for accessing table service.

Examples

Tables extensions provides only bindings. Bindings by themselves can't trigger a function. It can only read or write entries to the table.

In the following example we use HTTP trigger to invoke the function.

Binding to a single entity

public class InputSingle
{
    [FunctionName("InputSingle")]
    public static void Run(
        [HttpTrigger(AuthorizationLevel.Anonymous, "GET")] HttpRequest request,
        [Table("MyTable", "<PartitionKey>", "<RowKey>")] TableEntity entity, ILogger log)
    {
        log.LogInformation($"PK={entity.PartitionKey}, RK={entity.RowKey}, Text={entity["Text"]}");
    }
}

Binding to a single entity using model type

public class MyEntity
{
    public string PartitionKey { get; set; }
    public string RowKey { get; set; }
    public string Text { get; set; }
}
public class InputSingleModel
{
    [FunctionName("InputSingleModel")]
    public static void Run(
        [HttpTrigger(AuthorizationLevel.Anonymous, "GET")] HttpRequest request,
        [Table("MyTable", "<PartitionKey>", "<RowKey>")] MyEntity entity, ILogger log)
    {
        log.LogInformation($"PK={entity.PartitionKey}, RK={entity.RowKey}, Text={entity.Text}");
    }
}

Binding to multiple entities with filter

public class InputMultipleEntitiesFilter
{
    [FunctionName("InputMultipleEntitiesFilter")]
    public static void Run(
        [HttpTrigger(AuthorizationLevel.Anonymous, "GET")] HttpRequest request,
        [Table("MyTable", "<PartitionKey>", Filter = "Text ne ''")] IEnumerable<TableEntity> entities, ILogger log)
    {
        foreach (var entity in entities)
        {
            log.LogInformation($"PK={entity.PartitionKey}, RK={entity.RowKey}, Text={entity["Text"]}");
        }
    }
}

Creating a single entity

public class OutputSingle
{
    [FunctionName("OutputSingle")]
    public static void Run(
        [HttpTrigger(AuthorizationLevel.Anonymous, "GET")] HttpRequest request,
        [Table("MyTable")] out TableEntity entity)
    {
        entity = new TableEntity("<PartitionKey>", "<RowKey>")
        {
            ["Text"] = "Hello"
        };
    }
}

Creating a single entity using model

public class MyEntity
{
    public string PartitionKey { get; set; }
    public string RowKey { get; set; }
    public string Text { get; set; }
}
public class OutputSingleModel
{
    [FunctionName("OutputSingleModel")]
    public static void Run(
        [HttpTrigger(AuthorizationLevel.Anonymous, "GET")] HttpRequest request,
        [Table("MyTable")] out MyEntity entity)
    {
        entity = new MyEntity()
        {
            PartitionKey = "<PartitionKey>",
            RowKey = "<RowKey>",
            Text = "Hello"
        };
    }
}

Creating multiple entities

public class OutputMultiple
{
    [FunctionName("OutputMultiple")]
    public static void Run(
        [HttpTrigger(AuthorizationLevel.Anonymous, "POST")] HttpRequest request,
        [Table("MyTable")] IAsyncCollector<TableEntity> collector)
    {
        for (int i = 0; i < 10; i++)
        {
            collector.AddAsync(new TableEntity("<PartitionKey>", i.ToString())
            {
                ["Text"] = i.ToString()
            });
        }
    }
}

Creating multiple entities using model

public class MyEntity
{
    public string PartitionKey { get; set; }
    public string RowKey { get; set; }
    public string Text { get; set; }
}
public class OutputMultipleModel
{
    [FunctionName("OutputMultipleModel")]
    public static void Run(
        [HttpTrigger(AuthorizationLevel.Anonymous, "POST")] HttpRequest request,
        [Table("MyTable")] IAsyncCollector<MyEntity> collector)
    {
        for (int i = 0; i < 10; i++)
        {
            collector.AddAsync(new MyEntity()
            {
                PartitionKey = "<PartitionKey>",
                RowKey = i.ToString(),
                Text = i.ToString()
            });
        }
    }
}

Binding to SDK TableClient type

Use a TableClient method parameter to access the table by using the Azure Tables SDK.

public class BindTableClient
{
    [FunctionName("BindTableClient")]
    public static async Task Run(
        [HttpTrigger(AuthorizationLevel.Anonymous, "POST")] HttpRequest request,
        [Table("MyTable")] TableClient client)
    {
        await client.AddEntityAsync(new TableEntity("<PartitionKey>", "<RowKey>")
        {
            ["Text"] = request.GetEncodedPathAndQuery()
        });
    }
}

Troubleshooting

Please refer to Monitor Azure Functions for troubleshooting guidance.

Next steps

Read the introduction to Azure Function or creating an Azure Function guide.

Contributing

See the CONTRIBUTING.md for details on building, testing, and contributing to this library.

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit cla.microsoft.com.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Microsoft.Azure.WebJobs.Extensions.Tables:

Package Downloads
FunctionMonkey.Cgo

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.2.1 32,089 11/13/2023
1.2.0 57,484 8/11/2023
1.2.0-beta.1 5,006 5/23/2023
1.1.0 102,081 3/13/2023
1.0.0 473,813 4/12/2022
1.0.0-beta.2 4,354 3/10/2022
1.0.0-beta.1 30,295 1/14/2022