Written by 10:12 am Microsoft, Microsoft Azure, PowerShell • One Comment

6 Command Line (PowerShell & CLI) Tips & Tricks for Microsoft Azure you should know about!

Command Line PowerShell & CLI Tips & Tricks for Microsoft Azure you should know about!

There are many experiences and possibilities to manage your Microsoft Azure resources, one of them being the command line experience using the Azure CLI or Azure PowerShell. In this blog post we are going to have a look at 6 tips & tricks for managing your Microsoft Azure resources using the command line with Azure PowerShell and the Azure CLI.

Here are 6 command line Azure PowerShell and CLI tips & tricks for Microsoft Azure you should know about:

Az Predictor – Using AI-powered Intelligent context-aware command completion for Azure PowerShell

Sometimes it is hard to find the right commands and parameters when you want to run commands in the terminal. The Az Predictor module for Azure PowerShell is a great tip and trick which makes it easy to get not only suggestions based on your history of commands, but also AI-powered intelligence suggestions for your Azure PowerShell commands.

Azure PowerShell Az Predicorl ListView
Azure PowerShell Az Predicorl ListView

Az Predictor is using the subsystem for PowerShell Predictive Intelligence in the PSReadline module. You can use a list or inline view and you can also switch between these two views using the F2 key. To jump from one parameter to another you can use ALT+A which makes it super easy to change the parameters of the command.

Az Predictor Inline View
Az Predictor Inline View

To leverage the Az Predictor module, you will need to run PowerShell 7.2 or higher, and PSReadline 2.2.2 or higher. To learn more about the Az Predictor module and PowerShell Predictive Intelligence, check out my blog post.

Az Find – Use AI to find az commands

Another great Azure CLI tip is the Az Find command. The az find command provides you with example commands based on Azure documentation and usage patterns of the Azure CLI and Azure Resource Manager users.

Az Find Example
Az Find Example

You can see that I was looking for how I can delete an Azure backup or recovery service vault. Since the Azure CLI find command learn from documentation and usage, I not only get the example of deleting an existing Recovery service vault, but it also lets me know of other related examples that might come in handy. To learn more about the Azure CLI find command, check out my blog post here.

Az Next – AI-powered interactive assistant for the Azure CLI

Az next is designed to guide users through their scenarios or sequence of jobs-to-be-done in tool, so that they can remain focused and avoid unnecessary external documentation searches. Az next adopts the latest design guidelines and should help making the Azure CLI more approachable for all users, including beginners.

There are two scenarios which are currently supported. The first one is a simple walkthrough for the next commands as soon as you execute az next. After that, the Azure CLI will return a set of command options, which are highly likely to come after your last command. This is super helpful if you are running a sequence of commands, the Azure CLI will provide you with predictive recommendations.

az next after az login
az next after az login

The second one is the end-to-end scenario walkthrough with the aim to help you achieve a specific scenario in mind. In these case the options show up in form of a summary instead of an explicit command, and the tool will guide you through individual command completion.

az next after creating a resource group
az next after creating a resource group

To learn more about az next, check out my blog post here.

Cloud Shell – Run your commands in the cloud

Azure Cloud Shell is an interactive, authenticated, browser-accessible shell for managing Azure resources. It provides the flexibility of choosing the shell experience that best suits the way you work, either Bash or PowerShell.

Cloud Shell offers a browser-accessible, pre-configured shell experience for managing Azure resources without the overhead of installing, versioning, and maintaining a machine yourself. Azure Cloud Shell is assigned per unique user account and automatically authenticated with each session. This makes it a private and secure environment.

Cloud Shell Bash and PowerShell
Cloud Shell Bash and PowerShell

You get a modern web-based command line experience which can be accessed from several endpoints like the Azure Portalshell.azure.com and the Azure mobile app, Visual Studio Code or directly in the Azure docs.

In the backend, Azure uses containers and automatically attaches an Azure File Share to the container. You can store the data on it, so your data is persistent. This persists your data across different Cloud Shell sessions.

You can choose your preferred shell experience. Cloud Shell supports Bash and PowerShell and included your favorite third-party tools and standard tools and languages. If something like a module is missing, you can add it.

There is much more you can do, check out my blog called Mastering Azure with Cloud Shell to learn some more unique tips and tricks to manage Azure using Azure Cloud Shell.

One thing I also want to mention is that you can also run Azure PowerShell or Azure CLI in Cloud Shell directly from your mobile phone, using the Azure mobile app!

Cloud Shell on Azure mobile app
Cloud Shell on Azure mobile app

Azure Automation – Schedule your scripts and runbooks in the cloud

Sometimes you want to schedule your scripts to run at specific times. With Azure Automation you can schedule your scripts to be run on Azure workers or on your own servers running in Azure, on-premises, or at other cloud providers.

Azure automation overview
Azure automation overview

Azure Automation delivers a cloud-based automation, operating system updates, and configuration service that supports consistent management across your Azure and non-Azure environments. It offers a couple of distinctive features, in this blog we are going to use the process automation feature, which allows you to run automation inform of PowerShell runbooks. We are going to use Azure Automation to schedule the scripts to run on Azure VMs.

Az Arc SSH – Connect to any server using SSH running anywhere

With Azure Arc, you can remotely manage your Linux and Windows Servers using the Azure control plane and management services, such as Azure PolicyUpdate ManagementSecurity CenterAzure Monitor, and many more. This allows you to manage servers running on-premises, at the edge, or in mutlicloud environments at scale. However, in some cases, you will need to have direct access to your servers for troubleshooting, for example using an SSH connection. In many of these hybrid and mutlicloud environments, direct network connectivity can be a challenge, which is why you now can get SSH access to your Linux and Windows Servers running anywhere using Azure Arc enabled servers.

SSH access to your servers running anywhere using Azure Arc
SSH access to your servers running anywhere using Azure Arc

SSH access to Azure Arc-enabled servers offers the following benefits:

  • Create interactive and automated SSH connections to Arc-enabled Servers
  • Securely access hybrid servers without any additional ports or a public IP address
  • Access to Windows and Linux machines
  • Leverage different authentication options: AAD login based on RBAC roles (Linux only), Key-based authentication, and username & password authentication
  • Connect as a local user or as an Azure user
  • Connect with existing SSH clients using a config file
  • Connect to servers using Azure Cloud Shell
  • Leverage existing workflows & scripts for Azure IaaS Virtual Machines on Arc-enabled Servers
Azure Arc SSH Access local User
Azure Arc SSH Access local User

To learn more, check out my blog post: SSH access to servers running anywhere using Azure Arc

What are your favorite Azure command line tips and tricks?

These are some of my favorite Azure command line tips and tricks for the Azure CLI and Azure PowerShell. Do you have any tips and tricks? Let me know in the comments below!

Tags: , , , , , , , , , , , , , , , Last modified: December 16, 2022
Close Search Window
Close