Yeah, sure. But did you know that they’ve finally added the preview for using a PowerShell shell right from the browser?
“No! Do tell!”
For a while now you’ve had the ability to click what looks to be a command-prompt icon in the upper-right-hand corner of your Azure portal window.
That opens up a terminal-like window at the bottom of the browser, and you’re in a BASH session. There’s a drop-down at the top of that windows that suggested that you can choose between BASH and PowerShell, but PowerShell was “coming soon”. Well, soon was this week.
Setting it up is fairly straightforward. When you select PowerShell as the chosen shell, you are given a notice about the fact that you’ll need a dedicated storage account associated with this capability. This storage will be used to host your default cloud drive file share.
Note: Other than in this file share, there is no persistence between terminal sessions. More about this later.
As you see above, I didn’t have storage created for this, so after selecting my subscription, it created a storage account for me. I didn’t select the Show advanced settings option, but if I had I would have been able to choose existing or create new resource group, storage account, and file share.
When I was done, I had a default resource group created to host that storage account.
The shell windows displays the status of the configuration, which does take a minute or two…
And when you’re done, you’ve got a shell of POWER!
Notice at the top that can also now select between BASH and PowerShell, you can reset the session, click to common help topics, or manage settings (which as of right now is just manipulating the text size and providing feedback to Microsoft).
“Cool! So what can you do with it?”
I haven’t gotten that far.. but let’s try a couple of things to see what the environment looks like. Let’s start with a simple Get-Service cmdlet. It actually took about 5 seconds to respond, but when it did it came back with what I expected…
I have to assume that I can do Azure PowerShell commands, like listing the resource groups using Get-AzureRmResourceGroup…
The capture above is truncated because I thought I shouldn’t give you a list that also contains my subscription ID and other groups.. but trust me that this worked as expected.
“You mentioned that you have a file share created in storage. How do you get to that?”
You’ll notice that you start out in the Azure: drive. From here you can navigate to and manage Azure resources:
But if I want to get to the file system of the local machine, I can go $Home
Notice that I cd $Home, which brings me to a profile folder for my current session. Yes, it’s basically the default folders you’d see on a Windows Server 2016 machine (because, under the hood, that’s what it is!). However (and this is important).. putting items in any of that file system other than the linked folder CloudDrive will not persist from one session to the next. So, I cd .\CloudDrive\ and I’m now placed in the file share of my persistent storage. Whatever I do there will be persisted for me.
As an exercise for you, try creating a simple text file (echo “Hello, world!” > hello.txt) into both the Documents folder of the server, and of the root of the ./CloudDrive folder. Log out of Azure, and then back in and into your PowerShell terminal window, and see which file is still there when you get back. (NOTE: maybe you’ll get lucky and get the same machine if you do it right away. But if you wait 30 minutes for the VM to time-out, I bet the file in the Documents folder will be gone, but the CloudDrive file will still be there.)
For more official information, check out the announcement from the Azure Blog, plus the full Overview of Azure Cloud Shell (Preview), and Features & tools for PowerShell in Azure Cloud Shell.
Have you tried this yet? What do you think? Shoot me your questions and/or comments below.