1

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"
}
6
  • 1
    That's odd. Show more details about your project setup. Commented Nov 18, 2017 at 9:00
  • Added more info Commented Nov 18, 2017 at 9:14
  • 1
    Hmm, copy-pasted your files, but build/publish produce ../bin just fine. Are all 4 files in the same folder without subfolders? Commented Nov 18, 2017 at 20:12
  • 1
    Any chance that you don't have the latest tooling or NuGet packages? Check under Tools / Extensions and updates, and under NuGet for the project. Commented Nov 19, 2017 at 2:24
  • All four files are in the same folder with no subfolders. I'm using v1.0.6 of the SDK and 2.0.1-beta.21 of the cli tools. As far as I can tell they are the latest versions? Cant get to the bottom of this... Commented Nov 19, 2017 at 6:40

1 Answer 1

1

I found what I believe to be a bug in the SDK functions generator code. I have submitted a pull request here to try and get it resolved:

https://github.com/Azure/azure-functions-vs-build-sdk/pull/143

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.