我有azure函数应用程序,只要服务总线队列中有新项目,就运行用.NET Core 1.1编写的控制台应用程序。当我在本地主机中手动调用时,设置工作正常,但在托管环境中,它似乎没有按预期工作。这个过程很快就会退出。
#r "Newtonsoft.Json"
using System;
using System.Threading.Tasks;
using Newtonsoft.Json;
using System.Diagnostics;
public static void Run(string myQueueItem, TraceWriter log)
{
log.Info($"C# ServiceBus queue trigger function processed message: {myQueueItem}");
dynamic queueMessage = JsonConvert.DeserializeObject(myQueueItem);
string[] args = {
queueMessage.QueueId.Value.ToString(),
queueMessage.TenantId.Value.ToString()
};
log.Info(string.Join(" ",args));
string publishExe = @"D:\home\site\wwwroot\QueueTrigger\app.exe";
Process.Start(publishExe,string.Join(" ",args)).WaitForExit();
log.Info("Process Exit");
}
从Azure Function App登录
2017-10-13T14:43:54.293 Function started (Id=c80dfbb7-a06d-41e2-867e-1d526ee0bb70)
2017-10-13T14:43:54.450 C# ServiceBus queue trigger function processed message: {"QueueId":22,"TenantId":71}
2017-10-13T14:43:54.512 22 71
2017-10-13T14:43:55.075 Process Exit
2017-10-13T14:43:55.075 Function completed (Success, Id=c80dfbb7-a06d-41e2-867e-1d526ee0bb70, Duration=788ms)