Using Azure Files with a Linux VM

30 minutes
  • 2 Learning Objectives

About this Hands-on Lab

Azure File Shares provide a simple and reliable way to store data in a typical directory hierarchy. Moreover, File Share data can be accessed using the widely supported Samba protocol. This enables you to mount Azure File Shares to a virtual machine and easily interact with the files from your VM. In this lab, you will have the opportunity to mount an Azure File Share to a Linux VM. By the time you have completed the lab, you will be able to read and write to an Azure File Share from your Linux VM.

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Create a secure credentials file to store credentials for the Samba share.
  1. Create a file that will contain the samba credentials for the storage account. Note that for the file name, you should enter your unique service account name.
    sudo mkdir -p /etc/smbcredentials
    sudo vi /etc/smbcredentials/<storage account name>.cred
  2. Store the samba user (storage account name) and password (storage account key) in the file. Input your unique storage account name and key, which you can find via Azure portal.
  3. The file should look like this:
    username=<storage account name>
    password=<storage account key>
  4. Set permissions on the credential file so that only root can read it.
    sudo chmod 600 /etc/smbcredentials/<storage account name>.cred
Mount the File Share to the Linux VM.
  1. Create a directory for the mount.
    sudo mkdir -p /mnt/sattrecords
  2. Edit the fstab file.
    sudo vi /etc/fstab
  3. At the end of the file, add a line to automatically mount the Azure File Share whenever the server starts up.
    //<storage account name>.file.core.windows.net/records /mnt/sattrecords cifs nofail,vers=3.0,credentials=/etc/smbcredentials/<storage account name>.cred,serverino
  4. Mount the File Share by mounting all filesystems in fstab.
    mount -a
  5. Browse the mounted directory. You should see files there that are stored in the Azure File Share.
    cd /mnt/sattrecords
    ls -la
  6. Test your ability to write to the Azure File Share by creating a test file.
    vi test_file.txt
  7. Write some text to your test file and save it. If you wish, you can navigate to the file share in the Azure portal and view your new file there.

Additional Resources

Your company, Store All The Things!, offers customers the ability to store any object. The company has some record data stored in an Azure File Share.

An automation engineer at your company would like to build some automation scripts that work with this record data. However, they need you to make this data available in a Linux virtual machine that will be used to run these scripts. You can do this by mounting the Azure File Share on the virtual machine.

You will need the following information to complete this task:

  • The storage account containing the File Share begins with the text sattrecords.
  • The File Share is called records.
  • Mount the File Share to the location /mnt/sattrecords on the VM.
  • Any user on the VM should be able to read from the share, but only root needs to be able to write to it.
  • The File Share should be automatically mounted if the VM restarts.
  • Be sure to store any sensitive credentials on the VM so that they cannot be read by non-root users.

If you get stuck, feel free to check out the solution video, or the detailed instructions under each objective. Good luck!

What are Hands-on Labs

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.

Get Started
Who’s going to be learning?

How many seats do you need?

  • $499 USD per seat per year
  • Billed Annually
  • Renews in 12 months

Ready to accelerate learning?

For over 25 licenses, a member of our sales team will walk you through a custom tailored solution for your business.


$2,495.00

Checkout
Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!