Azure Compute

Practice – Azure Container Instances (ACI) Deployment using Azure CLI

Table of Contents

Azure Container Instances Overview

if you are using containers or just started you should definitely check out other container instances, today I will give you a brief on how can you deploy ACI using Azure CLI
before we start with what container instances are, let’s talk about What are containers?

A container is a standardized unit of software, what does this mean?
It has just a package software that should be able to run reliably between each another computing environment so that sounds very similar to what virtual machines are so let’s talk about

What is the difference between virtual machines and containers?
So in the case of virtual machines, there’s always a host, the host is created from the infrastructure on top of which there’s a hub hypervisor running this hypervisor is responsible for hosting virtual machines and managing them so there’s always a virtual machine on which you always have something called guest operating system so, therefore, you need to virtualize an entire operating system for you to be able to host your application and you need to do that again for every single application.
When it comes to containers you also have a host that hosts again the infrastructure but what’s a difference here is, you have a host operating system on top of which something called run time this run time is responsible for hosting and managing containers but what is good here is that from here onwards you can just host containers, you no longer need that guest operating system for each application and each container, therefore, releasing a lot of unnecessary resources which allow you to host more containers and more applications

So the main difference here

Less development overhead so your developers don’t need to create those images for virtual machines which takes a lot of time. Creating containers take just minutes as you’ve seen there are no guest operating systems, so there are much fewer resources consumed, also since there’s no guest operating system loaded into the container the file itself is in a much smaller size it’s from hundreds of megabytes down to 20 30 megabytes of size since the small size is there and the less consumption is required that means they also are starting up faster you can get your containers running in just seconds.

Here are some of Azure Container Instances (ACI) benefits:

  • Fast startup: Launch containers in seconds.
  • Per second billing: Incur costs only while the container is running.
  • Hypervisor-level security: Isolate your application as completely as it would be in a VM.
  • Custom sizes: Specify exact values for CPU cores and memory.
  • Persistent storage: Mount Azure Files shares directly to a container to retrieve and persist state.
  • Linux and Windows: Schedule both Windows and Linux containers using the same API.

Lets Practice Azure Container Instances using Azure CLI Commands

Create Resource Group

Create a new resource group with the name RG-ACI-Exercise so that it will be easier to clean up these resources when you are finished with the module. If you choose a different resource group name, remember it for the rest of the exercises in this module. You also need to choose a region in which you want to create the resource group, for example, West Europe.

az group create --name RG-ACI-Exercise --location westeurope

Specifying a DNS namewith Random VARs

Create Azure Container

Show container Details

Show container IP

What are container restart policies?

Azure Container Instances has three restart-policy options:

WHAT ARE CONTAINER RESTART POLICIES?
Restart policyDescription
AlwaysContainers in the container group are always restarted. This policy makes sense for long-running tasks such as a web server. This is the default setting applied when no restart policy is specified at container creation.
NeverContainers in the container group are never restarted. The containers run one time only.
OnFailureContainers in the container group are restarted only when the process executed in the container fails (when it terminates with a nonzero exit code). The containers are run at least once. This policy works well for containers that run short-lived tasks.

Show container Logs

Specifying a DNS name label with Random VARs

Create a container that works with your database

The two environment variables you created in the last part, COSMOS_DB_ENDPOINT and COSMOS_DB_MASTERKEY, hold the values you need to connect to the Azure Cosmos DB instance.

Create a container with Cosmos DB

Run the following az container create command to create the container.

Show container that works with your database

In a browser, go to your container’s IP address, Once the app is available, you’ll see this.

Try casting a vote for cats or dogs. Each vote is stored in your Azure Cosmos DB instance.

Use secured environment variables to hide connection information

Mahmoud A. ATALLAH

Microsoft MVP & MCT | Azure Service Delivery Lead with over 12 years of experience in Microsoft solutions and Professional services, Leading the Azure team to help our customers to build successful Azure practices, Blogger, Speaker, and Community leader. Focus on Azure, Cloud Security, Modern Workspace, AVD, Infrastructure as Code, Endpoint Management, Office 365, EMS.

Recent Posts

Microsoft MVP Summit 2024 Experience: A Journey to Seattle

A few weeks ago, Microsoft MVPs (Most Valuable Professionals) and RDs (Regional Directors) got together…

1 month ago

Web Summit Qatar | AI Copilots: Driving startup success

Description: Join us at Web Summit Qatar for an engaging session on how Azure AI…

2 months ago

My 2023 Highlights: A Year of Growth and Achievements 🌟

As the year 2023 draws to a close, it's the perfect time to reflect on…

4 months ago

Investigate and Respond to Incidents with Microsoft Security Copilot

Introduction Imagine harnessing the power of GPT-powered natural language to seamlessly investigate and respond to…

6 months ago

Introducing Microsoft Applied Skills – Your Fast Track to Verify Tech Proficiency

Introduction: In a dynamic tech landscape, Microsoft continues to pioneer innovative ways to empower individuals…

6 months ago

GITEX GLOBAL | Azure AI and the Future of SaaS

Description: Join us at GITEX as we explore the exciting world of Azure AI and…

7 months ago