Azure Cloud Shell is a powerful tool that can be used to access the Azure cloud. To use it, you need to have Visual Studio Code installed. If you don’t have it, you can install it here. Once Visual Studio Code is installed, open it and click on the File menu and select New File. In the New File dialog, enter azure-shell into the name field and click on the OK button. Now open your favorite text editor and create a new file called azure-shell.vscode in this directory. In this file, you will find all of the code that will be used to access Azure Cloud Shell. The first thing you will want to do is import the Azure Cloud Shell library: import “azure-shell/azure-shell” Next, you will need to create a function that will take an input of type string and return a result of type string: func main() { // input: “name” string var result = “John” // output: “John” } Next, you will need to create an instance of Azure Cloud Shell: azureShell = new AzureCloudShell() Now that your azure-shell instance is created, you can use it to run some tests:


The Azure Cloud Shell is an integrated CLI experience available to Microsoft Azure cloud users. Usually available in either a Linux Bash shell or PowerShell prompt, you can also utilize the Azure Cloud Shell directly in the VS Code integrated development environment.

What Features Does the Azure Cloud Shell Offer?

Bash shell for Linux style commands PowerShell for Windows familiar developers Built-in PowerShell Modules Az. Accounts Az. Compute Az. Network Az. Resources Az. Storage AzureAD. Standard. Preview AzurePSDrive PSCloudShellUtility Latest version of Azure CLI (az command) available to both Bash and PowerShell environments Latest PowerShell available in Bash environment using pwsh runtime

The Azure Cloud Shell automatically manages authentication and setup for all associated modules and tools. This makes it quick and easy to get started managing your Azure environment from the command line.

Getting Started with the Azure Cloud Shell

Most users will start with the Azure Cloud Shell in one of two ways. Either through the Azure Portal and its inline shell access or through a direct web link to the Azure Shell.

Azure Portal Shell Access

Connecting to the shell via the Azure Portal is as simple as clicking on the terminal icon next to the search bar in the upper portion of the screen.

As soon as you click on this icon, one of two shells will show, either the Bash or PowerShell terminal as seen below. In the first image, you will see that the Bash terminal has connected. If you use the dropdown to the upper left of the terminal, you will have the option for either Bash or PowerShell.

Direct Shell Access via Web

Another common method of starting the Azure Cloud Shell is through a direct link to the website itself. Navigating to https://shell.azure.com/ will open either the Bash or PowerShell terminal. If you are not logged in, you will be prompted to do so prior to access. Once authenticated, you will have immediate access to the same terminal as within the Azure Portal.

Integrating the Azure Cloud Shell with VS Code

Of course, as a developer, this may not be the most efficient method. A very popular editor released by Microsoft, VS Code, has become a well-integrated solution for access to many different Azure resources and notably the Azure Cloud Shell.

With an integrated development workflow and quick access to common Azure commands from within the editor itself, a lot of time and energy can be saved. What are the steps necessary to get started using the Azure Cloud Shell in VS Code?

The quickest and easiest way to get started is to install the official Azure Account extension from Microsoft. Navigate to the “Extension”s icon on the left-hand menu of VS Code and search for Azure Account. Once the extension has been located, click on the “Install” button. After installation, you might have to restart VS Code, but as soon as the extension is available, you will have access to a number of different commands.

To locate all the available commands, type ctrl-shift-p to open the command pane for VS Code. Click or select the “Azure: Open PowerShell in Cloud Shell” option.

If you are not already signed in through the Azure Account extension, a prompt will show. Click on “Sign In” to be taken to a webpage using your default browser that allows you to sign into your Azure account.

Choose the account that you are intending to use with the Azure Cloud Shell and enter your password, if necessary. Once entered, the page will prompt you to close the open browser tab or window, and VS Code will continue to authenticate in the background.

This process is the same whether you choose the PowerShell terminal or the Bash terminal. As you can see below, once you have authenticated both terminals become available to you.

Conclusion

Integrating the Azure Cloud Shell into VS Code makes a developer’s job much easier. Quick access to commands as you are developing is important to gathering information and running commands to see the results of those changes without switching between different windows constantly. Use the Azure Cloud Shell within VS Code today and see how much your efficiency can improve!