1

I'm trying to run firebase functions locally but I get the error:

Exception while executing function: Functions.TestMe. Microsoft.Azure.WebJobs.Host: One or more errors occurred. Exception binding parameter 'req'. mscorlib: Cannot create an abstract class.

I have an azure cloud function project in VSCode with just this function:

using System.IO;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.Http;
using Microsoft.AspNetCore.Http;
using Microsoft.Azure.WebJobs.Host;
using Newtonsoft.Json;

using MongoDB.Bson;
using MongoDB.Driver;

namespace Learning.Platform
{
    public static class TestMe
    {
        [FunctionName("TestMe")]
        public static IActionResult Run([HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)]HttpRequest req, TraceWriter log)
        {
            log.Info("C# HTTP trigger function processed a request.");

            var db = new MongoClient(/*snipped*/);
            var hey = db.GetDatabase("dude").GetCollection<object>("hey");

            return (ActionResult)new OkObjectResult($"Hello, {hey}");
        }
    }
}

I would have thought this would just work because it's a fairly basic example of azure functions.

I'm using the Azure .net SDK version 2.9, Azure Tools 1.3.0 and the .Net Core 2.0 framework.

4

3 回答 3

1

对于遇到这种情况的任何人。我有同样的问题,并且能够解决它。我在试图弄乱并针对 azure 函数运行时的 v2 创建一个 F# HttpTrigger 函数时遇到了这个问题(因为他们还没有模板……)。

无论如何,我的问题是我在解决其他问题时已将 System.AspNetCore.Http Nuget 包安装到我的项目中。删除对 Nuget 包的引用(仅保留 Microsoft.NET.Sdk.Functions)后,它再次开始工作。

于 2019-01-06T20:57:20.677 回答
1

我因沮丧而放弃并卸载了 .net 核心框架和 azure 工具,然后重新安装了两者。

问题自行解决。

于 2018-01-27T18:29:19.893 回答
0

azure 存储程序集中存在一个问题 - 我在尝试运行 webjob 时遇到了同样的问题 - 但 azure 存储团队修复了它

于 2018-05-30T23:02:54.127 回答