azure cli use specific subscription

Target Azure Subscription with CLI: A Comprehensive Guide

By Ashley Walker
AD

The Azure CLI (Command Line Interface) is a powerful tool for managing Azure resources. One common task when working with Azure is specifying a particular subscription. This is crucial when your account has access to multiple subscriptions. Here's how you can use Azure CLI to work with specific subscriptions.

Before we dive into the details, ensure you've installed the Azure CLI and logged in with your credentials. You can check if you're logged in by running `az account show` which will display your current account details.

Switching Between Subscriptions

By default, Azure CLI uses the 'current' subscription. If you have access to multiple subscriptions, you need to switch to the desired one.

AD
Azure CLI Cheat Sheet — Resource Groups & VM Reference
Azure CLI Cheat Sheet — Resource Groups & VM Reference
a family tree is shown with several different types of items in the same area, including two
a family tree is shown with several different types of items in the same area, including two
GitHub - Azure-Samples/azure-cli-samples: Contains Azure CLI scripts samples used for documentation at https://docs.microsoft.com
GitHub - Azure-Samples/azure-cli-samples: Contains Azure CLI scripts samples used for documentation at https://docs.microsoft.com

To list all your subscriptions, you can use:

``` az account list ```

-switching to a subscription

Once you've identified the subscription you want to use, switch to it using:

an image of a computer screen with the word azure in blue and green on it
an image of a computer screen with the word azure in blue and green on it
a blue and white poster with the words azure cli commands on it's side
a blue and white poster with the words azure cli commands on it's side
Azure Kubernetes Service (AKS) vs Google Kubernetes Engine (GKE)
Azure Kubernetes Service (AKS) vs Google Kubernetes Engine (GKE)
``` az account set --subscription ```

Replace `` with the name or ID of your subscription.

Setting a default subscription

If there's a specific subscription you use most frequently, you can set it as the default to avoid switching every time.

``` az account set --subscription --is-default true ```

Working with Specific Subscriptions

Now that you're in the desired subscription, you can perform various operations. Let's look at some examples.

To list all the resources in a subscription, use:

``` az resource list ```

Creating a resource in a specific subscription

When creating a resource, you can specify the subscription using the `` parameter:

``` az resource create --resource-group --properties "" --resource-name --subscription --is-full-object ```

Upgrading a subscription

To upgrade a subscription, you can use:

``` az account upgrade --subscription ```

This can upgrade your subscription to a different pricing tier or upgrade to a new offer.

That's it! You've now learned how to use Azure CLI to work with specific subscriptions. Happy automating!

Azure Basics Explained Simply ☁️ | Microsoft Azure Cloud Services
Azure Basics Explained Simply ☁️ | Microsoft Azure Cloud Services
the azure cloud mindmap diagram
the azure cloud mindmap diagram
Using Azure Data Factory to incrementally copy files based on URL pattern over HTTP | Towards Data Science
Using Azure Data Factory to incrementally copy files based on URL pattern over HTTP | Towards Data Science
Create A Xamarin.Forms App Using Azure Mobile Services
Create A Xamarin.Forms App Using Azure Mobile Services
a poster with some notes on it that say azure clustering and how to use them
a poster with some notes on it that say azure clustering and how to use them
Enable your Azure subscription for Data Lake Store - Part One
Enable your Azure subscription for Data Lake Store - Part One
Understanding Media Services In Azure
Understanding Media Services In Azure
Azure Integration Services for Business Modernization
Azure Integration Services for Business Modernization
Configuring Budget Alert In Azure
Configuring Budget Alert In Azure
Extract Text From Images Using Computer Vision API and Azure Functions
Extract Text From Images Using Computer Vision API and Azure Functions
Microsoft Strategy Teardown
Microsoft Strategy Teardown
Announcing IoT extension for Azure CLI 2.0 | Microsoft Community Hub
Announcing IoT extension for Azure CLI 2.0 | Microsoft Community Hub
Explore Azure Machine Learning workspace resources and assets - Training
Explore Azure Machine Learning workspace resources and assets - Training
Igor Iric on LinkedIn: #azure #datamanagement #analytics #databricks #cloudarchitecture #cloud…
Igor Iric on LinkedIn: #azure #datamanagement #analytics #databricks #cloudarchitecture #cloud…
the azure services compared what to use and when infos are displayed in this diagram
the azure services compared what to use and when infos are displayed in this diagram
Multiple output in Azure Functions with C#
Multiple output in Azure Functions with C#
AD