ultramcu - Fotolia
How Azure Cloud Shell can streamline resource management
Azure Cloud Shell's browser-based model frees IT teams from installation headaches but presents some formatting and timeout issues that admins need to watch for.
While Azure management tools, such as a PowerShell module or the Azure command-line interface, can help admins control their resources, these locally installed systems have their downsides, including software dependences, potential configuration challenges and latency from having to reach an Azure data center that's potentially thousands of miles away.
Azure Cloud Shell -- a browser-based command-line tool -- reduces these burdens. That said, it can also introduce its own set of challenges if admins aren't careful.
Accessible via a browser, Azure Cloud Shell provides admins with either a PowerShell console, still in preview, or a Bash console. It has the same look and feel of a command-line interface and supports various libraries and tools, as well as Node.js and Linux shell interpreters.
Upon initial connection, as shown in Figure 1, Azure Cloud Shell brings up a Linux container in the background and opens either a Bash or PowerShell Core console. For first-time users, the service will create an associated Azure storage account. Then, it uses Azure Files to mount a drive in the user's shell of choice, which provides storage for profiles, scripts or any other kind of file.
Three useful Azure Cloud Shell features
In addition to the benefits mentioned above, Cloud Shell offers a number of other native features that are helpful for admins.
For those who use the PowerShell console, Azure PowerShell drive is created by default. It enables you to interact with Azure resources in a hierarchical manner, just as you would a typical file system.
When Azure Cloud Shell places you directly into an Azure: prompt, as shown in Figure 2, you're on the Azure PowerShell drive. From here, you can run common PowerShell commands, such as Get-ChildItem, to, in this case, find all your subscriptions. You can drill down into each subscription as needed, as well as enumerate and manage any Azure resource without ever having to leave the Azure PowerShell drive.
Another helpful feature is Monaco Editor, shown in Figure 3, which lets you make edits to text files that are saved in Azure.
While it's possible to copy and paste code directly into Azure Cloud Shell, you might have scripts saved in an Azure Storage account that require a few edits. Rather than download the file locally, make your changes and then upload it again, the built-in Monaco Editor offers a faster and more direct way to make these edits.
Direct access to VMs
A third perk of Azure Cloud Shell is its native ability to connect to Azure VMs. In PowerShell, you can use the Invoke-AzureRmVmCommand and Enter-AzureRmVM commands to quickly bring up a console directly on the VM. This method reduces the risk of messing with various authentication schemes during VM management.
For example, if you want to run a command on your Azure VM from an on-premises device, you'd have to create a firewall rule and set up PowerShell Remoting. But with Cloud Shell, you can just run one of the Invoke-AzureRmVmCommand or Enter-AzureRmVM commands to invoke a session to your Azure VM.
Despite the benefits of Azure Cloud Shell, there are some drawbacks as well, most of which stem from the fact that it emulates a console experience in a browser.
For example, if you switch to a different browser tab while multitasking in Cloud Shell, you might see odd formatting issues, such as misplaced characters, as shown in Figure 4.
Also, there are occasions when the cursor positions become out of sync with the position you'd expect. In Figure 5, you can see that I began to copy/paste some text into the console and found the cursor position was much higher up in the command history.
It's also important to note that Azure Cloud Shell's behavior is different than a typical PowerShell console when you paste multiple lines.
For example, in Figure 6, I copied the numbers 1, 2 and 3 each onto a new line and pasted the sequence in Azure Cloud Shell and a local PowerShell console. Notice the difference? In the local console, on the right side of Figure 6, PowerShell doesn't treat each line separately. It allows me to paste the code in and add additional code, if needed. In Azure Cloud Shell, on the left side of Figure 6, it treats each line separately and, as a result, executes every line.
But perhaps one of the most frustrating drawbacks of Azure Cloud Shell is the 20-minute timeout feature. If admins open a new browser and begin working on something else for longer than 20 minutes, they'll have to reconnect to the Cloud Shell browser. If you have an editor open in that window, you can lose work this way.
That said, since the PowerShell console for Cloud Shell is still in preview, some bugs and oddities are expected, and Microsoft will likely resolve them over time.