Shared Application Configuration with Azure Files

30 minutes
  • 3 Learning Objectives

About this Hands-on Lab

Azure File Shares are a powerful tool for managing data in the cloud. The data stores that uses File Shares can take many forms, and it can even include configuration data.

One way to use Azure Files shares is to store shared configuration files in them so that the shared configuration files can be accessed across multiple servers.

In this lab, we will explore Azure File shares. We will configure an Nginx web server on two machines using a shared configuration file stored in an Azure File share. This will provide you with some hands-on experience with what it might look like to manage shared configuration using Azure File shares.

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Create a file share to store the shared configuration file.
  1. Log in to the Azure portal.
  2. Locate the storage account. The name of the storage account should begin with webconfig.
  3. Click on the storage account, then select File Shares and click + File Share to create a new file share.
  4. Set the name of the new file share to config and click Create.
Mount the File share to both web servers.
  1. On both servers, edit the fstab file using sudo vi /etc/fstab.
  2. Add a new entry at the end of the file on each server. Replace the <storage account name> in the Samba address with your real storage account name, which you can find in Azure portal. With it, enter the following:
    //<storage account name>.file.core.windows.net/config /etc/nginx/sites-enabled cifs nofail,vers=3.0,credentials=/etc/smbcredentials/webconfig.cred,serverino
  3. On both servers, finish mounting the File Share by mounting all filesystems in fstab using sudo mount -a.
Create the shared configuration file within the file share.
  1. On one of the two servers, edit the config file using sudo vi /etc/nginx/sites-enabled/default.
  2. Add the contents of the configuration file:

    server {
    listen 80 default_server;
    listen [::]:80 default_server;
    
    root /www/satt;
    
    index index.html index.htm index.nginx-debian.html;
    
    server_name _;
    
    location / {
    try_files $uri $uri/ =404;
    }
    }
  3. On both servers, reload the Nginx configuration using sudo nginx -s reload.

You should be able to view the website by accessing either server’s public IP address in a browser. You can also verify this when logged in to one of the servers with the curl localhost command.

Additional Resources

Your company, Store All The Things!, offers customers the ability to store any object. They are in the process of rolling out a new, multi-server infrastructure for their website. This website uses Nginx as its web server with a custom configuration file. This file is intended to be the same on all servers, and maintaining the configuration manually across multiple servers may be difficult and error-prone.

Luckily, you can use an Azure File share to keep the configuration in a central location (Azure). By mounting the file share to all of the web servers, you can ensure that any changes to this shared configuration can be easily rolled out to all servers. Create a file share to store the configuration file, mount it to both web servers (your two Lab VMs), and add the shared configuration file to the mounted share. After completing these tasks, you should be able to view the static website on both servers.

You will need the following information to complete this task:

  • The storage account containing the File Share begins with the text webconfig.
  • The File Share called config mounted at /etc/nginx/sites-enabled on both servers.
  • The Samba credentials file that exists on both servers at /etc/smbcredentials/webconfig.cred.
  • The configuration file called default.
  • The contents of the configuration file, which are:

    server {
       listen 80 default_server;
       listen [::]:80 default_server;
    
       root /www/satt;
    
       index index.html index.htm index.nginx-debian.html;
    
       server_name _;
    
       location / {
           try_files $uri $uri/ =404;
       }
    }

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!
Thanks for reaching out!

You’ll hear from us shortly. In the meantime, why not check out what our customers have to say about ACG?