In this project, I will go through the following steps to create a resource group in Microsoft Azure using Visual Studio Code:
- Install the Azure CLI
- Sign in to the Azure portal
- Create a resource group in the Azure portal
Install Azure CLI and Sign In
The goal of this step is to set up the Azure CLI on your computer and log in to your Azure subscription.
Step 1: Install on Windows (using Winget)**
This step installs the Azure CLI through Windows’ package manager, Winget.
The Azure Command-Line Interface (CLI) is a cross-platform tool that lets you manage Azure resources directly from your local machine. On Windows, it can be installed using an MSI or ZIP package, allowing access via PowerShell or the Command Prompt (cmd.exe).
To install the Azure CLI, open the Visual Studio Code terminal and run the following command:
winget install Microsoft.AzureCLI
NOTE: After the installation is complete, you must close and reopen any active terminal window to use the Azure CLI.
Step 2: Verify the installation.
To verify the installation, run the Azure CLI command az --version command

This gives details of the Azure version in use.
Step 3: Sign In and Select Subscription
Execute the command az login in the terminal. This will open a web browser for interactive authentication and automatically configure your active Azure subscription.
Be aware that the browser window may open behind other windows or on the side of your screen, so if you don’t see it immediately, try minimizing or rearranging your open windows.
Step 4: Then Sign in and select Next.
Because I was already signed in, it came up

This step is necessary because Azure needs to identify who is executing the commands and determine which subscription (billing account) will be used.
It also ensures security by verifying that only authenticated and authorized users can access and manage cloud resources.
Step 5: To confirm my active subscription, I entered 1, because it is the only active subscription I have. If you have more than one subscription, enter the number that corresponds to your subscription.
Test the command: az account show to view account details.
Step 6: To make a subscription your active one, use the following command:
az account set --subscription "Your Subscription ID"
While you can specify the subscription by name, this may cause an error if multiple subscriptions share the same name in your Azure environment. Using the subscription ID is more reliable, as it is always unique.
Step 7: To confirm your active subscription run this command: az account show

Notice that the isDefault field for the subscription is now set to true. This means that this subscription is saved as your default, so you won’t need to log in again each time you restart Visual Studio Code.
Create a Resource Group
In this section, the goal is to create a resource group, which will serve as the logical container for all resources in this lab environment.
Step 1: Define variables for the resource group
It’s a good practice to store the resource group name and region in variables. This reduces the risk of typos and makes your script easier to reuse.
RG="azurecli-labnamz-rg"
This creates a shell variable RG holding the resource group name, which can be referenced later as $RG
LOCATION="eastus"
Create a Resource Group
In this section, the goal is to create a resource group, which will serve as the logical container for all resources in this lab environment.
Step 1: Define variables for the resource group**
It’s a good practice to store the resource group name and region in variables. This reduces the risk of typos and makes your script easier to reuse.
RG="azurecli-labnamz-rg"
This creates a shell variable RG holding the resource group name, which can be referenced later as $RG.
LOCATION="eastus"
This creates a shell variable LOCATION with the region, which can be referenced later as $LOCATION.
Step 2: Create the Resource Group
Now, create a resource group in the East US region. All resources for this lab will be placed here, which makes it easier to manage and clean up later.
Creating a resource group is required because every Azure resource must belong to one. Resource groups help you organize, monitor, and delete all related resources together.
It’s also a best practice for operational excellence, as grouping related resources improves manageability and makes cost tracking simpler.
Run the following command: az group create --name $RG --location $LOCATION
This will create a resource group named $RG, which acts as a logical container for all Azure resources in this lab.




Top comments (0)