Azure provides the Azure Cloud Shell which includes almost every tool you will need already installed. But that requires you to be logged into the portal. And it times out after a short time. So you can administer Azure from your desktop.
There are tools you will normally want on your local computer to administer Azure:
- Azure Powershell
- Azure CLI and some additional tools (such as jq and Kubernetes)
- Visual Studio Code and extensions
All are cross platform tools. In this article, you will learn how to install the tools from the command line. And you will learn about Azure providers and how to add them to your subscription.
The purpose of this article is to provide a set of steps that you can use to get started using Azure from the command line. Tools change quickly, so the exact versions and the tooling can change. The point of the article is to provide a checklist and a set of tools that you will need as an cloud engineer.
Install or update PowerShell
PowerShell Core is a cross-platform (Windows, Linux, and macOS) automation and configuration tool/framework. PowerShell itself is now Open Source on GitHub.
The instructions on how to install are on the GitHub PowerShell. The site provides the links and instructions for how to install or update your PowerShell.
For detailed scripts on how install PowerShell in your automation on for your particular environment, see Installing various versions of PowerShell.
If you’re on Windows 10, you already have PowerShell 5.1 installed, which is high enough to install the Az module. You should be running version 7.0 or later. To check your version from inside PowerShell application, use
$PSVersionTable. If you are on a command line, use:
To see other ways to check, see How to Check the Current PowerShell Version.
Learn more about PowerShell, see Learning PowerShell on GitHub.
Install PowerShell for Azure using Scripts
Next, install Azure PowerShell. There are two PowerShell modules that support of Azure PowerShell, AzureRM and Az modules. You cannot have both installed at the same time. You should only use the Az module going forward. Install the Azure PowerShell module describes in detail how to check and install it.
The following PowerShell script shows how to install Az PowerShell and several other modules that you will need in other aricles in this blog.
The script uses
-Scope CurrentUser. To install for all users, use
-Scope AllUsers paramter and start PowerShell as admin or
sudo on the Mac. It also uses the
-Force parameter which is used to reinstall the modules. You will find that the versions of the modules may get updated separately.
You will need to agree to install from PowerShell Gallery.
Log into Azure using PowerShell
You can now log into Azure using PowerShell.
Connect-AzAccount can have parameters to specify a particular tenant, subscription, or to provide credentials using a service principal or managed identity. See Connect-AzAccount.
Install Azure CLI
You will want to install the Azure CLI and some additonal tools, such as jq and the Azure Kubernetes CLI.
To install on Windows from a script, you can use:
To install on Linux, use:
Log into Azure using Azure CLI
Once Azure CLI is installed, you can log in using:
If the CLI can open your default browser, it will do so and load an Azure sign-in page. Otherwise, open a browser page at
https://aka.ms/devicelogin and enter the authorization code displayed in your terminal.
NOTE: You can run Azure CLI commands from inside PowerShell. But Azure recognizes either the CLI log in or the PowerShell log in for its session state. And while you can mix or match tooling to some extent, you can use only the CLI using the CLI log in or the Azure PowerShell from the AzConnect-Account login.
Add to CLI
There are several additons to the Azure CLI, you will want:
- jq. Use it to slice and filter and map and transform the values the CLI returns in JSON.
- If you wan to use Azure Kubernetes Service, you will need an additonal module to log into kubectl.
The scripts in this blog need jq to parse the JSON that is returned by the Azure CLI. jq is a command line JSON processor; with it you can map, filter, slice, and transform JSON. The documentation shows how to download JQ.
If you are running in WSL 2 on Windows (Windows Subsystem for Linux) or in Linux, you can install jq using the following Bash script:
Install Kubernetes for CLI
It is intended for this blog to discuss Kubernetes at length, particularly Azure Kubernetes Service (AKS). You will need to install
Once you install your cluster, which is the subject of future articles, you can log into the cluster using something like:
AzCopy is a command-line utility that you can use to copy blobs or files to or from a storage account. It uses concurrency to scale up according to the number of machine’s logical cores. And if the connect drops, you can restart it without having to start over.
The following code can be used to install AzCopy using PowerShell:
To install manually, see Get started with AzCopy.
To use AzCopy, see azcopy for all the command line parameters.
Install or update Git
Follow the Git install documentation, which recommends that even if you have Git installed, you should update it.
On Windows go to https://git-scm.com/download/win and the download will start automatically. Note that this is a project called Git for Windows
On Ubuntu or on WSL on Windows:
You can develop, build and run your code in Docker containers on your desktop and they will work the same in the cloud.
Docker Desktop is an application for Mac or Windows desktop for you to build and share containerized applications and microservices.
Docker Desktop on Windows
Use the instructions on Install Docker Desktop on Windows. The steps consist of:
- Downloading the Docker zip file
- Enabling Hyper-V Windows Features
- Install Docker
- If your admin account is different to your user account, you must add the user to the docker-users group.
- Start Docker
Once you install Docker on your desktop, you will be able to see it from PowerShell or WSL or the command line. (WSL 2 runs inside Docker.)
Docker Desktop on Mac
Docker Desktop for Mac is the Community version of Docker for Mac. You can download Docker Desktop for Mac from Docker Hub.
Docker installation on Ubuntu
Use the Windows Docker Decktop installation if you are running WSL. Otherwise, use the documentation at Install Docker Engine on Ubuntu, which consists of several steps. Basically the steps:
- Set up the repository by updating
apt, add Docker’s official GPG key, add Docker’s apt repository.
- Install Docker Engine using
In production, you will want to review the installation scripts before running.
Install Visual Studio Code
Download Visual Studio Code from the installation page for Linux, Mac, or Windows.
To install in WSL or on Ubuntu:
With WSL, you can install and run Linux distributions on Windows. Add Remote – WSL extension, to get full Visual Studio Code editing and debugging support while running in the context of a Linux distro on WSL. See Developing in WSL to learn more. Try the Working in WSL step-by-step tutorial.
Start Visual Studio Code
To start code, go to the directory you want to use and type
Visual Studio Code Extensions
Before we start, Visual Studio Code supports Git by default, which means you don’t have to install any packages or extensions to use it. See Git Support.
The power of VS Code comes from the developer-supported extensions. Extensions will help with code highlighting, executing commands from within Code, and Intellisense.
Some interesting extensions:
- Docker helps you edit Dockerfile, docker-compose files. It also provides one-click debugging of Node.js, Python, and .NET Core inside a container.
- Kubernetes for developers building applications to run in Kubernetes clusters and for DevOps staff troubleshooting Kubernetes applications.
- Azure CLI provides IntelliSense for commands and their arguments.
- Terraform provides Terraform command support, resource graph visualization and CloudShell integration inside VSCode.
- Deploy to Azure helps you set up continuous build and deployment for Azure App Service or for Azure Kubernetes Service without leaving Visual Studio Code.
- Python offers IntelliSense, linting, debugging, code navigation, code formatting, Jupyter notebook support, refactoring, variable explorer, test explorer, snippets, and more.
- Git Graph for you to view a Git Graph of your repository, and easily perform Git actions from the graph.
You can list, add, and remove extensions from the command line:
When identifying an extension, provide the full name of the form
publisher.extension, for example
Install additonal Azure Providers
An Azure Provider is a set of services provided by Azure.
For example, if you want to store keys and secrets, you work with the Microsoft.KeyVault resource provider. This resource provider offers a resource type called vaults for creating the key vault.
For a list of the names of the providers and how they match to the services you need, see Resource providers for Azure services.
Not all providers are deployed in your subscription by default. From time to time, you will need a provider.
To see what providers are installed, use the following code in PowerShell:
To see what providers are installed, use the following code using the Azure CLI:
If the service provider you want is not installed, you will need to register it. For example, the following PowerShell script registers Azure Batch.
Or in Azure CLI:
For more details, see Azure resource providers and types.
In this article you have a good set of steps to get set up as an cloud admin for Azure. The scripts are meant to be suggestive and may need to be updated by the time you read this. But I hope you will find the checklist useful.
Windows now has a package manager as slick as
apt is on Linux. The new Windows Package Manager may make it much easier to get all of this installed on Windows in the future.