I have azure function application that runs a console application written in .NET Core 1.1 whenever there is a new item in service bus queue. The set up is working fine when I invoke manually in local host, but in hosted environment it seems not working as expected. The process is exiting quickly.
#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");
}
Log from 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)