Azure / azure-functions-host

The host/runtime that powers Azure Functions
https://functions.azure.com
MIT License
1.94k stars 441 forks source link

Issues running EventGridTrigger with func CLI or Azure #3674

Open TylerLeonhardt opened 6 years ago

TylerLeonhardt commented 6 years ago

Investigative information

Please provide the following:

Repro steps

Provide the steps required to reproduce the problem:

create a Node.js Function App then locally, run func init --worker-runtime node func new and select EventGrid Trigger func start

or publish it to Azure and run it in the Portal

Expected behavior

Function App starts correctly

Actual behavior

I get the following error:

func start

                  %%%%%%
                 %%%%%%
            @   %%%%%%    @
          @@   %%%%%%      @@
       @@@    %%%%%%%%%%%    @@@
     @@      %%%%%%%%%%        @@
       @@         %%%%       @@
         @@      %%%       @@
           @@    %%      @@
                %%
                %

Azure Functions Core Tools (2.1.725 Commit hash: 68f448fe6a60e1cade88c2004bf6491af7e5f1df)
Function Runtime Version: 2.0.12134.0
[10/24/18 5:37:14 AM] Building host: startup suppressed:False, configuration suppressed: False
[10/24/18 5:37:14 AM] Reading host configuration file '/Users/tyler/Code/JavaScript/jsazf-tyleonha/host.json'
[10/24/18 5:37:14 AM] Host configuration file read:
[10/24/18 5:37:14 AM] {
[10/24/18 5:37:14 AM]   "version": "2.0"
[10/24/18 5:37:14 AM] }
[10/24/18 5:37:14 AM] A host error has occurred
[10/24/18 5:37:14 AM] Microsoft.WindowsAzure.Storage: Settings must be of the form "name=value".
Listening on http://0.0.0.0:7071/
Hit CTRL-C to exit...
Settings must be of the form "name=value".
Application is shutting down...
[10/24/18 5:37:14 AM] Initialization cancellation requested by runtime.
Hosting environment: Production
Content root path: /Users/tyler/Code/JavaScript/jsazf-tyleonha
Now listening on: http://0.0.0.0:7071
Application started. Press Ctrl+C to shut down.
[10/24/18 5:37:15 AM] Stopping host...
[10/24/18 5:37:15 AM] Host shutdown completed.

In the Portal I get:

2018-10-24T05:33:43.754 [Information] Executing 'Functions.EventGridTrigger' (Reason='This function was programmatically called via the host APIs.', Id=518b3891-8058-4af9-afe3-0ead942b5511)
2018-10-24T05:33:44.037 [Error] Executed 'Functions.EventGridTrigger' (Failed, Id=518b3891-8058-4af9-afe3-0ead942b5511)
Unable to parse  to Newtonsoft.Json.Linq.JObject

Known workarounds

None at this time

Related information

Provide any related information

extensions.csproj

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>netstandard2.0</TargetFramework>
    <WarningsAsErrors></WarningsAsErrors>
    <DefaultItemExcludes>**</DefaultItemExcludes>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.Azure.WebJobs.Extensions.EventGrid" Version="2.0.0" />
    <PackageReference Include="Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator" Version="1.0.1" />
  </ItemGroup>
</Project>

local.settings.json

{
  "IsEncrypted": false,
  "Values": {
    "FUNCTIONS_WORKER_RUNTIME": "powershell",
    "AzureWebJobsStorage": "{AzureWebJobsStorage}"
  }
}

function.json

{
  "bindings": [
    {
      "type": "eventGridTrigger",
      "name": "eventGridEvent",
      "direction": "in"
    }
  ],
  "disabled": false
}

index.js

module.exports = async function (context, eventGridEvent) {
    context.log(typeof eventGridEvent);
    context.log(eventGridEvent);
};

a-h commented 5 years ago

I had to execute func azure functionapp fetch-app-settings <functionName> to get this running from here. It fills out the local.settings.json with values.

a-h commented 5 years ago

The issue is that the error message is not helpful, and that it happens in the first place. Why not just run the required CLI when you hit func start?

a-h commented 5 years ago

See https://github.com/Azure/azure-functions-host/issues/3835