Skip to content

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.
  • Labs icon Lab
  • A Cloud Guru
Azure icon
Labs

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.

Azure icon
Labs

Path Info

Level
Clock icon Beginner
Duration
Clock icon 45m
Published
Clock icon Nov 06, 2020

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.

Table of Contents

  1. Challenge

    Create the File Share

    1. Log in to the Portal and go to Storage accounts in the portal menu.

    2. Click on the provided storage account.

    3. Click on File shares in the resource menu, in the File service section.

    4. Click + File share.

    5. In the form that arrives:

      • Enter fileshare1 in the Name field.
      • Set the Quota, to 2.
    6. Click Create.

  2. Challenge

    Mount the File Share to a Linux VM

    1. Navigate to Virtual machines in the portal menu.

    2. Click on the provided virtual machine.

    3. In the resource menu, under Support + troubleshooting, click Reset password. We will fill out the details on this page in just a moment.

    4. Click the >_ button at the top of the Azure Portal (in the global controls section) to open the Cloud Shell.

    5. Click the Bash link in the cloud shell.

    6. Click Show advanced settings.

    7. Set Cloud Shell region to the same region as the existing storage account.

    8. For Storage account, select Use existing.

    9. Under File share, select Create new and enter fileshareforcli.

    10. Click Create storage.

    11. Determine your account username:

      whoami
      
    12. Copy the user into the Username field in the Reset password window.

    13. Back in the shell, create an ssh key:

      ssh-keygen
      
    14. Press Enter to save it in the default location.

    15. Enter a passphrase of your choice.

    16. Display the ssh key:

      cat .ssh/id_rsa.pub
      
    17. Copy the displayed key into the SSH public key field in the Reset password window.

    18. Click Update. This may take a few moments to update.

    19. Find Overview and copy its Public IP address.

    20. Back in the terminal, run this:

      ssh username@public_IP
      

      Substitute the username (cloud) and the public IP.

    21. Enter yes at the prompt.

    22. Enter the passphrase you entered earlier.

    23. Install the cifs-utils:

      sudo apt install cifs-utils
      
    24. Create a directory:

      sudo mkdir /mnt/fileshare1
      
    25. Get the link for the file share:

      1. In the Azure Portal, click Storage accounts from the portal menu.

      2. Click the storage account provided as part of the lab.

      3. Click on File shares in the resource menu under File service.

      4. Click on fileshare1.

      5. Click Properties.

      6. 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).

    26. 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**.
    
    1. 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 replace STORAGE_ACCOUNT_KEY with the key1 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
      
    2. Verify that it is mounted (the name of the fileshare is listed):

      df -h
      
    3. Navigate to the mounted directory and add a file:

      cd /mnt/fileshare1
      touch file1.txt
      
    4. 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.

    5. Click fileshare1 and verify the existence of file1.txt.

The Cloud Content team comprises subject matter experts hyper focused on services offered by the leading cloud vendors (AWS, GCP, and Azure), as well as cloud-related technologies such as Linux and DevOps. The team is thrilled to share their knowledge to help you build modern tech solutions from the ground up, secure and optimize your environments, and so much more!

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.

Start learning by doing today

View Plans