Being that it is hosted in the cloud it goes without saying that it should be available from anywhere you are, so Microsoft provides access via multiple paths: 1. Azure Portal 2. Direct Browser Access via shell.azure.com 3. Azure's mobile app for Android or iOS 4. Visual Studio Code via the Azure Account extension [gallery type="m" size="small" link="file" ids="eyJ1cmwiOiJodHRwczpcL1wvYmxvZy5weXRoaWFuLmNvbVwvd3AtY29udGVudFwvdXBsb2Fkc1wvYWNjZXNzXzFfYXp1cmVwb3J0YWwucG5nIiwidGl0bGUiOiJhY2Nlc3NfMV9henVyZXBvcnRhbCIsImNhcHRpb24iOiJBenVyZSBDbG91ZCBTaGVsbCB2aWEgQXp1cmUgUG9ydGFsIiwiYWx0IjoiIiwiZGVzY3JpcHRpb24iOiIifQ==,eyJ1cmwiOiJodHRwczpcL1wvYmxvZy5weXRoaWFuLmNvbVwvd3AtY29udGVudFwvdXBsb2Fkc1wvYWNjZXNzXzJfc2hlbGxhenVyZS5wbmciLCJ0aXRsZSI6ImFjY2Vzc18yX3NoZWxsYXp1cmUiLCJjYXB0aW9uIjoiQXp1cmUgQ2xvdWQgU2hlbGwgdmlhIHNoZWxsLmF6dXJlLmNvbSIsImFsdCI6IiIsImRlc2NyaXB0aW9uIjoiIn0=,eyJ1cmwiOiJodHRwczpcL1wvYmxvZy5weXRoaWFuLmNvbVwvd3AtY29udGVudFwvdXBsb2Fkc1wvYWNjZXNzXzNfYXp1cmVtb2JpbGVfMS5wbmciLCJ0aXRsZSI6ImFjY2Vzc18zX2F6dXJlbW9iaWxlXzEiLCJjYXB0aW9uIjoiQXp1cmUgTW9iaWxlIHNlbGVjdCBDbG91ZCBTaGVsbCIsImFsdCI6IiIsImRlc2NyaXB0aW9uIjoiIn0=,eyJ1cmwiOiJodHRwczpcL1wvYmxvZy5weXRoaWFuLmNvbVwvd3AtY29udGVudFwvdXBsb2Fkc1wvYWNjZXNzXzRfYXp1cmVtb2JpbGVfMi5wbmciLCJ0aXRsZSI6ImFjY2Vzc180X2F6dXJlbW9iaWxlXzIiLCJjYXB0aW9uIjoiQXp1cmUgQ2xvdWQgU2hlbGwgbG9hZGVkIHZpYSBBenVyZSBNb2JpbGUgQXBwIiwiYWx0IjoiIiwiZGVzY3JpcHRpb24iOiIifQ==,eyJ1cmwiOiJodHRwczpcL1wvYmxvZy5weXRoaWFuLmNvbVwvd3AtY29udGVudFwvdXBsb2Fkc1wvYWNjZXNzXzVfdnNjb2RlX2F6dXJlc2hlbGwucG5nIiwidGl0bGUiOiJhY2Nlc3NfNV92c2NvZGVfYXp1cmVzaGVsbCIsImNhcHRpb24iOiJBenVyZSBDbG91ZCBTaGVsbCB2aWEgVlMgQ29kZSIsImFsdCI6IiIsImRlc2NyaXB0aW9uIjoiIn0="] An unofficial method is also available via an open source app that Tyler Leonhardt ( @TylerLeonhardt) published. He also happens to be the maintainer for the PowerShell Extension in VS Code. You can download the app from his GitHub repository here. [gallery type="m" size="small" link="file" ids="eyJ1cmwiOiJodHRwczpcL1wvYmxvZy5weXRoaWFuLmNvbVwvd3AtY29udGVudFwvdXBsb2Fkc1wvYWNjZXNzXzZfY2xvdWRzaGVsbGFwcF8xLnBuZyIsInRpdGxlIjoiYWNjZXNzXzZfY2xvdWRzaGVsbGFwcF8xIiwiY2FwdGlvbiI6IkF6dXJlIENsb3VkIFNoZWxsIGxvZ2luIHByb21wdCB2aWEgQXp1cmUgQ2xvdWQgU2hlbGwgZGVza3RvcCBhcHAiLCJhbHQiOiIiLCJkZXNjcmlwdGlvbiI6IiJ9,eyJ1cmwiOiJodHRwczpcL1wvYmxvZy5weXRoaWFuLmNvbVwvd3AtY29udGVudFwvdXBsb2Fkc1wvYWNjZXNzXzdfY2xvdWRzaGVsbGFwcF8yLnBuZyIsInRpdGxlIjoiYWNjZXNzXzdfY2xvdWRzaGVsbGFwcF8yIiwiY2FwdGlvbiI6IkF6dXJlIENsb3VkIFNoZWxsIHZpYSBBenVyZSBDbG91ZCBTaGVsbCBkZXNrdG9wIGFwcCIsImFsdCI6IiIsImRlc2NyaXB0aW9uIjoiIn0="]
The Cloud Shell is run within a container via the Azure Container Service at no charge to you or your subscription for the container itself. The only cost for Cloud Shell is the storage account that is created and associated to it. The first time you open Cloud Shell from the Azure Portal you will need to select whether you want Bash or PowerShell, I chose PowerShell. After that you can select your subscription and Azure will automatically create a storage account and resource group. If you go through the advanced options it provides you with the ability to use a preexisting storage account. Using the option to just let Azure create the resources, after you click on "Create Storage" you will see output around the storage creation, and then when the prompt is returned it will have your location set to the Azure Drive ( Azure:\, more on this in a bit). [gallery type="slideshow" link="file" ids="eyJ1cmwiOiJodHRwczpcL1wvYmxvZy5weXRoaWFuLmNvbVwvd3AtY29udGVudFwvdXBsb2Fkc1wvZ2V0c3RhcnRlZF8xLnBuZyIsInRpdGxlIjoiZ2V0c3RhcnRlZF8xIiwiY2FwdGlvbiI6IkF6dXJlIENsb3VkIFNoZWxsIHZpYSBBenVyZSBQb3J0YWwgLSBTZWxlY3QgQmFzaCBvciBQb3dlclNoZWxsIiwiYWx0IjoiIiwiZGVzY3JpcHRpb24iOiIifQ==,eyJ1cmwiOiJodHRwczpcL1wvYmxvZy5weXRoaWFuLmNvbVwvd3AtY29udGVudFwvdXBsb2Fkc1wvZ2V0c3RhcnRlZF8yLnBuZyIsInRpdGxlIjoiZ2V0c3RhcnRlZF8yIiwiY2FwdGlvbiI6IkF6dXJlIENsb3VkIFNoZWxsIHZpYSBBenVyZSBQb3J0YWwgLSBTZWxlY3Qgc3Vic2NyaXB0aW9uIGFuZCBjcmVhdGUgc3RvcmFnZSIsImFsdCI6IiIsImRlc2NyaXB0aW9uIjoiIn0=,eyJ1cmwiOiJodHRwczpcL1wvYmxvZy5weXRoaWFuLmNvbVwvd3AtY29udGVudFwvdXBsb2Fkc1wvZ2V0c3RhcnRlZF8zLnBuZyIsInRpdGxlIjoiZ2V0c3RhcnRlZF8zIiwiY2FwdGlvbiI6IkF6dXJlIENsb3VkIFNoZWxsIHZpYSBBenVyZSBQb3J0YWwgLSBzaG93aW5nIHN0b3JhZ2UgYWNjb3VudCBpbmZvcm1hdGlvbiIsImFsdCI6IiIsImRlc2NyaXB0aW9uIjoiIn0=,eyJ1cmwiOiJodHRwczpcL1wvYmxvZy5weXRoaWFuLmNvbVwvd3AtY29udGVudFwvdXBsb2Fkc1wvZ2V0c3RhcnRlZF80LnBuZyIsInRpdGxlIjoiZ2V0c3RhcnRlZF80IiwiY2FwdGlvbiI6IkF6dXJlIENsb3VkIFNoZWxsIHZpYSBBenVyZSBQb3J0YWwgLSBTaG93aW5nIHRpcCBvZiB0aGUgZGF5IiwiYWx0IjoiIiwiZGVzY3JpcHRpb24iOiIifQ==,eyJ1cmwiOiJodHRwczpcL1wvYmxvZy5weXRoaWFuLmNvbVwvd3AtY29udGVudFwvdXBsb2Fkc1wvZ2V0c3RhcnRlZF81LnBuZyIsInRpdGxlIjoiZ2V0c3RhcnRlZF81IiwiY2FwdGlvbiI6IkF6dXJlIENsb3VkIFNoZWxsIHZpYSBBenVyZSBQb3J0YWwgLSBUaW1lb3V0IG9mIDIwIG1pbnV0ZXMiLCJhbHQiOiIiLCJkZXNjcmlwdGlvbiI6IiJ9"]
The storage account that is tied to Cloud Shell will get mounted to the container on start up for you. This is mounted under the user profile for PowerShell. You can find this under $home\CloudDrive, or the full path would be C:\Users\ContainerAdministrator\CloudDrive. [caption id="attachment_103869" align="aligncenter" width="712"]
Azure Cloud Shell - "Cloud Drive"[/caption]
The beauty of having this storage is it allows you to persist files between sessions. When you start and exit (or your session times out) for the Cloud Shell, that container that was spun up is removed. So any files or items you install outside of your CloudDrive will be lost, you should consider it as ephemeral storage. Since the storage account is Azure Storage you can upload and retrieve files via the normal methods (e.g. via Azure Storage Explorer or via Azure Portal). There are three methods now that allow you to upload files directly: 1. shell.azure.com 2. Accessing via Azure Portal 3. VS Code's Azure Account extension [caption id="attachment_103870" align="aligncenter" width="998"]
Azure Storage Explorer - Showing Fileshare[/caption] [caption id="attachment_103872" align="aligncenter" width="480"]
Azure Cloud Shell - Uploading file[/caption] VS Code has a monthly cadence now so extensions are being updated from Microsoft just as frequently. While preparing this post the extension that provides access to the Azure Cloud Shell was updated to include support for uploading a file. The only thing specific to this method is that in the Shell you have to ensure you current location is set to the $home\CloudDrive directory, otherwise from what I could figure out it goes into an area that only Neo could access.
Dismount-CloudDrive within a Cloud Shell session and once it has completed the session closed. The next time I accessed it, I had to go through the setup wizard again. This time though I went through the advanced option and selected my current storage account and file share. So far I have not experienced any more errors on startup.
It would be pretty boring if all this was just an empty container and a mounted file share, right? Well, Microsoft has not left us high and dry. One of the default modules that is pre-loaded for you is the Simple Hierarchy in PowerShell (SHiPS). This is a provider that allows you to build out a directory tree structure and lets you traverse those objects like you would the system volume of a Windows Server. In this case it is your Azure subscriptions. [caption id="attachment_103873" align="aligncenter" width="1143"]
Azure Cloud Shell - SHiPS provider[/caption] [caption id="attachment_103874" align="aligncenter" width="693"]
Azure Cloud Shell - SHiPS provider subscription folder[/caption]
Outside of just PowerShell and PowerShell modules Microsoft has provided other tools that can be used for automation or simple convenience. You can see from the screenshot below the container has Python and Git. One thing that threw me a bit was when I saw Vim is available...Who does not love Vim? [caption id="attachment_103875" align="aligncenter" width="811"]
Azure Cloud Shell - Installed programs[/caption] I opened up Vim to play around and found Microsoft has integrated the PowerShell Editor Service. This allows you to have full intellisense for PowerShell built-in commands, and installed modules you may be using. This also (apparently) comes with PSScriptAnalzyer support as well. [caption id="attachment_103876" align="aligncenter" width="1632"]
Azure Cloud Shell -Vim[/caption] For those not comfortable with Vim you also have Nano that can be used for editing files, it just does not include the Editor Services so no intellisense is available.
CurrentUser. This will ensure it persist from session to session. Now you may be asking: if only things inside of the $home\CloudDrive directory are persisted, how do modules you install stay around? It is by Symbolic links. You may already know but you can ensure modules are installed under your user profile by running the command with the scope set to CurrentUser.
Install-Module MyModule -Scope CurrentUserThis will ensure it will always be installed within the profile of the given user; more specifically for Cloud Shell in the full path
C:\Users\ContainerAdministrator\Documents\WindowsPowerShell\Modules. Microsoft auto configures a symbolic link for you where the modules will be installed under $home\CloudDrive\.pscloudshell\WindowsPowerShell\modules, or $home\CloudDrive\.pscloudshell\PowerShell\modules\ if you fancy using PowerShell Core. You can see the symbolic link that is created by checking the file object of the profile path. You can simply run:
Get-Item C:\Users\ContainerAdministrator\Documents\WindowsPowerShell\ | Format-List
Take note of the two properties LinkType and Target: [caption id="attachment_103885" align="alignleft" width="748"]
Azure Cloud Shell - symbolic link to pscloudshell under the CloudDrive directory[/caption]
Azure Cloud Shell while still in preview, is a big step forward in interactively managing your Azure resources (or just needing a PowerShell environment to work from) more easily. You can find more information around Cloud Shell by checking the documentation. As well, as you are using it, if you see features missing or not working as you expect, Microsoft would love the feedback. You can find the feedback site for this product here.
Ready to optimize your use of Microsoft Azure Cloud's tools?