- Lab
- A Cloud Guru
Creating and Mounting Azure File Shares
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.
Path Info
Table of Contents
-
Challenge
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.
-
Click Create.
-
-
Challenge
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:
whoami
-
Copy the user into the Username field in the Reset password window.
-
Back in the shell, create an ssh key:
ssh-keygen
-
Press Enter to save it in the default location.
-
Enter a passphrase of your choice.
-
Display the ssh key:
cat .ssh/id_rsa.pub
-
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:
ssh username@public_IP
Substitute the username (cloud) and the public IP.
-
Enter
yes
at the prompt. -
Enter the passphrase you entered earlier.
-
Install the
cifs-utils
: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.
-
Click Properties.
-
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:
1. In the Azure Portal, click on the **Storage Accounts** and our storage account. 2. Click on **Access keys** under **Settings** in the resource menu. 3. 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_NAME
with the name for your storage account (Ex: linuxazlabmrkxkpwyqzhmu). Also make sure to replaceSTORAGE_ACCOUNT_KEY
with thekey1
parameter 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):
df -h
-
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
file1.txt
.
-
What's a lab?
Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.
Provided environment for hands-on practice
We will provide the credentials and environment necessary for you to practice right within your browser.
Guided walkthrough
Follow along with the author’s guided walkthrough and build something new in your provided environment!
Did you know?
On average, you retain 75% more of your learning if you get time for practice.