Cloud Shell Key Concepts
Cloud Shell Key Concepts

This course defines the key concepts of  Azure Cloud Shell and illustrates the basic syntax of PowerShell and Bash.


- [Narrator] Hello and welcome to lesson one, key concepts. Azure Cloud Shell is an interactive, authenticated browser accessible command line Shell that can be used for managing Azure resources. It provides the flexibility of choosing the Shell experience that best suits the way you work, either with the Azure command line interface, commonly referred to a CLI or the PowerShell interface. It also has an inbuilt editor where you can create or run scripts or templates or even create and test web applications prior to deployment. Let's look at the key features of the Cloud Shell console. Azure Cloud Shell is a fully managed browser-based Shell experience to manage and develop Azure resources. It runs on Ubuntu 1604 LTS, which has provisioned from a temporary pre-defined container instance or host. Cloud Shell provisions machines on a per user request basis and as a result, machine state will not persist across sessions. Since Cloud Shell is built for interactive sessions, Shell's automatically terminate after 20 minutes of Shelling activity. This host machine is attached to your Cloud Shell session automatically when you open a new Shell session and is disconnected when you close the Shell session. There's no cost for running of this host system but because of it's interactive nature, you cannot store any persistent data like files or scripts in it. To get around this problem, Cloud Shell requires an Azure file share to be mounted to provide persistent storage. Within the file share a persistent image called Cloud Drive is created, this image is connected to the host as a persistent drive, whenever a Cloud Shell session is started. The same cloud drive image is used for storing files for both of the command line tools. The Cloud Shell environment gives you immediate visibility to access the two main command line tools, CLI and PowerShell. Cloud Shell also includes pre-configured open source tools such as Terraform, Ansible and Chef but there are many other tools that come prebuilt into the Cloud Shell environment that are too numerous to mention here. I recommend that you consult the documentation within the Cloud Shell for more information. There are three main ways to interact with Cloud Shell. One, from the Azure portal via the Cloud Shell icon. You can open a browser to and from the website or the Microsoft Learn websites, via the try it button that appears with Bash and PowerShell code snippets. Whichever way you choose to interact with Cloud Shell, if it's the first time you've used it as part of the container provision in process, you'll be prompted to create a storage account within your Azure subscription. And by default, as you will create the storage account and provision the container instance in a primary location, closest to your location. Now there are primary and secondary locations available. The storage account can exist in a primary or secondary location, but the container instances can only reside in one of, at present, seven primary locations. Now if it's not possible to have the storage account in one of the primary locations, but for example, GDPR restrictions or company restrictions, then the storage account can reside in the different secondary location from the Cloud Shell container instance. Now this means that the storage account could, for example, be in the UK, and the container instance, running the Cloud Shell environment, could potentially be in Europe. This can possibly slow down connection and data transfer speeds, having the two objects in different locations. But to achieve this kind of arrangement, you would have to configure advanced settings. Let's look at the Azure portal environment first to get an overview and feel of the different tools and settings available in Cloud Shell. Now you can see I'm in the portal, now from the portal, I click on the Cloud Shell icon, that then opens up the Cloud Shell space. Now because it's the first time in this particular subscription that this has been used, you can see it's prompting me to select either the Bash or PowerShell command line language. It doesn't matter which one I select, I'm just gonna for example select the Bash icon here, and because I don't have any storage mounted, it's now prompting me to create storage. Now the default would be to just click the create storage button, but if we're in a situation where as I explained earlier on, for example, I don't know, maybe GDPR, you wouldn't be able to potentially have your storage account in the same location as the image that's gonna be created, that's gonna provide us with the Ubuntu container, then we would have to go to the show advanced settings. Now if I click on show advanced settings, that then opens up a menu system and you can see for example up here, where it says, West Europe, at the moment, I'm recording this session in the UK, there are no primary locations in the UK, if I click on the link, you'll see that we have our primary regions at the top, so there are what's currently available, the seven primary regions, and then we have all the secondary regions available here. So the images can only exist in primary regions. So although I'm in the UK, the closest locations to the UK to be able to provide an Ubuntu image is actually either West Europe or North Europe. Now I could select those individually if I wish, or if I just let it set it up automatically, it will select one of those locations. If I was over in America, it will then select one of the America regions. But if I was in a situation where my storage account is not allowed to reside outside of the UK, I could then choose a secondary region, for example UK South or UK West and the storage account would be created there, but the Ubuntu container instance would still be located in one of the primary regions. So I'm just gonna close out of that and I'm gonna click on the icon again to get back into the Cloud Shell experience. I'm just gonna have to select Bash and I'm gonna leave it with it's default to create storage. Now that provisionally can take a few minutes to kick into life, so we'll just fast forward to when we get to the cursor. So here we are, the set up has been completed and I now have a cursor on the command line. And just to show you that that was a first time set up, if I close the Cloud Shell down and then go and click back on the Cloud Shell icon, it will open that new session back up again and because the storage has already been provisioned, it will automatically then come back into the last command line that I chose. And if I go and click on the Cloud Shell icon again, it will open up a new session and you'll see that I don't get prompted to create storage now, that one time has already been completed. But it will open me up on the last command line console that I had open. Now on the left hand side, you'll see in the drop down list, I can select either Bash or PowerShell. So these are the two main command line languages we have. What I'm gonna do is just go through a quick overview of the icons on the top menu bar and I'll cover these in a little bit more detail as we go through the following lessons. So I have the option of selecting either Bash or PowerShell, so if I, for example, select PowerShell and it says, do you wanna switch? I will confirm the switch, it will then switch me into the PowerShell environment and we'll get the usual blue PowerShell background. Now because the storage account that was created, created the file share, in that file share, we have the Cloud drive and you'll see here it says, building your Azure drive, the Cloud drive that was provisioned for Bash is the same Cloud drive that will be provisioned for PowerShell, we use the one file share. You can see now I've got the flashing cursor and we're ready to go with PowerShell, for example. Now up on the top bar, as we go through the icons, the Power icon, if I click on it, it'll say, do you wanna restart Cloud Shell? Now if I was to restart, it will kill any running processes that were running in this particular session. I'm just gonna cancel outta that 'cause we have nothing running at the moment. On the second icon, the question mark, this is the help button basically and if I go and click on that, you'll see that we have a link to the Cloud Shell overview. Now if I go and click on that link, it'll just take me out to the documents page, which gives me an overview of the Azure Cloud Shell. I'm gonna close that, I'll come back to those in a minute. I also have then the Azure PowerShell reference. Now that's purely because I'm in the PowerShell session at the moment. If I switch back to Bash, that'll go to the Bash reference. You'll see that I've got instructions here how to copy and paste. Now I'm running on a Microsoft Windows machine at the moment, but we could use Cloud Shell from a Linux machine, we could be using it from macOS. So how to copy, paste, that will literally give me instructions on the different systems like for Windows controls for you to copy. On a macoS, it will be Command C to copy and so on and so forth. On the settings cog, we can then change things like the text size. We can go from small, medium and large. So if I wish to change the text size, I can do so. Or I'll just put it back down to it's medium size. And I can also change the font settings. So I can either go Monospace or Courier New. The next icon is the upload and download button. Now I can upload files directly into the file share that's attached, or I can download from the file share to my local machine. The next icon on the tool bar is the open new session icon. Now this will lead us to the second way that we can interact with Cloud Shell. At the moment, we're in a Cloud Shell session within the portal experience, but by clicking on the open new session, it will open a new tab and take us to the experience. Now it's the same experience, it's just in full screen. And we get access then to the set of icons again, and you can see on the top right hand side, if I want to I can then sign out or sign in to a different subscription or a different directory. Now I could have done that directly from opening the brand new tab, and at that point going to And at that point, it'll either take me to my pre-existing one, because I've already authenticated, or it would prompt me to sign in. The third way that we can interact with the Shell is through the documentation side of things. If I just go back to the question mark for a second and click on the Azure PowerShell reference link, that'll take me out to the PowerShell documentation site. You'll see here that I've got a link for sample scripts for virtual machines and if I click on it, it takes me to this page, which is a Quickstart for creating a virtual machine in PowerShell. Now if I scroll down a little bit, you'll see that we've got some coding here and the third way of interacting with the Shell environment is from this try it button. So I can click on a try it button and what that will do is then open up the Shell experience directly in this browser page and I can then sign in. Now because I've already authenticated in this tab on the left hand side, it should automatically authenticate me in my subscription and you can see it's now opening up a Cloud Shell experience. So I potentially could go into here and then copy the code and then literally right click and paste it in. So I don't have to type the commands in, I can do a copy paste, copy paste. That's a great way of interacting with the Cloud Shell experience, if you just wanna follow some of the exercises that are in the documentation site. So I'm just gonna close that tab up and come back into the portal experience. So that sort of covers the three different ways that we can do it directly from the portal, in a new browser tab to or clicking on a new Shell session, which will open up a new tab, or doing it from the documentation side of things. The next icon in the two curly brackets, basically takes us to the editor experience. So this is the Monaco editor that's built in. Now there are other editors that are built in, you've got Nano, you've got vim, for example, but this is the one that's actually just built in to the portal experience itself. We're gonna cover that in another lesson, so I'm gonna close the editor. And the last icon that we have in here is the web preview icon. Now if I click on that and hit the configure button, effectively what I can do is if I have an application that I want to run and test, a web app for example, I can then run that from within the Cloud Shell experience and then set it up so I can view it directly, without having to publish it. I'll do a demo of that when we look at the editor lesson. Then obviously on the right hand side, we have the close button, we have the minimize and maximize buttons. If you minimize or maximize, maximize will just give us a full screen experience. Clicking on the X will just close down the Cloud Shell experience, disconnecting the Cloud drive and also disconnecting the Ubuntu machine that was providing that experience in the first place. Okay, that concludes the small demonstration of just creating the Cloud Shell environment for the first time and also going through the icons. So as a quick recap, Cloud Shell is an on demand environment that's fully managed by Microsoft. It runs on a temporary host with one machine assigned per user and it uses a persistent home drive, which effectively uses a five gigabyte image held in a file share. Now while I'm here, on the left hand side, I'm quickly gonna go down and find storage accounts and you'll see that in the storage accounts, there's a storage account that's been created and it's called Cloud Shell storage and it's located in West Europe. So, I'm the UK at the current time of recording this, but I can't have the storage account in the UK, it has to be, in this case it's in West Europe 'cause that's where the Ubuntu machine was provisioned. If I wanted the storage account in the UK, I would have to have done the advanced settings to separate those out, and if I go into the storage account, you'll see in the overview page here that we have a link to file shares. So you can see on the file share, if I click on the file share, there is a Cloud console directory, and inside that directory, we then have the Cloud Shell image, or the Cloud Drive image that becomes the home drive that is then attached to your virtual machine when you open a Cloud Shell session. So this becomes the persistent storage. Okay, so that concludes lesson one. I look forward to seeing you in lesson two, learning the basic Bash sintacts for Azure Cloud.

About the Author
Learning Paths

A world-leading tech and digital skills organization, we help many of the world’s leading companies to build their tech and digital capabilities via our range of world-class training courses, reskilling bootcamps, work-based learning programs, and apprenticeships. We also create bespoke solutions, blending elements to meet specific client needs.