嗨,我正在试用简单的Azure功能与REST。我的env是MSVC 2019,并创建了一个简单的mmApi应用程序
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using AzureFuncApp.Model;
using System.Collections.Generic;
using Microsoft.WindowsAzure.Storage.Table;
using Microsoft.WindowsAzure.Storage;
namespace AzureFuncApp
{
public static class mmApi
{
//static List<Board> boards = new List<Board>();
[FunctionName("CreateBoard")]
public static async Task<IActionResult> CreateBoard(
[HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = "board")] HttpRequest req,
[Table("boards", Connection ="AzureWebJobsStorage")] IAsyncCollector<BoardTableEntity> boardTable,
ILogger log)
{
log.LogInformation("Creating a new board.");
string requestBody = await new StreamReader(req.Body).ReadToEndAsync();
var input = JsonConvert.DeserializeObject<BoardCreateModel>(requestBody);
var board = new Board() { PlayerCount = input.PlayerCount };
board.Players.Add(input.Player);
await boardTable.AddAsync(board.ToTableEntity());
return new OkObjectResult(board);
}这一行是我添加到表存储表(“board”,Connection ="AzureWebJobsStorage") IAsyncCollector中的
正在抛出以下错误
函数(AzureFuncAppmmApi/CreateBoard)错误: Microsoft.Azure.WebJobs.Host: Error索引方法'CreateBoard‘。Microsoft.Azure.WebJobs.Host:不能将参数'boardTable‘绑定到IAsyncCollector`1’1类型。请确保绑定支持参数类型。如果使用绑定扩展(例如Azure存储、ServiceBus、计时器等)确保您已经为启动代码中的扩展调用了注册方法(例如builder.AddAzureStorage()、builder.AddServiceBus()、builder.AddTimers()等)。
当我在我的项目中没有启动文件时,我不知道在哪里注册builder.AddAzureStorage()。
附件是我的项目细节,任何帮助和指针都是见习的。

发布于 2019-12-15 01:12:48
我找到了答案,Microsoft.NET.Sdk.Functions更新到v3.0.2,在csprog文件中手动添加了下面的参考,它工作得很好。@tubakaya你的建议有所帮助
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="1.0.23" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Storage" Version="3.0.1" /> </ItemGroup>```https://stackoverflow.com/questions/59338367
复制相似问题