Reputation: 1535
I'm trying to understand how an Azure WebJob setup to be triggered on a queue is supposed to continuously run in the cloud without being aborted due to a timeout.
The idea of a web job being triggered on a queue is that it will run continuously and then your function will be triggered when a new item is added to the queue.
The way it works in reality is that if nothing is currently executing, and nothing is added to the queue in a 120 second time period (which is configurable) your web job will ABORT completely and it will stop listening to items being added to the queue. It will require intervention to restart it.
Microsoft has provided somewhat useful, and pretty out of date, documentation for web jobs, and it paints a rosy picture of how to create it in C#.
(Yes, I have enabled "Always On" on the app service)
I can configure the time period to 2 hours, 24 hours, etc, but it is not bullet proof. What is Microsoft's actual recommendation to having a triggered web job run without idling out and aborting?
An actual, Always On web server, doesn't require the service host to be restarted after it has been idle. I expect nothing less from a web job.
Someone please tell me what is the guidance from Microsoft on this? If it doesn't exist, tell me why they are broadcasting a feature without any real good implementation pattern guidance.
Upvotes: 0
Views: 113
Reputation: 29940
My solution is that deploy the azure webjobs as continuous type via .zip file. And it does not have such issue.
First create a .net core console project, and install all the necessary nuget packages -> write your queue trigger function in Function.cs->add appsettings.json, put your storage connection string in it(Note that you also need to right click the appsettings.json -> select Properties -> set "Copy to Output Directory" to "copy if newer").
Then I publish the project -> in visual studio, right click your project -> select publish -> in the new window, select Folder and also choose the path(you can keep the default path), then click publish button:
After the publish is completed, you can go to the path where you defined in the above step(by default, the path looks like this: webjob222\bin\Release\netcoreapp2.1\publish
)
Create a run.cmd file, and write something like dotnet your_webjob_name.dll
into run.cmd -> then send all the files here into a .zip file.
Nav to azure portal -> your web app -> in the left blade, select webjobs -> add, upload the .zip file, and set the Type as Continuous.
After the webjobs is created, you can do your test. It works fine at my side, no such errors(I left the webjobs as idle for about 45 minutes, then add a queue message, it works fine). Here is the log of the webjobs:
Upvotes: 0