Reputation: 7001
I keep getting
2020-04-21T15:15:58.686 [Information] Executing 'Functions.entry' (Reason='This function was programmatically called via the host APIs.', Id=90808c2e-1944-454c-bac0-e25871662d7c)
2020-04-21T15:15:59.192 [Error] Executed 'Functions.entry' (Failed, Id=90808c2e-1944-454c-bac0-e25871662d7c)
Not Found
2020-04-21T15:17:28 No new trace in the past 1 min(s).
Function.json
{
"bindings": [
{
"authLevel": "anonymous",
"name": "req",
"type": "httpTrigger",
"direction": "in",
"methods": [
"get",
"post"
]
},
{
"name": "$return",
"type": "http",
"direction": "out"
},
{
"type": "table",
"name": "entryTableOutput",
"tableName": "entry",
"connection": "AzureWebJobsStorage",
"direction": "out"
},
{
"type": "table",
"name": "entryTableInput",
"tableName": "entry",
"take": 50,
"connection": "AzureWebJobsStorage",
"direction": "in"
}
],
"disabled": false
}
This is my code any ideas ?
Run.CSX
#r "Newtonsoft.Json"
#r "Microsoft.WindowsAzure.Storage"
using System.Net;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Primitives;
using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.Table;
using Newtonsoft.Json;
public static async Task<IActionResult> Run(HttpRequest req, Newtonsoft.Json.Linq.JArray entryTableInput, IAsyncCollector<Entry> entryTableOutput, ILogger log)
{
log.LogInformation(req.Method);
if (req.Method == "GET")
{
return (ActionResult) new OkObjectResult(entryTableInput);
}
var requestBody = await new StreamReader(req.Body).ReadToEndAsync();
var entry = JsonConvert.DeserializeObject<Entry>(requestBody);
if (entry != null)
{
await entryTableOutput.AddAsync(entry);
return (ActionResult) new OkObjectResult(entry);
}
return new BadRequestObjectResult("Invalid entry request.");
}
public class Entry
{
public string Id => Guid.NewGuid().ToString("n");
public string Title { get; set; }
public double Latitude { get; set; }
public double Longitude { get; set; }
public DateTime Date { get; set; }
public int Rating { get; set; }
public string Notes { get; set; }
// Required for Table Storage entities
public string PartitionKey => "ENTRY";
public string RowKey => Id;
}
Upvotes: 1
Views: 874
Reputation: 14111
I can reproduce your problem:
2020-04-21T15:15:59.192 [Error] Executed 'Functions.entry' (Failed, Id=90808c2e-1944-454c-bac0-e25871662d7c) Not Found
Maybe this error doesn't describle well. It didn't tell you in detail where the problem lies.
In fact, your code is no problem. I think the key of this question is you don't have a table in the Storage Account you set in the function.json. You set the input and output of your function and the function try to find table named entry in the storage account.
You should go to find what is the storage account of 'AzureWebJobsStorage'. It can be found in the configuration settings:
And then go to the storage account, create the table 'entry' in it.
After that, it works fine:
Upvotes: 2