2

I'm working on Azure WebJob. I started by creating a console application in Visual Studio and I published the application as a webJob in portal.azure from VisualStudio.

the WebJob is Triggered Manualy from its Webhook with username and password https://{MyWebAPP}.scm.azurewebsites.net/api/triggeredwebjobs/{MyWebJob}/run?arguments=1 2 3 from a second program.

this WebJob is verry simple. It only displays a the arguments 1,2 and 3.

when I run the program from CommandeLine like so dotnet MyProject.dll 1 2 3 it works well. but when I run it from webHook it does not read arguments.

here is my main script :

 class Program
{
    static void Main(string[] args)
    {

        Console.WriteLine("PARAMS Passed : " + string.Join(",", args));
    }
}

This is the log in the WebJob when I run from WebHook by Post request : [06/09/2018 15:19:37 > 33a9f2: INFO] PARAMS Passed :

and this is the console when I run it from commande Line : [06/09/2018 15:19:37 > 33a9f2: INFO] PARAMS Passed : 1,2,3

Can some One Help PLEASE. Tha,ks From All.

4

1 回答 1

8

这归结为 VS 发布错误。问题是它会自动生成一个run.cmd具有:

dotnet foo.dll

当它真的应该有:

dotnet foo.dll %*

这样参数就会流入您的控制台应用程序。

我会报告这个问题,但现在您可以按以下方式解决:

  • run.cmd在控制台应用程序的根目录(即 program.cs 旁边)显式创建一个。使用 . 使其包含上面的正确行%*。显然,使用您的实际 dll 名称而不是 foo.dll :)
  • 将其添加到您的项目中,并设置Copy to Output DirectoryCopy Always(默认为不复制)。

这将导致您run.cmd被部署,并且 VS 不会自动生成有故障的。

于 2018-06-09T16:44:31.533 回答