I've finally managed to get my function.json file to generate with mostly the correct attributes. The only problem I'm still struggling with is that the scriptFile path if set to the wrong value.
It gets generated with a value of "bin/MyFunctions.dll" instead of "../bin/MyFunctions.dll". This happens whether I build or publish.
When I try and run the script host I get the error:
The following 1 functions are in error:
Echo: Invalid script file name configuration. The 'scriptFile' property is set to a file that does not exist.
Manually changing the value to "../bin/MyFunctions.dll" solves the issue.
csproj file
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<NoWarn>NU1701</NoWarn>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Mvc.Core" Version="2.0.0" />
<PackageReference Include="Microsoft.Azure.WebJobs" Version="3.0.0-beta3" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="1.0.6" />
</ItemGroup>
<ItemGroup>
<Reference Include="Microsoft.CSharp" />
</ItemGroup>
<ItemGroup>
<None Update="host.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="local.settings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
</None>
</ItemGroup>
</Project>
EchoFunction.cs
using System;
using System.Collections.Generic;
using System.Text;
using System.Net;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Primitives;
using Microsoft.AspNetCore.Http;
using Microsoft.Azure.WebJobs.Host;
using System.Linq;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.Http;
namespace EchoFunctionNameSpace
{
public class EchoFunction
{
[FunctionName("Echo")]
public static IActionResult Run(
[HttpTriggerAttribute(AuthorizationLevel.Anonymous, "get", Route = "name/{name}/sname/{sname}")]
HttpRequest req, TraceWriter log, string name, string sname)
{
log.Info("C# HTTP trigger function processed a request.");
return new OkObjectResult($"Hello {name} {sname}");
}
}
}
host.json
{}
local.settings.json
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "",
"AzureWebJobsDashboard": ""
}
}
Those are the only 4 files I have. dotnet build/publish produces a file Echo/function.json that looks like this:
{
"generatedBy": "Microsoft.NET.Sdk.Functions.Generator-1.0.6",
"configurationSource": "attributes",
"bindings": [
{
"type": "httpTrigger",
"route": "name/{name}/sname/{sname}",
"methods": [
"get"
],
"authLevel": "anonymous",
"name": "req"
}
],
"disabled": false,
"scriptFile": "bin/AzureFunctions.dll",
"entryPoint": "EchoFunctionNameSpace.EchoFunction.Run"
}
../bin
just fine. Are all 4 files in the same folder without subfolders? – Mikhail Shilkov