TIP
💡 Learn more : Overview of Azure Cloud Shell (opens new window).
# Mount a drive and upload files to Cloud Shell
# Overview
When working with Azure Cloud Shell (opens new window), you sometimes need the ability to upload files to work with later. I'm going to call out the two methods that I use to accomplish this task all the time.
# Mount a drive and upload via the Azure Portal
In method one, we'll update the file share that's associated with Cloud Shell by using the clouddrive mount
command. Note: that you may already have a cloud drive that is created upon initial start of cloud shell. Go ahead and spin up Azure Cloud Shell and type clouddrive -h
to see the commands to mount and unmount a drive.
michael@Azure:~$ clouddrive -h
Group
clouddrive :Manage storage settings for Azure Cloud Shell.
Commands
mount :Mount a file share to Cloud Shell.
unmount :Unmount a file share from Cloud Shell.
2
3
4
5
6
7
8
To mount a drive, we'll type clouddrive mount -h
to see a help screen that is looking for the following parameters:
Arguments
-s | --subscription id [Required]:Subscription ID or name.
-g | --resource-group group [Required]:Resource group name.
-n | --storage-account name [Required]:Storage account name.
-f | --file-share name [Required]:File share name.
-d | --disk-size size :Disk size in GB. (default 5)
-F | --force :Skip warning prompts.
-? | -h | --help :Shows this usage text.
2
3
4
5
6
7
8
We'll now simply call clouddrive mount -s subscription-id -g your-resource-group-name -n storage-account -f storage-file-name
to create our drive. Once it has completed, we'll navigate to the resource and hit the Upload button and upload a file. Again, you could have navigated to your existing resource group instead of creating a new one - but I want you to learn how to do this manually.
Now type cd clouddrive
and ls -l
and you should see the file you just uploaded:
michael@Azure:~/clouddrive$ ls -l
total 53
-rwxrwxrwx 1 root root 53385 May 29 23:55 cloudshellnew1.png
michael@Azure:~/clouddrive$
2
3
4
# Upload via Cloud Shell button
The second method involves pressing the Upload button built right into Azure Cloud Shell.
After you press this button and provide the file, you'll see that it is uploading it into your /HOME/username
folder
Now you can simply type cp filename cloudrive
to copy the file and have access to the file via cloud drive.