2017-04-19 51 views
1

我是新Azure的功能,我創建了一個名爲 「myfunction的」 蔚藍的功能,其中包含
1)控制檯應用程序文件(.exe)
代碼:Azure的功能執行錯誤

console.writeline("Hello World!"); 

2 )run.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. 
+2

嘗試將'。\ ConsoleApp1.exe'修改爲'D:\ home \ site \ wwwroot \ nmfunction \ ConsoleApp1.exe' –

回答

4

把綁定的名字json文件,這的確是一個必需的參數。

您的exe文件未找到,因爲您認爲當前文件夾是該函數的文件夾,這不正確。默認目錄是D:\Windows\system32。你可以看到,通過添加一行.ps1文件:

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

一種選擇是指定要.exe文件,這很可能是你的情況D:\home\site\wwwroot\nmfunction的絕對路徑。

有一個開放issue提供了一種更直觀的方式來訪問本地文件。