Mastering Azure CLI: A Step-by-Step Guide for Beginners
Azure CLI
Azure Command Line Interface
Azure automation
Azure CI/CD
Infrastructure as Code
Azure resource management
Azure DevOps
Azure CLI tutorial
Azure CLI installation
Azure CLI commands
Why CLI?
Automation: Azure CLI enables automation of repetitive tasks, such as provisioning resources, deploying applications, and configuring settings.
CI/CD Pipelines: Azure CLI is used in continuous integration and continuous deployment (CI/CD) pipelines to automate tasks, such as building, testing, and deploying applications.
Infrastructure as Code: Azure CLI helps manage infrastructure as code, allowing version control and reproducibility of resources.
Consistency: Azure CLI ensures consistency across environments, reducing errors and inconsistencies.
Efficiency: Azure CLI simplifies tasks, reducing the time spent on manual configuration and troubleshooting.
Scalability: Azure CLI enables scalable operations, making it easy to manage large environments.
Security: Azure CLI provides secure authentication and authorization, ensuring access control and compliance.
Monitoring and Logging: Azure CLI helps configure monitoring and logging, ensuring visibility and troubleshooting capabilities.
Collaboration: Azure CLI enables collaboration among team members, providing a common interface for DevOps tasks.
Integration: Azure CLI integrates with other DevOps tools, such as Jenkins, GitLab, and Azure DevOps, streamlining the DevOps pipeline.
Example :
Imagine you're setting up a new office with computers, internet, and software for your team. There are two ways to do this:
Manually (like using the Azure Portal):
You go to the store, buy each computer, install software on each one, and set up the internet for each desk.
It takes a lot of time because you have to do everything step-by-step.
Every time you set up a new office, you have to do it all over again, which can be tiring and you might make mistakes.
Automatically (like using Azure CLI):
You have a list of instructions that someone can follow to set up the office automatically.
This list can be a script or a set of commands that does everything for you: buying the computers, installing software, and setting up the internet.
You just run the script, and everything is set up the same way every time, quickly and without mistakes.
Step 1 :
Just go to Google, search for Azure CLI, and click on it.
Step 2 :
Go to the install tab, and you can either install Azure CLI directly or follow the command instructions for Mac, Windows, and Linux.
Step 3 :
Check whether it is installed using a command.
Command : az version
Then you need to see the version displayed above.
Step 4:
And you need to log in and connect the CLI to your Microsoft account to create the resources and configure from the CLI.
Command : az login
After that, you need to select your account and connect.
You are successfully connected; you should see the following as shown in the image.
Step 5 :
If I need to create any resource, I will follow the documentation provided by Azure in the Azure CLI documentation to create and delete a resource group through the CLI.
To create a resource group, the command is:
az group create --name Sundhar_resourcegroup --location eastus
In the command, you need to specify your resource group name and location based on your requirements.
After creation, you need to see the output displayed below.
Then we will check in the Azure console.
Hurray, it's created!
Now we will delete the resource group using the Azure CLI by finding the deletion command in the Azure CLI documentation, pasting it into the CLI, changing the name as needed, and hitting enter to delete it.
Command : az group delete --name <resource_group_name> --yes --no-wait
Hurray, it's getting deleted.
In this way, without using the Azure console, we can create resources through the CLI; for example, if we need to create 50 VMs at once, we would have to do it one by one in the console, but with IaC (Infrastructure as Code), we can create them all with one click.
Conclusion :
Using Azure CLI offers numerous advantages for managing and automating tasks in Azure environments. It enhances efficiency, consistency, and scalability by allowing users to script and automate repetitive tasks. Azure CLI also integrates seamlessly with CI/CD pipelines and other DevOps tools, ensuring smooth and automated workflows. By using Azure CLI, teams can maintain secure, reproducible, and well-documented infrastructure, ultimately leading to more streamlined operations and better collaboration. Whether you're provisioning resources, deploying applications, or managing infrastructure as code, Azure CLI is an invaluable tool for modern cloud management.
Subscribe to my newsletter
Read articles from Hema Sundharam Kolla directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Hema Sundharam Kolla
Hema Sundharam Kolla
I'm a passionate Computer Science student specializing in DevOps, cloud technologies, and powerlifting. I've completed several certifications, including AWS Cloud Practitioner and Google’s Generative AI badge, and I'm currently exploring both AWS and Azure to build scalable, efficient CI/CD pipelines. Through my blog posts, I share insights on cloud computing, DevOps best practices, and my learning journey in the tech space. I enjoy solving real-world problems with emerging technologies and am developing a platform to offer career advice to students. Outside of tech, I'm a competitive powerlifter, constantly striving to improve and inspire others in fitness. Always eager to connect with like-minded individuals and collaborate on projects that bridge technology and personal growth.