meds
meds

Reputation: 22956

Cannot create an abstract class?

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.

Upvotes: 1

Views: 2434

Answers (3)

Doug G
Doug G

Reputation: 11

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

Anyway, my issue was that I had installed the System.AspNetCore.Http Nuget package into my project while I was troubleshooting something else. After removing the reference to the Nuget package (Leaving only the Microsoft.NET.Sdk.Functions) it started working again.

Upvotes: 1

flori
flori

Reputation: 71

There was an an issue within the azure storage assembly - i run in the same problem as i tried run a webjob - but the azure storage team fixed it

Upvotes: 0

meds
meds

Reputation: 22956

I gave up out of frustration and uninstalled the .net core framework and azure tools then reinstalled both.

Issue resolved itself.

Upvotes: 1

Related Questions