This is chapter-4 of my Azure Cloud Shell Web Series and today we are discussing – Linux Containers as a back end of Azure Cloud Shell. Microsoft announced in May that this was their plan, but it was just implemented last week. Now every Azure Cloud Shell session runs in one in thousands of geo-dispersed Linux Containers, that brings speed, consistency, and a simpler user experience to all Azure Cloud Shell users. But certainly Windows-only users will observe some minor hiccups in getting used to it in a *NIX environment.
If you like this video, please subscribe to my YouTube channel here which is the motivation for me to create more such videos 🙂 thank you!
Azure Cloud Shell on Linux Containers
What has changed after Microsoft’s move to use Linux Containers for the Azure Cloud Shell –
Linux containers are faster compared to Windows containers, so a huge drop in loading and setup time when you launch the Azure Cloud Shell.
Following is a tweet from Danny Maertens from the PowerShell Team, that demonstrates the Speed differences from Launch to setup of Azure Cloud Shell Linux Containers in a browser based terminal compared to the Windows Containers.
Read about the changes to #PowerShell in Azure #Cloud #Shell! (https://t.co/nrwYkt3FRI) Look forward to: PowerShell Core 6 as the default experience, running on Linux, and faster start-up! pic.twitter.com/ljO9gbDwWa
— Danny Maertens (@maertend33) May 21, 2018
No longer a Windows Experience
Most of the use cases of Azure Cloud Shell are independent of underlying operating system, so switching to Linux Containers brought more good with minimum impact.
For a fresh spin of Azure Cloud Shell you’ll notice that both Bash and PowerShell now run and share the same Linux environment and you can switch between these shell as per your requirement.
Mostly the experience is same, like the Azure Drive (Azure:\) works exactly like it used to work before on Windows Containers, but you should avoid the ‘ls’ command which is also native to Linux to navigate your AzureRM resources under the Azure drive, and use Get-ChildItem (gci) instead .
File system may seem a bit different if you’ve been only Windows user, but that is just an initial friction and you’ll get used to it in no time.
Moving to Linux Container also changed your $home drive and default location of your modules, now there is no .pscloudshell folder in Cloud Drive that holds your module like on a Windows Container.
Runs on PowerShell Core 6.x instead of PowerShell 5.x
These Linux Container is now enabled by PowerShell Core running on .NetCore in the Azure Cloud Shell, that means some of your modules which are not yet supported on .Net Core won’t be able to run in the cloud shell.
But Microsoft is heavily investing time and efforts to port these modules to .Net Core and they would be soon available and fully supported in the Azure Cloud Shell, like the AzureAD module.
PowerShell.exe Since the Azure Cloud Shell defaults to Linux Containers going forward, now there is no PowerShell executable available and instead you’ll have to use pwsh command to call PowerShell. Please refer to this issue on GitHub if you want to know why this was done.
Linux environment is case sensitive, that means at Linux Operating System level ‘ls’ and ‘LS’ are two different things, that is something many Windows user won’t like because Windows PowerShell (v5.x) is case insensitive.
You may run into errors if you are not careful of the case, working with native Linux commands, file names and paths like in below image, on contrary PowerShell cmdlets will run in any case.
Storing your work
Cloud drive mounted on the Azure Cloud Shell is still available and could be used on both a Windows or Linux Containers to store and persist your work and scripts. Save files to $home\CloudDrive for persistence across your cloud shell sessions. If you want to know more about Azure Cloud Shell – Storage check out this link.
Beware of Aliases
Some common aliases in Windows PowerShell (v5.x) like ls, sleep that are already LINUX commands will not work in Linux containers like expected in PowerShell 5.x. Aliases were used in PowerShell as a transition aid for Linux administrators to PowerShell. But in PowerShell Core any alias which is also a Native command in Linux is not an alias anymore.
Like if you run ‘ps’ in Azure Cloud Shell it runs the native Linux Command to list processes, not Get-Process that returns PowerShell [System.Diagnostics.Process] objects
Azure Cloud Shell from Visual Studio Code
In my last video chapter , I demonstrated how to use Azure Cloud Shell from your Visual Studio Code editor, but after these new changes when I run the cloud shell from visual studio code I still see it uses a windows container.
After little research on the Azure Account extension’s repository on GitHub, it seems like Microsoft is already working on this, see this commit on GitHub. Until that time I believe it will still launch the Azure Cloud Shell from Visual Studio Code editor inside a Window Containers.