none
Azure Webjob high availability RRS feed

  • Question

  • I have a webjob that subscribes to an Azure service Bus topic. The webjob automates a very important business process. For the Service bus, it is Premium SKU and have Geo-Recovery configured. My question is about the best practice to setup High Availability for my webjob (to ensure that the process runs always). I already have the App Service Plan deployed in two regions, and the webjob is installed in both the regions. However, I would like my webjob in the secondary region to run only if the primary region is down - maybe temporarily due to an outage. How can this be implemented? If I run both the webjob in parallel, that will create some serious duplication issues. Is there any architectural pattern I can refer to, or use any features within App Service or Azure to implement this?
    Monday, August 12, 2019 5:53 PM

All replies

  • Hi tjosephp,

    Thanks for your question! Apologies for the delay in response.

    Are you running a continuous or triggered webjob? Assuming that you're running a continuous webjob and you don't want it to run on all instances, you can set it to be in 'singleton' mode by creating a file called settings.job alongside your WebJob files. It should contain:

    { "is_singleton": true }
    This solution was from this SO post.

    On another note, since it seems like high availability is a priority  for you. So I would suggest using Azure functions. Azure Functions is built on the WebJobs SDK, so it shares many of the same event triggers and connections to other Azure services but it also contains additional functionalities. Please see, Run a web application in multiple Azure regions for high availability for more information. 

    Reference architecture for a web application with high availability

    Hope that helps. Please let us know if you have further questions!

    Thanks,

    Grace

    Thursday, August 15, 2019 10:43 PM
    Moderator
  • Hi tjosephp,

    Did the above solution work for you?

    -Grace

    Monday, August 19, 2019 9:38 PM
    Moderator
  • Hi Grace,

    Tried out the solution. This will work only within a region, when you have multiple instances of App Service running. My question is more about when I run the same job in multiple regions (for Active-Active high Availability implementation) and each region has auto-scale setup - what is the approach recommended  by Microsoft to ensure that there is only one instance of webjob running at any given point in time?

    Thursday, August 29, 2019 5:09 PM