Azure Функция .... не найдена - PullRequest
1 голос
/ 21 апреля 2020

Я получаю

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).

Функция. 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
}

Это мой код, есть идеи?

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;
}

1 Ответ

1 голос
/ 22 апреля 2020

Я могу воспроизвести вашу проблему:

enter image description here

2020-04-21T15: 15: 59.192 [Error] Executed 'Functions.entry '(Ошибка, Id = 90808c2e-1944-454 c -bac0-e25871662d7 c) Не найдено

Возможно, эта ошибка не очень хорошо описывается. Он не сказал вам подробно, в чем проблема.

На самом деле, ваш код не проблема. Я думаю, что ключ этого вопроса в том, что у вас нет таблицы в учетной записи хранения, которую вы установили в функции. json. Вы задаете ввод и вывод своей функции, и функция пытается найти таблицу с именем entry в учетной записи хранения.

Вам необходимо go, чтобы найти учетную запись хранения AzureWebJobsStorage. Его можно найти в настройках конфигурации:

enter image description here

enter image description here

А затем go к учетной записи хранения создайте в ней таблицу «запись».

enter image description here

enter image description here

После этого все работает нормально:

enter image description here

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...