Skip to main content

WSL + Interop + Azure: $HOME is everywhere

Introduction

Microsoft //BUILD is just 3 days away and while I'm just (super) sad that I will not attend, I wanted to bring a "special" gift.
After some discussion on Twitter with @Tara_msft, she asked me if I tried Azure Cloud Shell.
She past a link to the (incredibly) excellent @docmsft site. And the Pandora box was definitively open...

The crazy idea

after looking at the Cloud Shell, and reading about Spot Instant Cloud, this (crazy) idea came to life:
What if, I could tweak the "$HOME" hack and make it available "everywhere"! 
Or, due to the limitation of the Azure free account (in terms of storage capacity) and the "Network drives" permissions/behavior, at least I could put the important dot files in the Cloud Drive while keeping the development files on the "Interop zone" (read: /mnt/c/...) as described in Brian's blog post.

To be prepared, you must

Before we can apply what follows, some preparation is needed.
The major one being: you must have an Azure account. Gladly, Microsoft offers a free account!

Once you completed the creation of your new account, you can login to https://shell.azure.com/ if you want a full page console, or login to https://portal.azure.com and click on the Cloud Shell icon.
The first time, it will warn you that you need to create an Azure Files Storage.
Follow this guide to get you fully started.

On your computer, you need to have WSL installed with your preferred distribution (search for Linux in Microsoft Store).

Mounting the Clouddrive: Windows side

Ok, first of all: we want to mount the Azure Shell Cloud drive in WSL, so what is this Windows side all about?
Well, it's simple, for mounting the Cloud Drive in Linux, we need Fuse and for the time being, it's still not handled in WSL.
However, we can mount Windows drives into WSL, and following the docs, we can mount (read: network drive) the Cloud Drive in Windows.

Here is a quick summary based on the docs:  

  1. Connect to https://portal.azure.com
  2. Click on "Storage Accounts" on the left menu
  3. You should see at least one line with the Cloud Shell drive
  4. Click on the name to get to the account summary page
  5. Click on "Files" to get the file share details
  6. Click on the name of the file share
  7. Click on "Connect" to see the connection helper on the right
  8. Open an Explorer window and click on "This PC"
  9. Click on "Map Network drive"
  10. Choose the drive letter and enter the network path that you see in the "net use" connection helper and click on "Connect using different credentials"
  11. Click on finish
  12. Enter the username with the "Azure" domain
  13. Enter the access key as the password
  14. Click OK to complete the mapping
You should now be able to see you drive mounted with, normally, only one directory ".cloudconsole"

Mounting the Clouddrive: WSL side

As all the heavy lifting was done on Windows side, on WSL we will simply map the drive:
  1. Launch your favorite distro (here I will use Ubuntu)
  2. Mount the drive with the letter you chose (here I will use Z:) to either the "/mnt/" path or, in my case, to a directory in my $HOME
And that's all! Here is the gif I made to share on Twitter the full setup with a small demo at the end:

Once again, I really hope someone will find this useful and do not hesitate to ping me in Twitter to share your experience or even better, a link to your own take at this "feature".

As for the WSL, Azure and Docs teams: please continue to bring such cool features, I will keep having these crazy ideas on how to connect them :)


>>> Nunix Out <<<

Comments

Popular posts from this blog

Scripting with GO: what about Windows?

!!! Warning !!!Once again, let me repeat, I'm by no means a developer nor a sysadmin (at least no more since 5 years).
This means that, while the solution below worked for me and I could reproduce it, it's not 100% safe neither!
Also, my solution still feels incomplete (read further), so if someone know the tweak to make it even more compete, please share it and reach out in Twitter, I'll be waiting.
IntroductionBy now, everyone following @jessfraz read her take about the very neat "little hack" from @cloudflareUsing Go as a scripting language in Linux

As a good WSL Corsair, I tried it and it just worked!
But then, based on my latest playground of having a seamless coding experience between WSL and Windows (thanks @bketelsen for the love and notification spam), I really thought it would be unfair to "my Windows side" to not be able enjoying the fun of GO scripting (yes, split personality is bad).

So as the good Corsair I am, it was time to see if some shinn…

WSL: One Home to host them all

IntroductionThis blog post will explain how a single home mount can be shared accross all the WSL instances. It was quite fun to find the idea and then make it happen. It will use all the tools currently available from WSL, so please don't expect a "Linux only" as Interopability will be heavily used. And before I start, here is my point of view about WSL: It's not only Linux!
It's different, just like GNU is different from Unix (yes I said it).We have finally the strength of both worlds combined. And while I do understand the "dev" aspect is meant to be reproducible in a Linux prod environment, the "ops" side is meant to take advantages of everything that can make the full environment feeling Home. Setup requirementsIn order to really enjoy this solution, I do recommend having 2 or more WSL distros installed or, if you fell like a real WSLCorsair, try @bketelsencrazy setup (I love it)!
While the distros are downloading, let's prepare the Windo…

Docker + WSL: Get 2 daemon for the price of 1

Introductionalmost two years ago, Docker announced the capability of switching between the Linux and Windows containers "mode" (far from the right click that we have today).
At that time, I wrote a blog post on how to run both daemons at the same time (http://darthnunix.blogspot.ch/2016/10/docker-for-windows-2-daemons-enter-in.html)

Fast forward to 2018, and while we were blogging on how to get the TLS connection from WSL docker client with Rory McCune (https://raesene.github.io/blog/2018/03/29/WSL-And-Docker/), another blog post, by Stefan Stranger drew my attention (read: blew my mind) as I was trying to reproduce the same: how could I "bind" the docker socket in WSL with the Docker for Windows Linux mode socket (https://blogs.technet.microsoft.com/stefan_stranger/2018/04/02/access-my-docker-for-windows-kubernetes-cluster-from-debian-wsl/)
From 1 to 2 daemon: DemonHunter mode achievedNow that we have all the required setup resources, let's bind them together. An…