Create a Resource Group in Azure using Visual Studio Code

Published: (March 16, 2026 at 03:34 AM EDT)
4 min read
Source: Dev.to

Source: Dev.to

Create a Resource Group in Microsoft Azure using Visual Studio Code

In this project, I will go through the following steps:

  1. Install the Azure CLI
  2. Sign in to the Azure portal
  3. 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.AzureCLI

Note: After the installation finishes, close and reopen any terminal windows so the az command becomes available.

Winget install command output


Step 2 – Verify the installation

az --version

Verify the installation output

The command prints the Azure CLI version and its dependencies.


Step 3 – Sign in and select a subscription

az login

A 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.

Sign‑in screen


Step 4 – Complete the sign‑in flow

If you’re already signed in, the dialog may show a Next button.

Sign‑in continuation

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

Confirm subscription output


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

az account show output

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"
  • RG holds the resource‑group name and can be referenced later as $RG.
  • Replace YOUR_AZURE_REGION with 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

Resource name and 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 $LOCATION

This creates a resource group named $RG, acting as a logical container for all Azure resources in this lab.

Resource group created

0 views
Back to Blog

Related posts

Read more »