Nirav Madariya
Nirav Madariya

Reputation: 1508

Azure Functions execution error

I'm new to Azure Functions, I've created azure function named "myfunction", which contains
1) console app (.exe)
Code:

console.writeline("Hello World!");

2) run.ps1 (Powershell)
code :

.\<consoleappname>.exe

3) function.json
code :

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

When I run this function, it throws an error as below:

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

when I add "name":"nmfunction" to the json binding, it don't throw any error in UI, but still don't run the console app, and throws error in log,

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.

Upvotes: 1

Views: 5027

Answers (1)

Mikhail Shilkov
Mikhail Shilkov

Reputation: 35124

Put the binding name to json file, it's indeed a required parameter.

Your exe file is not found, because you assume that the current folder is the function's folder, which is not true. The default directory is D:\Windows\system32. You can see that by adding a line to .ps1 file:

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

One option would be to specify the absolute path to .exe file, which would probably be D:\home\site\wwwroot\nmfunction in your case.

There is an open issue to provide a more intuitive way to access local files.

Upvotes: 5

Related Questions