Migrating .NET Background Jobs to Azure

There are many azure services that can be considered to host your application code for background jobs, this post reviews just 4 of the possible options.

If you have multiple applications it may well be the case that not all applications need to be hosted using the same azure service. Different azure solutions might better suit different applications.

You might end up with some applications being migrated via a lift and shift to an azure VM,  for e.g a windows service that cannot be refactored, then others hosted as WebJobs or azure functions. The key is not to have a fixed idea that all background applications need to be migrated to a single azure service. 

Below are some key points on 4 possible options, what they are, when might be best to use each one and also some advantages and disadvantages of each.

What ?

Azure Virtual Machine (VM) An Azure VM gives you the flexibility of virtualization without having to buy and maintain the physical hardware that runs it
Azure WebJob WebJobs are a feature of the azure app service that enables you to run a program or script in the same instance as a web app, API app, or mobile app
Azure Function

Azure Functions allows you to run small pieces of code without worrying about application infrastructure.

A look at azure functions

Modernizing your application with azure functions

Azure Container Instances (ACI) Containers are a way to wrap up an application into its own isolated package. In its container, the application is not affected by applications or processes that exist outside of the container. Everything the application depends on to run successfully as a process, is inside the container.
Azure Container Instances(ACI) is useful for scenarios that can operate in isolated containers, including simple applications, task automation, and build jobs.

When?

Azure Virtual Machine (VM)
  • If the background task is implemented in a way that prevents it from being deployed as a serverless offering like Azure WebJob for e.g Windows services
  • If you require full control over the OS
  • No code changes – Lift and shift , a quick way to move your applications to the cloud
Azure WebJob
  • If you want to run an Executable or script e.g powershell
  • If you are already utilizing the azure app service for a web app for e.g
  • Ideally suited for migrating existing console applications from virtual machines to run more cloud-native, without re-writing the whole tool
Azure Function
  • If you want to control costs of application execution and the application fits within the scope of the consumption plan
  • If you want to trigger application execution via an API trigger
  • If you don’t want to manage infrastructure to run your code
  • If you are creating a new application or are happy to re-factor an existing application
Azure Container Instances (ACI)
  • If you have a standalone application that just requires running a single instance
  • If you are having issues with applications monopolizing resources on a VM
  • If you want to improve deployment – automate packaging of applications, better CI/CD pipeline

Advantages/Disadvantages?

  Advantages Disadvantages
Azure Virtual Machine (VM)
  • No application changes required
  • Can scale using azure scale set for example
  • A quick way of getting your application to the cloud
  • Slower to scale than containers minutes instead of seconds
  • Maintenance overhead of managing infrastructure e.g patching and backups
Azure WebJob
  • If already utilizing the azure app service, then deploying an application as a webJob will allow you to reuse the same app service with no additional cost.
  • By default, WebJobs scale with the web app. However, you can configure jobs to run on single instance
  • Management – manage alongside existing web application
  • Can be short or long running application
  • Uses same resources as web app if deployed in same app service, could be an issue if application is resource intensive
Azure Function
  • Cost efficiency – Only pay for duration of app execution under the consumption plan
  • Reserved resources just for application
  • Multiple options for triggering application inc http trigger
  • Highly scalable
  • For long running applications requires premium plan which is fixed charge
  • Not isolated by default — isolating requires an App Service Environment that is expensive, only an issue if you require the application to run in an isolated environment perhaps due to personal data
  • Cannot benefit from consumption plan in ASE
  • Required re-factoring of application
  • Posible upskilling of developers
Azure Container Instance (ACI)
  • Per second billing for the time the container is used.
  • Isolation by default
  • No container orchestrator needed
  • Don’t have to manage VM
  • Starts up in seconds as opposed to minutes for a VM
  • Possible up skilling of developers
  • Newer azure offering
  • Also requires deployment of an ACR (Azure container Registry) to store the containers

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *