如何在 Azure 函数中启动我的控制台应用程序可执行文件

How to launch my console app executable in an Azure-Function

我已经在 Azure 门户上创建了一个 Azure-Function 应用程序。

D:\home\site\wwwroot 下,我有一个 MyApp 文件夹,里面有一个可执行文件 My.App.exe.

我在这个文件夹中还有一个 run.ps1 powershell 脚本,我只是想让 powershell 脚本启动 exe 应用程序。

我也有这个 function.json :

{
  "bindings": [
    {
      "name": "MyApp",
      "type": "timerTrigger",
      "direction": "in",
      "schedule": "0 */6 * * * *",
      "runOnStartup": true
    }
  ]
}

我必须在 运行.ps1 文件中输入什么才能调用 exe 应用程序?

我尝试了 & ".\My.App.exe",它给出了:

2017-02-24T15:15:47.204 Function started (Id=0f4b9b0b-a1f5-4812-9d93-c4017da5ac1c)
2017-02-24T15:15:51.562 & : The term '.\My.App.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
+ &
+ _
+ CategoryInfo          : ObjectNotFound: (.\My.App.exe:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException

我也尝试了 ".\My.App.exe",它给出了:

2017-02-24T15:26:29.312 Function started (Id=dced4842-069b-43c6-a055-aa06a46286c4)
2017-02-24T15:26:29.499 .\My.App.exe
2017-02-24T15:26:29.499 Function completed (Success, Id=dced4842-069b-43c6-a055-aa06a46286c4)

但它是因为 exe 从未启动过,因为它的第一行是 Console.WriteLine 并且日志是空的

放入 Powershell 文件的正确命令是什么?

根据评论中的讨论,一种解决方案是使用显式路径:

& 'D:\home\site\wwwroot\MyApp\My.App.exe'

您的 Azure 函数文件应始终存在于 'D:\home\site\wwwroot\{yourfunctionname}\'