DEV Community

lim cym
lim cym

Posted on

Local development environment configuration for Azure CLI

Install the following tools:
● Visual Studio Code with Azure Extensions
● The Azure CLI
● Configure your local Python environment for Azure
● The Azure Functions Core Tools, for local development of serverless functions.

Authenticate from your local shell. let Azure pop open a browser and go through their OAuth flow to authenticate you.

You can go to your local command prompt, and launch Azure Cloud Shell.

  1. You need to open the link that the shell prompted, and enter Azure provided code.

  2. After the authenticated, hit y to login.

Before you can use Azure Cloud Shell, you must register the Microsoft.CloudShell resource provider. Access to resources is enabled through provider namespaces that must be registered in your subscription.

1.On your subscription page, expand Settings in left menu and select Resource providers.

2.In the Filter by name... box, enter cloudshell to search for the resource provider.

3.Select the Microsoft.CloudShell resource provider from the provider list.

4.Select Register to change the status from unregistered/Re-register to Registered

PS: The first time you start Cloud Shell you're prompted to create an Azure Storage account for the Azure file share.

Set your subscription
1.List subscriptions you have access to:
az account list

By default, the command returns a JSON array. Each object in the array represents one Azure subscription and contains several key-value pairs.
name: The human-readable name of the subscription (e.g., "My Development Subscription").

id: The unique Subscription ID (a GUID). This is crucial for many CLI commands to specify which subscription you want to work with.

isDefault: A boolean (true or false) that indicates which subscription is currently active for your CLI session. Any commands you run will target the subscription where isDefault is true.

state: The current status of the subscription, most commonly "Enabled".

tenantId: The Microsoft Entra ID (formerly Azure Active Directory) tenant that the subscription belongs to.

Changing the Output Format
The default JSON output is great for scripting but can be hard to read. Use the --output (or -o) flag for better formatting.
az account list --output table

This command will display the subscriptions in a clean, tabular format, which is much easier for human eyes.

2.Set the active subscription for your session:
az account set --subscription 'my-subscription-name/my-subscription-ID'

PS: When you're done building something and don't need to run it anymore, delete the Azure resource group out of your organization. (If you've used proper infrastructure-as-code(IaC), you haven't lost anything - you can just deploy the code in a new account later!)

Top comments (0)