Getting Started with Azure Files Preview
Azure Files allows Virtual Machines (VMs) in an Azure Data Center to mount a shared file system and then these VMs will be able to access these files using standard Windows file APIs (CreateFile, ReadFile, WriteFile, etc.). Many VMs can attach to these files concurrently, allowing you to share persistent data easily between various roles and instances. In addition to accessing your files through the Windows file APIs, you can access your data using the Azure Files REST API. Below I will take you through getting started with the Azure Files Preview and then end with mounting the Azure Files Share as a drive in your Azure Virtual Machine. See Introducing Microsoft Azure File Service for a more detailed look at Azure Files.
To get started with the Azure Files Preview, you will first need to apply for the preview and have it activated on your Azure account. Start at the Azure Preview features scroll down to the Azure Files section and click the “Try it” button.
Your account will then be added to the queue to get activated with the Azure Files Preview, and while that sounds like it will take a long time, the email shows about in about 5 minutes saying Azure Files preview has been activated in your Azure account.
Once your account has been activated with the Azure Files preview, log into the Azure Management Portal and drill down into the Storage feature.
The Azure Files Preview is added on top of a storage account which means it is kind of hidden that you have the Preview activated on your account until you create a new storage account. Go ahead and create a new storage account by using the New button.
IMPORTANT: Mounting the Azure Files share as a drive in a virtual machine requires that you have the Storage Account and Virtual Machine in the same Location. For example, if you create the storage account in South Central US then the Azure Virtual Machine must also be in the South Central US location. If you want to mount the Azure Files Share in a preexisting Azure Virtual Machine, make sure the Locations match between both.
Once the new storage account is provisioned, drill down into it and then click on the Dashboard tab. Here you will see the new Azure Files Preview is activated on the storage account with an endpoint for the new Azure Files service (https://[storage_account_name].file.core.windows.net/).
Now the fun part begins where you can create shares and add directories and files to your share. The storage account that you just created contains zero or more Azure File shares. In each of those shares is where your put your directory and file hierarchy. You can read more about this from the Microsoft Azure Documentation Naming and Referencing Shares, Directories, Files, and Metadata.
First thing we’ll do is create a share and the easiest way to do that is through PowerShell and the PowerShell Cmdlets for Files which can be found from reading Introducing Microsoft Azure File Service - How do I install the PowerShell Cmdlets for Files? From this documentation FAQ, download the zip from http://go.microsoft.com/fwlink/?LinkID=398183 and then make sure to unblock the zip file before extracting. Now go ahead and extract the files, open a PowerShell console, and change to the folder containing the extracted files. If everything goes well you will end up with a directory containing the following:
And your PowerShell console opened to this directory:
Introducing Microsoft Azure File Service has detailed instructions on using the PowerShell Cmdlet for creating your share and adding directories and files. To create that first share, you will import the PowerShell module, create a new Azure Storage Context, and then create the share:
import-module .\AzureStorageFile.psd1
$ctx=New-AzureStorageContext <account name> <account key>
New-AzureStorageShare <share name> -Context $ctx
<account name> is the storage account name that you created earlier.
<account key> is from the Manage Access Keys dialog for this storage account and can be found by clicking the button when you are in the Storage Account.
Now that you have the share created, you can mount it as a drive in an Azure Virtual Machine.
IMPORTANT NOTE: You can only mount a share in a Virtual Machine from a Storage Account that is in the same Azure Location as the Virtual Machine. For instance, when creating the Storage Account if you choose South Central US then your virtual machine will also need to be in the South Central US.
To mount the share as a drive in your virtual machine, execute the following net use command:
net use z: \\<account name>.file.core.windows.net\<share name> /u:<account name> <account key>
Now you will have an X drive on your virtual machine:
And you can work with the drive just like any other directory and create files:
Wow! I have 5 TBs of free space!!!
For programmatic access and access outside of an Azure Virtual Machine you can use Windows Azure Storage Client Library to create and edit shares, directories, files, and metadata which is then all visible to the Azure Virtual Machines.