Reputation: 592
I'm trying to deploy a .NET Core Console App as an Azure WebJob. All files etc. are getting copied to the right directories but my console app its output is a .dll, so it requires dotnet.exe
to start.
I've added a run.cmd file with the single command: dotnet QbiSync.dll
.
But the output is the following, it can't seem to find dotnet.exe:
[11/14/2016 13:15:29 > 4741da: SYS INFO] Run script 'run.cmd' with script host - 'WindowsScriptHost'
[11/14/2016 13:15:29 > 4741da: SYS INFO] Status changed to Running
[11/14/2016 13:15:29 > 4741da: INFO]
[11/14/2016 13:15:29 > 4741da: INFO] D:\local\Temp\jobs\continuous\QbiSync\x4jkoxww.vy4>dotnet QbiSync.dll
[11/14/2016 13:15:29 > 4741da: ERR ] 'dotnet' is not recognized as an internal or external command,
[11/14/2016 13:15:29 > 4741da: ERR ] operable program or batch file.
[11/14/2016 13:15:29 > 4741da: SYS ERR ] Job failed due to exit code 1
[11/14/2016 13:15:29 > 4741da: SYS INFO] Process went down, waiting for 60 seconds
Opening up a Console window using Kudu or in the Azure Portal and calling dotnet.exe
both works fine. I've also tried hardlinks like:
"D:\Program Files (x86)\dotnet\dotnet.exe" QbiSync.dll
"\Program Files (x86)\dotnet\dotnet.exe" QbiSync.dll
But they also give errors like:
[11/14/2016 13:59:29 > 4741da: ERR ] The filename, directory name, or volume label syntax is incorrect.
[11/14/2016 13:59:29 > 4741da: INFO] D:\local\Temp\jobs\continuous\QbiSync\hzlkzj1q.0jt>"D:\Program Files (x86)\dotnet\dotnet.exe" QbiSync.dll
Even though the dotnet.exe is actually located there.
Update:
Possibly related is that the source used @echo off
at the start of the script. But this is also a "command" that doesn't seem to be accepted.
[11/14/2016 12:37:57 > 4741da: INFO] D:\local\Temp\jobs\continuous\QbiSync\3n44nly1.ucq>@echo off
[11/14/2016 12:37:57 > 4741da: INFO]
[11/14/2016 12:37:57 > 4741da: ERR ] '@echo' is not recognized as an internal or external command,
Sources used:
Upvotes: 21
Views: 3709
Reputation: 12577
In my experience the simplest way to get a .NET Core Console App running within the context of an Azure WebJob is to create a self-contained .exe
.
You can do this with the following command:
dotnet publish -r win10-x64 -c Release
Note that the above command produces a different output than a
Right-click > Publish
action.
This will create a folder called win10-x64
within the bin\Release\netcoreapp2.0
directory of your console app. Inside of the win10-x64
directory is another directory called publish
.
Simply compress the
...bin\Release\netcoreapp2.0\win10-x64\publish
folder and upload as a new WebJob.
The trigger mechanism will detect the .exe
and run the code within the console app.
Upvotes: 3
Reputation: 43193
The issue is that your run.cmd
uses UTF-8 with BOM (byte order marks), which in some cases causes the script engine to misbehave. The fix is to not have the BOM.
There is a mention of this on the wiki (https://github.com/projectkudu/kudu/wiki/Web-Jobs), but granted it's easy to miss.
Upvotes: 27