Can anyone help me fix these errors?
#r "Newtonsoft.Json"
#r "Microsoft.WindowsAzure.Storage"
using System.Net;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Primitives;
using Newtonsoft.Json;
using Microsoft.WindowsAzure.Storage.Table;
public static async Task<IActionResult> Run
(HttpRequest req,
CloudTable objUserProfileTable,
ILogger log)
{
log.LogInformation("C# HTTP trigger function processed a request.");
string firstname = null, lastname = null;
string requestBody = await new
StreamReader(req.Body).ReadToEndAsync();
dynamic inputJson = JsonConvert.DeserializeObject(requestBody);
firstname = firstname ?? inputJson?.firstname;
lastname = inputJson?.lastname;
UserProfile objUserProfile = new UserProfile(firstname, lastname) ;
TableOperation objTblOperationInsert =
TableOperation.Insert(objUserProfile);
await objUserProfileTable.ExecuteAsync(objTblOperationInsert);
return (lastname + firstname) != null
? (ActionResult)new OkObjectResult($"Hello, {firstname + " " + lastname}")
:new BadRequestObjectResult("Please pass a name on the query" + "string or in the request body");
}
class UserProfile : TableEntity
{
public UserProfile(string firstName, string lastName)
{
this.PartitionKey = "p1";
this.RowKey = Guid.NewGuid().ToString();
this.FirstName = firstName;
this.LastName = lastName;
}
UserProfile() {}
public string FirstName { get; set; }
public string LastName { get; set; }
}
I get these errors:
Error CS0006: Metadata file 'Microsoft.WindowsAzure.Storage' could not be found
Error CS0234: The type or namespace name 'WindowsAzure' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)
Error CS0246: The type or namespace name 'CloudTable' could not be found (are you missing a using directive or an assembly reference?)
Error CS0246: The type or namespace name 'TableEntity' could not be found (are you missing a using directive or an assembly reference?)
Error CS0246: The type or namespace name 'TableOperation' could not be found (are you missing a using directive or an assembly reference?)
Error CS0103: The name 'TableOperation' does not exist in the current context
Error CS1061: 'UserProfile' does not contain a definition for 'PartitionKey' and no accessible extension method 'PartitionKey' accepting a first argument of type 'UserProfile' could be found (are you missing a using directive or an assembly reference?)
Error CS1061: 'UserProfile' does not contain a definition for 'RowKey' and no accessible extension method 'RowKey' accepting a first argument of type 'UserProfile' could be found (are you missing a using directive or an assembly reference?)
Compilation failed.