每当服务总线队列中有新项目时,我就有运行用 .NET Core 1.1 编写的控制台应用程序的 azure 函数应用程序。当我在本地主机中手动调用时,设置工作正常,但在托管环境中它似乎没有按预期工作。该过程正在快速退出。
#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)