This article is in continuation of my previous article where I have explained how to bind Azure Queue Storage for Azure Functions. Here, we are going to discuss how to integrate the Azure Table Storage to Azure Functions.
- Azure Subscription
- Basic knowledge of Azure Functions and Storage Service
Integrate Azure Table Storage to Azure Functions
Log into the Azure portal, go to the Functions App, and under QueueIntegrationDemo function, click on "Integrate".

- Table parameter name - let it be the default one, i.e., outputTable
- Table Name - name it as orders
- Storage account connection - let it be AzureWebJobStorage which is used for the function earlier.

- #r "Newtonsoft.Json"
- using System;
- using System.Net;
- using Microsoft.AspNetCore.Mvc;
- using Microsoft.Extensions.Primitives;
- using Newtonsoft.Json;
- public class Order{
- public string PartitionKey {get;set;}
- public string RowKey{get;set;}
- public string OrderId{get;set;}
- public string ProductId{get;set;}
- public string UserEmail{get;set;}
- public decimal Price {get;set;}
- }
- public static async Task<object> Run(HttpRequestMessage req, ILogger log, IAsyncCollector<Order> outputQueueItem, IAsyncCollector<Order> outputTable)
- {
- string jsonContent= await req.Content.ReadAsStringAsync();
- var myOrder= JsonConvert.DeserializeObject<Order>(jsonContent);
- log.LogInformation($"Order {myOrder.OrderId} received from {myOrder.UserEmail} for product{myOrder.ProductId}");
- myOrder.PartitionKey = "Orders";
- myOrder.RowKey=myOrder.OrderId;
- await outputQueueItem.AddAsync(myOrder);
- await outputTable.AddAsync(myOrder);
- return (object)new OkObjectResult($"Your Order is Placed with Order Id {myOrder.OrderId}, Thank you" );
- }
From the above code, you can notice that we have added the PartitionKey and RowKey properties in the Order class for Azure Table Storage.
Trigger the function using POSTMAN tool.


Conclusion
We have seen how to integrate Azure Table Storage as a service to the Azure Functions and how can we add the records to the table by triggering the function. We will see more about service binding to Azure Functions in my future articles.

Join the conversation! Your thoughts help the community grow.