[英]Cannot create an abstract class?
I'm trying to run firebase functions locally but I get the error: 我正在尝试在本地运行firebase函数,但出现错误:
Exception while executing function: Functions.TestMe.
执行函数时发生异常:Functions.TestMe。 Microsoft.Azure.WebJobs.Host: One or more errors occurred.
Microsoft.Azure.WebJobs.Host:发生一个或多个错误。 Exception binding parameter 'req'.
异常绑定参数“ req”。 mscorlib: Cannot create an abstract class.
mscorlib:无法创建抽象类。
I have an azure cloud function project in VSCode with just this function: 我在VSCode中有一个带有此功能的天蓝色云功能项目:
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. 我正在使用Azure .net SDK版本2.9,Azure工具1.3.0和.Net Core 2.0框架。
I gave up out of frustration and uninstalled the .net core framework and azure tools then reinstalled both. 我放弃了挫败感,卸载了.net核心框架和Azure工具,然后重新安装了这两个工具。
Issue resolved itself. 问题已自行解决。
For anyone who runs into this. 对于遇到这个问题的任何人。 I had the same issue, and was able to resolve it.
我遇到了同样的问题,并且能够解决它。 I ran into this while trying to mess around and create an F# HttpTrigger function against v2 of the azure function runtime (since they don't have templates for that yet...).
我在尝试弄乱并针对azure函数运行时的v2创建F#HttpTrigger函数时遇到了此问题(因为它们尚无此模板...)。
Anyway, my issue was that I had installed the System.AspNetCore.Http Nuget package into my project while I was troubleshooting something else. 无论如何,我的问题是我在对其他问题进行故障排除时已经将System.AspNetCore.Http Nuget软件包安装到了项目中。 After removing the reference to the Nuget package (Leaving only the Microsoft.NET.Sdk.Functions) it started working again.
删除对Nuget包的引用(仅保留Microsoft.NET.Sdk.Functions)后,它再次开始工作。
天蓝色存储组件中存在一个问题-我遇到了与尝试运行Webjob相同的问题-但是天蓝色存储团队已将其修复
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.