Create a Resource Group in Azure using Visual Studio Code
Source: Dev.to
Create a Resource Group in Microsoft Azure using Visual Studio Code
In this project, I will go through the following steps:
- Install the Azure CLI
- Sign in to the Azure portal
- Create a resource group in the Azure portal
Install Azure CLI and Sign In
This section shows how to install the Azure CLI on your computer and log in to your Azure subscription.
Step 1 – Install on Windows (using Winget)
The Azure CLI is a cross‑platform tool for managing Azure resources from the command line. On Windows you can install it with Winget.
winget install Microsoft.AzureCLINote: After the installation finishes, close and reopen any terminal windows so the
azcommand becomes available.

Step 2 – Verify the installation
az --version
The command prints the Azure CLI version and its dependencies.
Step 3 – Sign in and select a subscription
az loginA web browser opens for interactive authentication. After you sign in, Azure automatically sets the active subscription. If the browser window appears behind other windows, minimize or rearrange your screens to locate it.

Step 4 – Complete the sign‑in flow
If you’re already signed in, the dialog may show a Next button.

This step confirms the identity of the user and the subscription that will be used for subsequent commands.
Step 5 – Confirm the active subscription
If you have only one subscription, press 1 when prompted.
To view the details of the currently selected subscription, run:
az account show
Step 6 – Set a specific subscription as active
When you need to switch to a different subscription, use its subscription ID (preferred) or name:
az account set --subscription "YOUR_SUBSCRIPTION_ID"Using the ID avoids ambiguity if multiple subscriptions share the same name.
Step 7 – Verify the active subscription again
az account show
The isDefault field should be true, indicating that this subscription is now your default. You won’t need to log in again each time you restart Visual Studio Code.
Create a Resource Group
In this section we create a resource group, which serves as the logical container for all resources in this lab environment.
Step 1 – Define variables for the resource group
Storing the resource‑group name and location in variables reduces the risk of typos and makes scripts reusable.
RG="azurecli-labnamz-rg"
LOCATION="YOUR_AZURE_REGION"RGholds the resource‑group name and can be referenced later as$RG.- Replace
YOUR_AZURE_REGIONwith a valid Azure region (e.g.,eastus,westeurope, etc.).
Step 2 – Create the resource group
az group create --name "$RG" --location "$LOCATION"You should see output confirming that the resource group has been created, similar to:
{
"id": "/subscriptions/<subscription-id>/resourceGroups/azurecli-labnamz-rg",
"location": "eastus",
"name": "azurecli-labnamz-rg",
"properties": {
"provisioningState": "Succeeded"
},
"tags": null,
"type": "Microsoft.Resources/resourceGroups"
}Note: At this point you have the Azure CLI installed, are signed in to your subscription, and have created a resource group ready for further Azure resource deployments.
Step 1 – Define Variables for the Resource Group
Storing the resource‑group name and location in variables reduces the chance of typos and makes the script reusable.
# Resource‑group name
RG="azurecli-labnamz-rg" # reference later as $RG
# Azure region
LOCATION="eastus" # reference later as $LOCATION
Step 2: Create the Resource Group
Create a resource group in the East US region. All resources for this lab will be placed here, making management and cleanup easier.
Why a resource group?
- Every Azure resource must belong to a resource group.
- Groups let you organize, monitor, and delete related resources together.
- They improve manageability and simplify cost tracking.
Command
az group create --name $RG --location $LOCATIONThis creates a resource group named $RG, acting as a logical container for all Azure resources in this lab.
