This post has been republished via RSS; it originally appeared at: ITOps Talk Blog articles.
In my last post I discussed how you can run the managed image that the Azure Cloud Shell is based on locally. It allows you to leverage the Azure Shell managed environment without being subject to the limitations of the real Azure Cloud Shell.
Following that post, someone said to me, “You forgot that online you can use code (Cloud Shell editor)”.
Well. Yes and no…
Let me elaborate… No, you cannot use the same Code version in the shell.
However, there is a great way to use the container version WITH the full Visual Studio Code. I must admit that I MUCH prefer it this way. Mostly because I can use all the extensions in VS Code that make my life easier. Extensions like:
- Azure Resource Manager (ARM) Tools
- Azure CLI Tools
- Azure Terraform
- Azure Virtual Machines
- Azure Account
To name a few.
Here’s how I set that up, so I get the best of both worlds. A managed Cloud Shell environment and a local powerful code editor.
Connecting to VS Code to the Running container
So, we already covered how we setup and start the container in the last post. Now to connect VS Code to the container we need to get one more extension. The Remote - Containers extension lets you use a Docker container as a full-featured environment. To quickly swap between different, isolated development environments and safely make updates without worrying about impacting your local machine.
Once it’s installed, I press F1 to bring up the Command Palette and type in Remote-Containers for a full list of commands.
You can also click on the Remote "Quick Access" status bar item to get a list of the most common commands.
From the Command Palette select “Remote-Containers: Attach to Running Container…”
A list of running containers will be presented and I select the one that’s running my “Local Cloud Shell”.
It will ten connect to the container environment.
Connecting to the mapped folder inside the container
Connecting to the mapped folder is as easy as opening a folder and navigating to the folder in the container mapped to the local location.
The last piece of this puzzle is the terminal. Because I’m connected to the container, I have access to all the environments that are setup in there. By selecting ‘Terminal’ from the ‘view’ menu I can open the default environment which is a bash shell.
But I can easily open a PowerShell terminal by selecting “Select Default Shell” in the terminal shell selection drop down.
And selecting the PowerShell Core environment setup in the image of the cloud shell.
And finally, starting a new terminal either by selecting ‘New Terminal” in the Terminal menu, or clicking the ‘+” in the terminal view.
From there you are using the Cloud Shell Image and all the tools that are configured in it, it’s always up to date and you get access to the full power of VS Code instead of the Code “light” editor available in the Online Azure Cloud Shell.
So, to address the comment, “You forgot that online you can use code (Cloud Shell editor)”. I say. You’re right, but I got something better!
I hope this helps!