Using Azure Files (Preview)

The Azure File service enables the use of highly available and scalable Azure blob storage to be used as file shares for multiple virtual machines or PaaS roles.   Essentially one can create a cloud based file share on resilient storage subsystems and then access those file shares using the standard SMB 2.1 protocol.  The file shares appear as mapped drives on the virtual machines they are assigned to.

 

Why use Azure Files ?

Azure files is a great way to share persistent data between multiple servers or PaaS roles (such as websites) without having to set up file servers.  This can be to store configuration files, log files or any other data and make it independent to a virtual machine instance.  The storage is provided by highly resilient storage and so there is no need to worry about placement and accessibility of individual VHD files.

 

How much does it cost ?

Currently during the preview the costs are discounted at 50% and are £0.0255 per GB for locally redundant file shares or £0.0319 per GB for geo redundant file shares. Locally redundant means that the data is stored in triplicate in the same data centre and geo redundancy adds replication to another data centre.  This can be set during creation of the storage account and can also be changed if required after creation.  Full pricing for storage can be found here http://azure.microsoft.com/en-us/pricing/details/storage/.

 

Current Limitations and Requirements of Using Azure Files

  • Currently Azure files is in preview mode and so there will be no SLAs provided until it goes to General Availability.
    • This means you must also request access to the service which is available on the Azure preview page
  • Once activated (can take minutes) you must set up a new storage account which can be regional or assigned to an affinity group.
  • You can only create the file shares using PowerShell.
  • Read-Access Geographically Redundant Storage (RA-GRS) storage accounts are not supported, only local and geo redundant options are available at this time.
  • The file shares are only available to virtual machines or PaaS websites within the same datacentre as the file share storage account.
  • Access to the file shares is provided via Azure Storage Keys.  Currently there are is no AD integration.

 

Steps Required To Get Up And Running

  1. Activate Azure Files Preview from the preview page  (link above).
  2. Create new storage account and retrieve access key.
  3. Download the Azure file storage cmdlets, unblock, extract and import into your PowerShell session.
  4. Install Azure PowerShell Modules and connect to you Azure subscription.
    • Previous article on how to connect to Azure using PowerShell is here
  5. From PowerShell, setup the account credentials and create the file share.
  6. From another Azure VM attach the file share as a mapped drive.

 

1. Activate Azure Files Preview

  • From the Azure preview page locate the Azure Files feature and click “Try it”.  Microsoft will send an email shortly after (could be minutes).

image

 

2. Create Storage Account

  • Create a new storage account

image

  • Once created, open the storage account dashboard and you will see the Files preview service listed as shown here :-

image

  • Click on Manage Access Keys, copy one of the keys and keep it safe for the scripting section later in section 5 below.

image

3. Download The Azure Storage File PowerShell Modules

image

 

4. Connect To Your Azure Subscription In PowerShell and Import the Storage Module

If you have not setup PowerShell to connect to Azure yet please see here.

 

#Get-AzurePublishSettingsFile
#Import-AzurePublishSettingsFile ‘C:\Myfile.publishsettings’

#Set Subscription Name
$subscriptionname = ‘My Demos’

Set-AzureSubscription $subscriptionname -CurrentStorageAccountName ‘mcdemostore’
Select-AzureSubscription $subscriptionname

#Import downloaded storage module
import-module ‘C:\scripts\AzureStorageFile\AzureStorageFile.psd1’

5. Create a Context for Account and Key

  • From the same PowerShell session enter the storage context which is essentially the account name and password (storage key).

The format for this is $ctx=New=AzureStorageContext <account name> <account key>

The account name we have set up in this example is filesharestore which can be seen here to show you the context.

image

#Create a context for account and key

$ctx=New-AzureStorageContext filesharestoreStorage key

  • Create a New Share

This code will actually create a file share in Azure using the account and storage key used above.  We need to supply a share name.

# create a new share
$s = New-AzureStorageShare sqlbackupshare -Context $ctx

 

6. Attach The Share to Azure Virtual Machines

Log into an Azure virtual machine located in the same region as the storage account used above.  We will create a persistent share so it remains after a reboot.  To do this we need to store the credentials and map the drive using the stored credentials.

  • Open up an administrative PowerShell window and enter the following code and substitute your own account name and storage key.
cmdkey /add:filesharestore.file.core.windows.net /user:filesharestore /pass:’Yourkey
net use z: \\filesharestore.file.core.windows.net\sqlbackupshare

Voila!

image

 

Troubleshooting Azure Files

  • Trying to mount an Azure file share using net use fails with code 64.

net : System error 64 has occurred.

The specified network name is no longer available.

This occurs as the file share is only mountable from another Azure resource (virtual machine or website) in the same region as the storage account.

  • Importing the AzureStorageFile.psd1 gives errors

    import-module : The following error occurred while loading the extended type data file:
    , C:\scripts\AzureStorageFile\AzureStorageFile\Microsoft.WindowsAzure.Commands.Storage.File.types.ps1xml(5) : Error in type

This looks like a bug as the process continues to work regardless of these errors.  If anyone knows any more please feel free to post here.

 

 

Thank you for taking the time to read this article about Azure Files !

I hope this was useful for some of you.   Do let me know if it was as that’s the reason I make these tutorials 🙂

If there are things you can add or have some good ideas about the use of Azure files also let me know so we can all share some good ideas.  This maybe where Microsoft are heading towards better support for clustering in the future but we shall wait and see !  Thanks again.

 

Mitesh

Advertisements

About Mitesh Chauhan
Mitesh Chauhan, Azure Cloud Solutions Architect. This is my blog where I share articles and thoughts on IT Infrastructure and architecture. The topics I am most passionate about are Implementation and architecture of rock solid Cloud Infrastructure based around SQL Server and Windows Server mainly using Microsoft Azure. MCTS - Azure Architecture MCTS - Azure Implementation MCSE Server Infrastructure (Windows Server 2012) , MCITP SQL Server 2008, Togaf Certified, Prince 2 Practitioner.

One Response to Using Azure Files (Preview)

  1. Pingback: Using Azure Files (Preview) - Information Management Group Ltd.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: