Microsoft.Azure.WebJobs.Extensions.Tables
1.3.2
Prefix Reserved
dotnet add package Microsoft.Azure.WebJobs.Extensions.Tables --version 1.3.2
NuGet\Install-Package Microsoft.Azure.WebJobs.Extensions.Tables -Version 1.3.2
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Tables" Version="1.3.2" />
paket add Microsoft.Azure.WebJobs.Extensions.Tables --version 1.3.2
#r "nuget: Microsoft.Azure.WebJobs.Extensions.Tables, 1.3.2"
// Install Microsoft.Azure.WebJobs.Extensions.Tables as a Cake Addin #addin nuget:?package=Microsoft.Azure.WebJobs.Extensions.Tables&version=1.3.2 // Install Microsoft.Azure.WebJobs.Extensions.Tables as a Cake Tool #tool nuget:?package=Microsoft.Azure.WebJobs.Extensions.Tables&version=1.3.2
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 | Versions 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. |
-
.NETStandard 2.0
- Azure.Data.Tables (>= 12.8.0)
- Microsoft.Azure.WebJobs (>= 3.0.37)
- Microsoft.Extensions.Azure (>= 1.7.4)
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.3.2 | 67,841 | 6/13/2024 |
1.3.1 | 15,714 | 4/17/2024 |
1.2.1 | 142,870 | 11/13/2023 |
1.2.0 | 92,324 | 8/11/2023 |
1.2.0-beta.1 | 5,665 | 5/23/2023 |
1.1.0 | 157,038 | 3/13/2023 |
1.0.0 | 606,189 | 4/12/2022 |
1.0.0-beta.2 | 4,809 | 3/10/2022 |
1.0.0-beta.1 | 30,373 | 1/14/2022 |