In this hands-on lab, we are tasked with creating a file share and mounting it to a Linux VM. File shares are located within our Storage Account. File shares are fully managed file storage systems, allowing us to easily store files from our local workstation by using the mounted drive, just as you would with local storage.
Successfully complete this lab by achieving the following learning objectives:
- Create the File Share
Log in to the Portal and go to Storage accounts in the portal menu.
Click on the provided storage account.
Click on File shares in the resource menu, in the File service section.
Click + File share.
In the form that arrives:
- Enter fileshare1 in the Name field.
- Set the Quota, to 2.
- Mount the File Share to a Linux VM
Navigate to Virtual machines in the portal menu.
Click on the provided virtual machine.
In the resource menu, under Support + troubleshooting, click Reset password. We will fill out the details on this page in just a moment.
Click the >_ button at the top of the Azure Portal (in the global controls section) to open the Cloud Shell.
Click the Bash link in the cloud shell.
Click Show advanced settings.
Set Cloud Shell region to the same region as the existing storage account.
For Storage account, select Use existing.
Under File share, select Create new and enter fileshareforcli.
Click Create storage.
Determine your account username:
Copy the user into the Username field in the Reset password window.
Back in the shell, create an ssh key:
Press Enter to save it in the default location.
Enter a passphrase of your choice.
Display the ssh key:
Copy the displayed key into the SSH public key field in the Reset password window.
Click Update. This may take a few moments to update.
Find Overview and copy its Public IP address.
Back in the terminal, run this:
Substitute the username (cloud) and the public IP.
yesat the prompt.
Enter the passphrase you entered earlier.
sudo apt install cifs-utils
Create a directory:
sudo mkdir /mnt/fileshare1
Get the link for the file share:
In the Azure Portal, click Storage accounts from the portal menu.
Click the storage account provided as part of the lab.
Click on File shares in the resource menu under File service.
Click on fileshare1.
Copy the URL field that’s out in the working pane, but leave off the https: (just grab the two forward slashes and everything else to the right).
Retrieve the password for the account.
Note: this step is done later in the video, but is necessary to complete the following steps now:
In the Azure Portal, click on the Storage Accounts and our storage account.
Click on Access keys under Settings in the resource menu.
Copy the content in the Key box under key1.
Return to Cloud Shell and enter the beginning of the mount command using the copied URL. Do not include "https" in the path. Replace the
STORAGE_ACCOUNT_NAMEwith the name for your storage account (Ex: linuxazlabmrkxkpwyqzhmu). Also make sure to replace
key1parameter from the previous step. Then run the command:
sudo mount -t cifs //FILESHARE_URL_WITHOUT_HTTPS /mnt/fileshare1 -o vers=3.0,username=STORAGE_ACCOUNT_NAME,password=STORAGE_ACCOUNT_KEY,dir_mode=0777,file_mode=0777,serverino
Verify that it is mounted (the name of the fileshare is listed):
Navigate to the mounted directory and add a file:
cd /mnt/fileshare1 touch file1.txt
In the Azure Portal, get back to Storage accounts and into the one we’re working with. click File shares under the File service section of the resource menu.
Click fileshare1 and verify the existence of