Azure Functions 执行错误

Azure Functions execution error

我是 Azure Functions 的新手,我创建了名为 "myfunction" 的 azure 函数,其中包含
1) 控制台应用程序 (.exe)
代码:

console.writeline("Hello World!");

2) 运行.ps1 (Powershell)
代码:

.\<consoleappname>.exe

3) function.json
代码:

{
  "bindings": [
    {
      "type": "timerTrigger",
      "direction": "in",
      "schedule": "*/15 * * * * *",
      "runOnStartup": false
    }
  ]
}

当我运行这个函数时,它抛出如下错误:

Error:
             
Function ($nmfunction) Error: The binding name  is invalid. Please assign a valid name to the binding. 
             
Session Id: 3366132a28a043bab13f1cfa28781c9b
             
Timestamp: 2017-04-19T14:14:03.962Z

当我将 "name":"nmfunction" 添加到 json 绑定时,它不会在 UI 中抛出任何错误,但仍然不会 运行 控制台应用程序,并在日志中抛出错误,

2017-04-19T14:20:25.618 Function started (Id=9bc53d11-1189-43c1-9497-4438713025fa)
2017-04-19T14:20:26.009 .\ConsoleApp1.exe : The term '.\ConsoleApp1.exe' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
at run.ps1: line 1
+ .\ConsoleApp1.exe
+ _________________
    + CategoryInfo          : ObjectNotFound: (.\ConsoleApp1.exe:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
2017-04-19T14:20:26.009 Function completed (Failure, Id=9bc53d11-1189-43c1-9497-4438713025fa, Duration=389ms)
2017-04-19T14:20:26.024 Exception while executing function: Functions.nmfunction. Microsoft.Azure.WebJobs.Script: PowerShell script error. System.Management.Automation: The term '.\ConsoleApp1.exe' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

将绑定名称放入json文件,确实是必填参数

未找到您的 exe 文件,因为您假设当前文件夹是函数的文件夹,但事实并非如此。默认目录为 D:\Windows\system32。您可以通过在 .ps1 文件中添加一行来看到:

Write-Output "Current folder: $((Get-Item -Path ".\" -Verbose).FullName)";

一个选项是指定 .exe 文件的绝对路径,在您的情况下可能是 D:\home\site\wwwroot\nmfunction

有开放issue提供更直观的方式来访问本地文件。