I am trying to update a row in an Azure table based on an Azure Function. I see that the Table bindings can handle an ICollector which has an Add method which will add a row
With today's bindings, you can set an ETag property to the value * to do an upsert:
[FunctionName("Function1")]
public static async Task Run(
[HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req,
ILogger log,
[Table("test")] IAsyncCollector table)
{
log.LogInformation("C# HTTP trigger function processed a request.");
string name = req.Query["name"];
if (name == null)
return new BadRequestResult();
await table.AddAsync(new PocoClass { Name = name });
return new OkObjectResult($"Hello, {name}");
}
public sealed class PocoClass
{
public string PartitionKey { get; } = "partition";
public string RowKey { get; } = "row";
public string ETag { get; } = "*";
public string Name { get; set; }
}