Skip to content

Instantly share code, notes, and snippets.

@savishy
Last active January 22, 2024 07:31
Show Gist options
  • Save savishy/05eebae905023468afa7760fb4ea5378 to your computer and use it in GitHub Desktop.
Save savishy/05eebae905023468afa7760fb4ea5378 to your computer and use it in GitHub Desktop.
Azure things.

Mounting Azure Cloud Drive on Linux machines

This is especially useful if you want to develop locally and run it from Cloud Shell.

References

  1. this
  2. Mounting CIFS drives as a specific user and group

The Goal

  1. Azure Cloud Drive containing your files
  2. Mounted on a Linux Azure VM
  3. Development from your Local Windows VM

Steps

  1. Create Azure Cloud Storage
  2. Mount it on Windows. (This process is easy)
  3. Mount it on Linux using above reference.

Mounting Process on Linux

  1. Install cifs-utils.
  2. Create local mount directory eg. ~/clouddrive.
  3. Copy the mount string from Azure File Share. Example
sudo mount -t cifs //XYZ.file.core.windows.net/FILE-SHARE \
[mount point] -o vers=3.0,username=XYZUSERNAME,password=BASE64ENCODED==, \
dir_mode=0777,file_mode=0777,sec=ntlmssp

Now modify the string as appropriate.

  • Replace mount point with the mount directory on Linux. E.g. ~/clouddrive
  • Change the file mode as desired. 0777 is the default file mode with which files and directories are mounted. But for work with SSH keys etc, this might create an issue.
  • The default mount is with user root and group root. This creates trouble with Git checkouts. So add additional parameters uid=[USER] and gid=[GROUP] for the user and group on your Linux machine.

Final Modified Connect String

sudo mount -t cifs //XYZ.file.core.windows.net/FILE-SHARE \
~/clouddrive -o vers=3.0,username=XYZUSERNAME,password=BASE64ENCODED==, \
dir_mode=0777,file_mode=0777,uid=vish,gid=vish,sec=ntlmssp

Now run this string on your Linux machine. This should succeed if your options are correct.

Note: you can do a permanent mount by storing it in /etc/fstab.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment