Azure-functions-vs-build-sdk: [NoAutomaticTrigger] generates invalid function.json

Created on 16 Feb 2018  路  6Comments  路  Source: Azure/azure-functions-vs-build-sdk

Problem
When using Microsoft.NET.Sdk.Functions v1.0.8 so I can use the [NoAutomaticTrigger] trigger (#140), the generated function.json is invalid.

Reproduction path

  • Create Azure function
  • Add [NoAutomaticTrigger] attribute
  • Deploy to Azure using VS2017 v15.5.6
  • Run trigger manually using the Azure portal

Result

  • When the trigger is run manually, the Azure portal displays Status: 404 Not Found
  • Application Insights contains a trace with the following message:

The following 1 functions are in error:
Generated function.json

{
  "generatedBy": "Microsoft.NET.Sdk.Functions.Generator-1.0.8",
  "configurationSource": "attributes",
  "bindings": [
    {
      "type": "manualTrigger",
      "direction": "in"
    }
  ],
  "disabled": false,
  "scriptFile": "../bin/[path].Hosts.FunctionApp.dll",
  "entryPoint": "[Path].Run"
}

Workaround
If I manually add the name attribute in the bindings section using Kudu, the function works:

{
  "generatedBy": "Microsoft.NET.Sdk.Functions.Generator-1.0.8",
  "configurationSource": "attributes",
  "bindings": [
    {
      "name": "InsertNameHere",
      "type": "manualTrigger",
      "direction": "in"
    }
  ],
  "disabled": false,
  "scriptFile": "../bin/[path].Hosts.FunctionApp.dll",
  "entryPoint": "[Path].Run"
}

Most helpful comment

Unfortunately, https://github.com/Azure/azure-functions-host/wiki/function.json (which I used as a reference when implementing #140) describes an invalid manual trigger binding. Fortunately, there is an easier way than editing the function.json file in Kudu: just add a string input argument to your [NoAutomaticTrigger] function to generate a valid function.json file.

All 6 comments

Unfortunately, https://github.com/Azure/azure-functions-host/wiki/function.json (which I used as a reference when implementing #140) describes an invalid manual trigger binding. Fortunately, there is an easier way than editing the function.json file in Kudu: just add a string input argument to your [NoAutomaticTrigger] function to generate a valid function.json file.

@mathewc I think the fix for this should go in the runtime. Is there a reason name is required for manualTrigger? A manual trigger function deson't need to have parameters, and if it doesn't we don't know what to put in that name property.

The solution from @0xced works!

public static async Task Run(string input, TraceWriter log)

Creates the following (valid) function.json:

{
  "generatedBy": "Microsoft.NET.Sdk.Functions-1.0.12",
  "configurationSource": "attributes",
  "bindings": [
    {
      "type": "manualTrigger",
      "direction": "in",
      "name": "input"
    }
  ],
  "disabled": false,
  "scriptFile": "../bin/{namespace}.dll",
  "entryPoint": "{namespace}.Run"
}

Not doing anything with the input, other than that it creates the proper json. Thanks!

Closing since the issue is fixed per this comment - https://github.com/Azure/azure-functions-vs-build-sdk/issues/168#issuecomment-378913905

@vijayrkn The issue is not fixed, that is a workaround.

@zmarty I have re-opened. @soninaren - This is an issue in the actual generation. Can you have someone take a look?

Was this page helpful?
0 / 5 - 0 ratings