Azure Hands-On - Deploy a multi-container group using a YAML file on ACI

Azure Hands-On - Deploy a multi-container group using a YAML file on ACI

Azure Learning Path for Cloud and DevOps Engineers

📝Introduction

In this hands-on lab, we walked through deploying a multi-container group using a YAML file using Azure ACI.

Azure Container Instances(ACI) supports the deployment of multiple containers onto a single host using a container group. It is useful when building an application sidecar for logging, monitoring, or any other configuration where a service needs a second attached process.

In this tutorial, you follow the steps to run a simple two-container sidecar configuration by deploying a YAML file using the Azure CLI. You learn how to:

  • Configure a YAML file

  • Deploy the container group

  • View the logs of the containers

📝Log in to the Azure Management Console

Using your credentials, make sure you're using the right Region. In my case, I am using the region France Central in my Cloud Playground Sandbox.

📌Note: You can also use the VSCode tool or from your local Terminal to connect to Azure CLI

More information on how to set it up is at the link.

📝Prerequisites:

  • Update to PowerShell 5.1, if needed.

  • Install .NET Framework 4.7.2 or later.

  • Visual Code

  • Web Browser (Chrome, Edge)

  • Azure CLI installed

  • Azure subscription

  • Docker installed

📝Setting an Azure Storage Account to Load Bash or PowerShell

  • Click the Cloud Shell icon (>_) at the top of the page.

  • Click PowerShell.

  • Click Show Advanced Settings. Use the combo box under Cloud Shell region to select the Region. Under Resource Group and Storage account(It's a globally unique name), enter a name for both. In the box under File Share, enter a name. Click ***Create storage (***if you don't have any yet).

📝Configure a YAML file

We adapted this example of the YAML file for this lab. It was created on my local PC.

This YAML file defines a container group with two containers, a public IP address, and two exposed ports.

apiVersion: 2019-12-01
location: francecentral
name: democontainerg
properties:
  containers:
  - name: aci-demo-app
    properties:
      image: mcr.microsoft.com/azuredocs/aci-helloworld:latest
      resources:
        requests:
          cpu: 1
          memoryInGb: 1.5
      ports:
      - port: 80
      - port: 8080
  - name: aci-demo-sidecar
    properties:
      image: mcr.microsoft.com/azuredocs/aci-tutorial-sidecar
      resources:
        requests:
          cpu: 1
          memoryInGb: 1.5
  osType: Linux
  ipAddress:
    type: Public
    ports:
    - protocol: tcp
      port: 80
    - protocol: tcp
      port: 8080
tags: {exampleTag: demo}
type: Microsoft.ContainerInstance/containerGroups

📝Deploy the container group

Deploy the container group with the following command, passing the YAML file as an argument and using our existing ResourceGroup:

az container create --resource-group <nameResourceGroup> --file deploy-aci.yaml

📝View deployment state

To view the state of the deployment, use the following command:

az container show -g <nameResourceGroup> -n <nameContainerGroup> --output table

📝View container logs

View the log output of a container using the following command. The --container-name the argument specifies the containers from which to pull logs.

az container logs -g <nameResourceGroup> -n <nameContainerGroup> --container-name <namecontainerapp>

📌Note - At the end of each hands-on Lab, always clean up all resources previously created to avoid being charged.

Congratulations — you have completed this hands-on lab covering the basics of deploying a multi-container group using a YAML file using Azure ACI.

Thank you for reading. I hope you understood and learned something helpful from my blog.

Please follow me on Cloud&DevOpsLearn and LinkedIn, franciscojblsouza