In a prior post I went over getting started with Azure automation using Azure Automation Account. Another way to run PowerShell scripts against an Azure subscription is to use Azure Cloud Shell. I think of Azure Automation Account as PaaS PowerShell whereas Azure Cloud Shell is more like IaaS PowerShell (more like PowerShell web access running on an Azure container).
Azure Cloud Shell can be access from https://shell.azure.com/ or by clicking the Cloud Shell icon in the Azure Portal
We have most of the common PowerShell features such as tab completion. Initially Get-Module shows:
Copy/paste works, although keyboard shortcuts like CTRL-C and CTRL-V do not.
Unlike Azure Automation Account, we can install and import PS modules directly from the shell:
We get drive y: as an Azure file share for persistent storage, since these PS sessions are not..
We have access to more than PowerShell in this shell, such as Azure CLI and Python, which I choose to completely ignore in this post, and focus on PowerShell only 🙂
The Azure: drive provides access to the available subscriptions and their objects:
So, we can list VMs under a given subscription by simply iterating the objects under azure:\subscription_name\VirtualMachines !!
You can tell that the Azure: drive provider is using the required AzureRM cmadlets to fetch the requested objects. In this example, it’s calling Get-AzureRmVM cmdlet
We can upload files to the y: drive Azure file share directly from the Azure portal: