Azure CloudShell is a game-changer for IT pros, offering an interactive command-line interface to Azure resources.
CloudShell provides a seamless experience, allowing you to access Azure resources without the need for a full Azure subscription.
With CloudShell, you can run Azure CLI commands, access Azure files, and even use Azure Storage Explorer from the comfort of your own environment.
Azure CloudShell is available in the Azure portal, making it easily accessible for anyone with an Azure account.
Getting Started
To get started with Azure Cloud Shell, you'll need to set it up by opening a web browser and navigating to https://shell.azure.com.
You'll then need to choose between Bash or PowerShell; for this tutorial, we'll be using PowerShell. If you're asked to create a new storage account, you can use the default or go for advanced if you wish to specify the names of the components yourself.
Here are the basic steps to follow:
- Open your favorite web browser and navigate to the Azure portal, http://shell.azure.com.
- Log into your Azure account, if required.
Once you've set up Azure Cloud Shell, you'll be dropped into a PowerShell environment, where you can start running commands.
Requirements
To get started with Azure Cloud Shell, you need to have access to an Azure Subscription.
The usage of Azure Cloud Shell itself is free, but it does require an Azure File Share with a Storage Account behind it to store files, which is billed against normal rates.
A Visual Studio subscription with Azure Benefits is ideal for using Azure Cloud Shell.
Set Up
To set up Azure Cloud Shell, you need to have access to an Azure subscription. It's free to use Azure Cloud Shell itself, but you'll need an Azure File Share with a Storage Account to store files, which will be billed against normal rates.
Open a web browser and navigate to https://shell.azure.com to get started. You'll be asked to choose between Bash and PowerShell - go with PowerShell for this tutorial.
You'll also need to create a new storage account, and you can either use the default or go for advanced if you want to specify the names of the components yourself.
Here are the key parameters to consider when creating your Cloud Shell resources:
Once you've provided the required parameters, you'll be dropped into your Azure Cloud Shell session, where you can start running commands.
Azure CloudShell Features
Azure CloudShell offers a flexible and secure way to manage Azure resources from anywhere, at any time.
You can use CloudShell in the Azure portal, which allows you to access a Bash shell directly from your browser.
CloudShell provides a persistent shell that stays active even when you close the browser, making it easier to manage your Azure resources.
Azure CloudShell supports multiple shells, including Bash, PowerShell, and Cloud Shell, allowing you to choose the one that best fits your needs.
You can use CloudShell to run Azure CLI commands, which gives you access to a wide range of Azure services and tools.
CloudShell also includes a file system that allows you to store and manage files, including Azure files and local files.
File Management
File Management in Azure Cloud Shell is a breeze. You can upload files from your local machine to the Cloud Shell environment using the upload/download icon in the toolbar, or by using the wget and curl Linux commands within the Azure Cloud Shell environment.
To upload a file, simply click on the upload/download icon, select Upload, and choose the file you want to upload. By default, the file will be saved in your home folder (/home/%USERNAME%), but you can move it to your clouddrive using the PowerShell cmdlet Copy-Item.
You can also download files from the Azure Cloud Shell file system by clicking on the upload/download icon, selecting Download, and specifying the path to the file you want to download. Alternatively, you can use the download command to download files from the Azure Cloud Shell.
Here are the steps to upload a file to Azure Cloud Shell:
- Pick or create a file on your local machine.
- Click on the upload/download icon in the Cloud Shell toolbar, click Upload and select a file on your local machine.
- Use the PowerShell cmdlet Copy-Item to move the uploaded file to your clouddrive.
Once you've uploaded a file to your clouddrive, it will persist over different Cloud Shell sessions, making it a convenient way to work with files across multiple sessions.
Cloning a Git Repository
Cloning a Git Repository is a straightforward process, especially if you're using the Azure Cloud Shell container, which comes with Git installed by default.
Git can be used to clone a repository to your clouddrive, making it available even after your current Cloud Shell session is ended.
To clone a repository, run the command `git clone` and provide the repository's URL.
The Azure Cloud Shell container has Git installed by default, making it easy to work with repositories.
Maybe you have a favorite GitHub repository you'd like to work on in Cloud Shell, no problem, just run `git clone` and provide the repository's URL.
The repository is cloned successfully if you can see it in the list of files by running the `ls -l` command.
Getting Drive Information
To get drive information, you can run the PowerShell cmdlet Get-CloudDrive. This command returns various information about your clouddrive, including the FileSharePath where you can access your clouddrive.
The FileSharePath property is where Azure Cloud Shell mounted the Azure file shared created when setting up the Cloud Shell. This is the path you'll use to access and manage your files.
You can also use the Get-ChildItem or dir command to view your current Azure subscription. This will give you a list of your available subscriptions, including the Pay-As-You-Go subscription mentioned in the example.
Frequently Asked Questions
What is Azure CloudShell?
Azure Cloud Shell is a browser-accessible terminal for managing Azure resources, offering flexibility in choosing between Bash and PowerShell. It provides a temporary, user-specific host for interactive management.
Is cloud shell the same as PowerShell?
Cloud Shell is based on Linux and uses a .NET Core-based version of PowerShell, which is different from the traditional .NET Framework-based version used on Windows. This means it's not the exact same as the PowerShell you're used to on Windows, but still offers many similar features and functionality.
Is Azure Cloud Shell free?
Yes, Azure Cloud Shell is a free service. However, excessive usage may incur consequences, so review the Azure Terms of Service for details.
Sources
- https://pnp.github.io/powershell/articles/azurecloudshell.html
- https://wmatthyssen.com/2022/02/01/upload-and-run-an-azure-powershell-script-from-your-clouddrive-in-azure-cloud-shell/
- https://katystech.blog/azure/azure-cloud-shell
- https://build5nines.com/azure-cloud-shell-tips-and-tricks/
- https://adamtheautomator.com/azure-cloud-shell/
Featured Images: pexels.com