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.
- Log in to the Azure portal.
- Locate the storage account. The name of the storage account should begin with
webconfig
. - Click on the storage account, then select File Shares and click + File Share to create a new file share.
- Set the name of the new file share to
config
and click Create.
- Mount the File share to both web servers.
- On both servers, edit the
fstab
file usingsudo vi /etc/fstab
. - 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
- On both servers, finish mounting the File Share by mounting all filesystems in fstab using
sudo mount -a
.
- On both servers, edit the
- Create the shared configuration file within the file share.
- On one of the two servers, edit the config file using
sudo vi /etc/nginx/sites-enabled/default
. 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; } }
- 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.- On one of the two servers, edit the config file using