I'm trying to run a function from a dll file but I'm getting this error:
2018-02-17T12:51:41.403 [Error] Exception while executing function: Functions.PreCompiledHttpTrigger. Microsoft.Azure.WebJobs.Script: One or more errors occurred. System.Web.Http: The request does not have an associated configuration object or the provided configuration was null.
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
namespace CompiledAzureFunctions
{
public class Utility
{
public static async Task<HttpResponseMessage> Run(HttpRequestMessage req)
{
// parse query parameter
string name = req.GetQueryNameValuePairs()
.FirstOrDefault(q => string.Compare(q.Key, "name", true) == 0)
.Value;
if (name == null)
{
// Get request body
dynamic data = await req.Content.ReadAsAsync<object>();
name = data?.name;
}
return name == null
? req.CreateResponse(HttpStatusCode.BadRequest, "Please pass a name on the query string or in the request body")
: req.CreateResponse(HttpStatusCode.OK, "Hello " + name);
}
}
}
function.json
{
"scriptFile": "bin/CompiledAzureFunctions.dll",
"entryPoint": "CompiledAzureFunctions.Utility.Run",
"bindings": [
{
"authLevel": "anonymous",
"name": "req",
"type": "httpTrigger",
"direction": "in",
"methods": [
"get",
"post"
]
},
{
"name": "$return",
"type": "http",
"direction": "out"
}
],
"disabled": false
}