Blog Post

Apps on Azure Blog
4 MIN READ

A Glimpse into the Future: The Sidecar Pattern on Linux App Service

TulikaC's avatar
TulikaC
Icon for Microsoft rankMicrosoft
Feb 01, 2024

At Microsoft Ignite 2023, we unveiled our ongoing work on implementing a Sidecar pattern for Linux App Service. While the complete implementation is still in progress, we want to provide you with a sneak peek into this upcoming feature. Moreover, we'll guide you on how to start using it immediately (with certain restrictions) on Linux App Service. In this blog post, we'll delve into the Sidecar pattern, its significance, and practical ways to leverage it for your applications.

What is the Sidecar Pattern

Applications and services often require related functionality, such as monitoring, logging, configuration, and networking services. These peripheral tasks can be implemented as separate components or services, built using different languages and technologies.

 

The Sidecar pattern allows you to co-locate a cohesive set of tasks with the primary application but place them inside their own process or container. This container is attached as a supplementary container (the 'sidecar') to the main application container. The sidecar container runs alongside the primary application, providing additional functionalities, such as logging, monitoring, security, or other auxiliary services.

 

 

A Step-by-step guide to creating a Sidecar enabled site for Linux App Service

While we're diligently refining the portal experience for the Sidecar pattern on Linux App Service, you can already start experimenting with this exciting feature using ARM Templates.

 

In this section, we'll guide you through the steps of creating an application on Linux App Service, leveraging the Sidecar pattern.

Prerequisites:

  • Before we dive into the implementation, make sure you have Azure CLI installed. If not, you can install it by following the instructions here.
  • The application code, including the ARM template, for this example is available on here. Feel free to clone and explore the codebase to understand the integration of main and sidecar containers.

Sidecar example:

In this scenario, we’ll run a main app powered by NGINX, which will be supplemented by three sidecar containers executing Dotnet, Python, and Node.js applications. This example demonstrates how to create sidecars running different language stacks for your application.

This is our application architecture.

 

Let's discuss the ARM template before we get started.

We are creating a Linux app service with the linuxFxVersion property set to ‘sitecontainers’.

 

Now we can add a collection of sitecontainers. Each sitecontainer has 3 properties.

  • image – The container image that we want to use.
  • isMain – Only one of the containers in the collection should be marked as Main. This is the container which would be getting all HTTP requests.
  • targetPort – The port used for communication. For the main container, this should be 80, i.e., the HTTP port.

The complete ARM template is here.

 

To create the site, you can follow these steps. 

Open a command prompt and type in these commands - 

 

git clone https://github.com/Azure-Samples/appservice-linux-sidecar.git
cd appservice-linux-sidecar/nginx-sample/
az login
az group create --name <RESOURCE-GROUP> --location "<AZURE-REGION>"
az deployment group create --resource-group <RESOURCE-GROUP> --parameters webAppName=<WEB-APP-NAME> sku=P0v3 --template-file armtemplatemultictr.json 

 

 

 

Note:

  • This feature is only available in the region list given above. Please deploy your application in a region which is mentioned in the list.
  • Substitute the values for <SUBSCRIPTION-ID>, <RESOURCE-GROUP>, <AZURE-REGION> and <WEB-APP-NAME>.
  • You can use the ARM template here and chose an appropriate SKU. This document lists all the available SKUs for App Service App Service plans - Azure App Service | Microsoft Learn

Feel free to adapt the parameters and configurations based on your specific requirements. The setup will take a couple of minutes to complete.

 

The site might take 1-3 minutes to start. Once the site has started, you can test it out by using these endpoints -

  • <APP_URL>: Shows up Nginx home page from main Nginx container.
  • <APP_URL>/dotnetcore: Shows up welcome page from dotnet sidecar container.
  • <APP_URL>/python: Shows up welcome page from python sidecar container.
  • <APP_URL>/nodejs : Shows up welcome page from nodejs sidecar container.

 

In conclusion, the Sidecar pattern for Linux App Service opens a world of possibilities for enhancing your application's capabilities. Don't hesitate to experiment with deploying your custom or publicly available containers as sidecars, tailoring your setup to suit your specific needs.

 

As we continue refining and expanding this feature, stay tuned for updates! We are actively working on adding more regions and ensuring a smoother user experience.

 

Your feedback is invaluable in shaping the future of the Sidecar pattern on Linux App Service Stay up to date on new features and innovations on Azure App Service via Azure Updates (App Service) as well as the Azure App Service (@AzAppService) / Twitter feed.  There is always a steady stream of great deep-dive technical articles across the breadth of developer focused Azure services over on the Apps on Azure blog.  And lastly drop by the Azure Developers Community YouTube channel for developer focused content about tooling, languages and services running in the cloud!

 

Updated May 24, 2024
Version 8.0
No CommentsBe the first to comment