I'm starting out using Azure and c# and I'm attempting to use Table Storage - and using an Azure Function to update entitys in the table. My code is as follows:
#r "Microsoft.WindowsAzure.Storage"
#r "Newtonsoft.Json"
using System;
using Newtonsoft.Json;
using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.Table;
public static async Task<HttpResponseMessage> Run(HttpRequest req, CloudTable lookupTable)
{
string requestBody = await new StreamReader(req.Body).ReadToEndAsync();
dynamic data = JsonConvert.DeserializeObject(requestBody);
string partitionKey = data.Society;
string rowKey = data.ConnectionDetails.Environment;
string newConnection = data.ConnectionDetails.Connection;
TableOperation operation = TableOperation.Retrieve<SocietyConnectionDetails>(partitionKey, rowKey);
TableResult result = lookupTable.Execute(operation);
SocietyConnectionDetails societyConnectionDetails = (SocietyConnectionDetails)result.Result;
societyConnectionDetails.Connection = newConnection;
operation = TableOperation.Replace(societyConnectionDetails);
lookupTable.Execute(operation);
}
public class SocietyConnectionDetails : TableEntity
{
public string Connection {get; set;}
}
But the errors im getting are as follows:
2020-02-25T10:33:16.956 [Error] run.csx(17,38): error CS1061: 'CloudTable' does not contain a definition for 'Execute' and no accessible extension method 'Execute' accepting a first argument of type 'CloudTable' could be found (are you missing a using directive or an assembly reference?)
2020-02-25T10:33:16.984 [Error] run.csx(22,17): error CS1061: 'CloudTable' does not contain a definition for 'Execute' and no accessible extension method 'Execute' accepting a first argument of type 'CloudTable' could be found (are you missing a using directive or an assembly reference?)
2020-02-25T10:33:17.011 [Error] run.csx(8,47): error CS0161: 'Run(HttpRequest, CloudTable)': not all code paths return a value
I can see that the issue is happening when im attempting to 'Execute' my Table Operations... this might be a relatively straight forward problem but I'm struggling to work out why this wouldn't be working...
Thanks for any help..
I can reproduce your error.
Like this:

Solution is add a function.proj file to your function.

<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="WindowsAzure.Storage" Version="9.3.3" />
</ItemGroup>
</Project>
Then the error should disappear.
(If you dont do this. the compilation step will not success.)

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With