I will have an Azure webjob which will run every x minutes. The job listens to EventHub (pub/sub) for any incoming messages and processes the message.
What is the best way to create/design the webjob so that it stays awake processing the messages? I am unsure if always on is the right way to do this or just run the webjob every few minutes however during the executing of the webjob, I want the code to run so it can wait and listen for messages rather than just exiting almost immediately (imagine program.cs without a console.readline!)
Any ideas or thoughts?
You have 3 main options:
Create a console app and use Event Processor Host. Deploy it as a continuous web job.
Create a console app and use WebJobs SDK to create an EventHub-triggered function. Deploy it as a continuous web job.
Create an Azure Function with Event Hub trigger.
In 1 and 2 you will pay per hour of your Web App Plan instance. There's no point in making job timer-based instead of continuous: you keep paying per hour unless you shut down the Web App instance.
In 3 you pay per function execution time, which might be much cheaper if the amount of events is low.