Azure Storage – Azure Files
When you have a local network, you can have network storage – an SMB share on a file server, or a Network Attached Storage (NAS) box that everything on the network can access. Inside a cloud service, ironically, you don’t have that same concept of local network storage. If you have an app that works with your on-premise file server, moving it to Azure means rewriting it, or setting up a file server in the cloud. Azure Files is being built to handle the issues above.
What is Azure Files?
File storage offers shared storage for applications using the standard SMB 2.1 protocol. Microsoft Azure virtual machines and cloud services can share file data across application components via mounted shares, and on-premises applications can access file data in a share via the File storage API.
Azure Files Concept
|Storage Account||All access to Azure Storage is done through a storage account.|
|Share||A File storage share is an SMB 2.1 file share in Azure. All directories and files must be created in a parent share. An account can contain an unlimited number of shares, and a share can store an unlimited number of files, up to the capacity limits of the storage account.|
|Directory||An optional hierarchy of directories.|
|File||A file in the share. A file may be up to 1 TB in size.|
Common uses of Azure Files
|Lift and Shift||Migrating on-premises applications that rely on file shares to run on Azure virtual machines or cloud services, without expensive rewrites. To make this happen, each VM connects to the file share and then it can read and write files just like it would against an on-premise file share.|
|Share application settings||Storing shared application settings, for example in configuration files.|
|Diagnostic Share||Storing diagnostic data such as logs, metrics, and crash dumps in a shared location. Having these available through both the SMB and REST interface allows applications to build or leverage a variety of analysis tools for processing and analyzing the diagnostic data.|
|Dev/Test/Debug||Storing tools and utilities needed for developing or administering Azure virtual machines or cloud services. With Azure Files, a developer or administrator can store their favorite tools on a file share, which can be easily connected to from any virtual machine.|
Prerequisite requirements to use Azure Files service
- You need to have Azure subscription and an Azure storage account (can create it easily with Azure Portal).
- Azure File storage is currently in preview. To request access to the preview, navigate to the Microsoft Azure Preview page, and request access to Azure Files. Once your request is approved, you’ll be notified that you can access the File storage preview.
Setting up the Azure Files service
Currently, we need to use Azure PowerShell to setup new Azure Files service, start the PowerShell prompt and execute the following.
# Connect to Azure account, once authentication popup prompt
# you need to enter your credential and wait for the validation
# Create new contect with account and private key
# Access to Azure Portal to collect information of storage acount
$ctx=New-AzureStorageContext nguyensdemo <<my secrete key>>
# Create new share (in my case I create the directory
# to store my little girl's picture)
$s=New-AzureStorageShare linh3npicture -Context $ctx
# Create a directory in the test share just created
New-AzureStorageDirectory -Share $s -Path myangel
The new option will be appeared in Azure Portal.
PowerShell also helps to query, upload and remove files from Azure Files service.
# Try to upload a local file to target directory on Azure
Set-AzureStorageFileContent -Share $s -Source E:\chip.jpg -Path myangel
# Query existing files from a given path
Get-AzureStorageFile -Share $s -Path myangel
# Try to download file from Azure Files
Get-AzureStorageFileContent -Share $s -Path myangel/chip.jpg -Destination D:\chip.jpg
# Remove unwanted file from Azure Files
Remove-AzureStorageFile -Share $s -Path myangel/chip.jpg
Access to Azure Files with CloudBerry
CloudBerry Explorer now supports Azure Files, you can now easily create a new Azure File storage account, add new file shares and effectively manage your data on these file shares.
I’m using this utility to copy and manage all my little angle’s pictures.
Mount Azure Files to Windows Virtual Machines
To use the share via SMB 2.1 protocol, log into the VM that requires access to the share and execute “net use” as shown below:
# Sett the storage account credentials on the virtual machine.
# This allows Windows to automatically reconnect to the file share
# when the virtual machine reboots.
cmdkey /add:nguyensdemo.file.core.windows.net /user:nguyensdemo /pass:<<my sceret key>>
# Add network location with net use statement
net use z: \\nguyensdemo.file.core.windows.net\linh3npicture
You can mount Azure Files to all VMs and 5TB will be added as your shared storage.
Azure Files charge you $0.04 per GB with LRS option (Locally Redundant Storage) and $0.05 per GB with GRS option (Geographically Redundant Storage). And during preview, Files is priced 50% off and the RA-GRS option isn’t available.
Limitations of Azure Files service
- Azure Files is based around the use of SMB 2.1. That should work out fine for most uses, but keep in mind that there are some circumstances in which SMB 3.0 is required.
- Azure Files is not a substitute for a file server. One of the reasons for this is that Azure Files doesn’t support the use of Access Control Lists (ACLs) or Active Directory authentication.
- You can only mount a share from a Virtual Machine running in the same region as your storage account.