Serverless on Azure
Functions vs. Container Instances
As part of our goal to improve resiliency at ASOS, we decided to replicate messages sent on an Azure Service Bus between two separate namespaces in different Azure regions in an active/active manner.
Azure doesn’t allow you to autoforward messages from one namespace to another, so we had to create our own service. We require our service to run in an isolated environment as the messages may contain encrypted personal information.
The resources on Azure that best met our requirements were Azure Functions and Azure Container Instances. Both of these are serverless offerings from Microsoft.
Azure Functions were Microsoft’s first serverless offering, allowing you to use a variety of events such as a message on an Azure Service Bus or a database update to trigger execution of your code (see the full list here).
Advantages of Azure Functions
- Can be seamlessly integrated with multiple Azure Components
- Easily deployed to using the Azure CLI
- Highly scalable
Disadvantages of Azure Functions
- Not isolated by default — isolating requires an App Service Environment that is very expensive
- Cannot benefit from a consumption plan when running in an App Service Environment
Azure Container Instance
Azure Container Instance (ACI) is a serverless container offering. It allows you to easily run Docker images without having to use a container orchestration tool such as Kubernetes or Docker Compose.
Advantages of ACI
- Hypervisor Isolation by default
- Ability to hide secure environment variables — such as connection strings
- Low cost
Disadvantages of ACI
- Newer and less proven than Azure Functions
- Requires the creation of an Azure Container Registry and Service principals to access the registry
With this in mind, we decided that the ACI was the most suitable approach for us. The low cost hypervisor isolation was an important factor — a long term goal for our team is to migrate fully to .NET core and Kubernetes. Using the ACI is a logical stepping stone as it allows us to benefit from containerisation without having to manage our own Kubernetes cluster.
If we didn’t process personal information, Azure Functions would have been a clear winner. The easy integration and the consumption plan make it simpler to write code, and it will automatically scale to handle our load. However, unlike ACI, Azure Functions were not designed with isolation in mind and this makes ACI better suited for our use case.
I’m River Phillips a Software Engineer Intern in Asos Tech, and a Computer Science Student at the University of Surrey.