1. Using the Azure Files in
Your Cloud Applications
Introduction to Microsoft Azure File Service
2.
3.
4. Mihail Mateev
Senior Technical Evangelist
@ Infragistics,
Microsoft Azure MVP
30 of September 2014
Using the Azure
Files in Your Cloud
Applications
Mihail Mateev
5.
6. About the speaker ...
Mihail Mateev is a Senior Technical Evangelist,
Team Lead at Infragistics Inc., Community &
Evangelism Lead for Europe,
Microsoft Azure MVP
Mihail works in various areas related to
Microsoft technologies : Silverlight, WPF, WP,
LightSwitch, WCF, ASP.Net MVC, MS SQL Server
and Microsoft Azure
7. • How to Use Azure File Storage?
• File storage concepts
• Limitations
• Manage Azure Files
• When to use Azure Blobs, Azure Files,
or Azure Data Disks?
• Demos
8. • 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.
• You 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.
9. • Azure files is a way to share persistent data between multiple
servers or PaaS roles (such as websites) without having to set up
file servers.
• The storage is provided by highly resilient storage and so there is
no need to worry about placement and accessibility of individual
VHD files
• You can share it with several VMs for read/write access
( Azure Drive allows to write only one VM, but read data from
many)
10. Currently during the preview the costs
are discounted at 50% :
• €0.0298 per GB for locally redundant file shares
• €0.0373 per GB for geo redundant file shares.
Full pricing for storage can be found here
http://azure.microsoft.com/en-us/pricing/details/storage/ .
11. • First we use PowerShell to show how to create a new Azure File share,
add a directory, upload a local file to the share, and list the files in the
directory.
• Then you can mount the file share from an Azure virtual machine, just
as you would any SMB share
• You also can use the Azure .NET Storage Client Library to work with
the file share from a desktop application.
12. • Since a File storage share is a standard SMB 2.1 file share,
applications running in Azure can access data in the share via
file I/O APIs.
• Developers can therefore leverage their existing code and skills
to migrate existing applications.
• IT Pros can use PowerShell cmdlets to create, mount, and
manage File storage shares as part of the administration of
Azure applications. This guide will show examples of both.
13. Common uses of File storage:
•Migrating on-premise applications that rely on file shares to run on Azure
virtual machines or cloud services, without expensive rewrites
•Storing shared application settings, for example in configuration files
•Storing diagnostic data such as logs, metrics, and crash dumps in a shared
location
•Storing tools and utilities needed for developing or administering Azure virtual
machines or cloud services
15. • Azure files is in preview mode and so there will be no SLAs
provided
• Once activated, 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
• The file shares are only available to virtual machines or PaaS
websites within the same datacenter as the file share storage
account.
• Access to the file shares is provided via Azure Storage Keys -
there are is no AD integration.
16. • 5TB per share
• Max file size 1TB
• Up to 1000 IOPS (input/output operations
per second of size 8KB) per share
• Throughput Up to 60MB/s per share of data transfer
• SMB 2.1 support only
17. • Activate Azure Files Preview
• Create new storage account and retrieve access key.
• Download the Azure file storage cmdlets, unblock, extract
and import into your PowerShell session.
• Install Azure PowerShell Modules and connect to you
Azure subscription.
• Setup the account credentials and create the file share
from PowerShell,.
• From another Azure VM attach the file share as a mapped
drive.
18. Prerequisites
• Sign up for service:
go to the Microsoft Azure Preview Portal, and
sign up for the Microsoft Azure Files service using
one or more of your subscriptions
• Create a new storage account
The file endpoint for the account will be:
<account name>.file.core.windows.net.
19. # import module and create a context for account and key
import-module .AzureStorageFile.psd1
$ctx=New-AzureStorageContext <account name> <account key>
# create a new share
$s = New-AzureStorageShare <share name> -Context $ctx
# create a directory in the test share just created
New-AzureStorageDirectory -Share $s -Path testdir
# upload a local file to the testdir directory just created
Set-AzureStorageFileContent -Share $s -Source D:uploadtestfile.txt -Path testdir
# list out the files and subdirectories in a directory
Get-AzureStorageFile -Share $s -Path testdir
# download files from azure storage file service
Get-AzureStorageFileContent -Share $s -Path testdir/testfile.txt -Destination D:download
# remove files from azure storage file service
Remove-AzureStorageFile -Share $s -Path testdir/testfile.txt
20. • You can also create a file share programmatically using the ‘Create
Share’ REST API with version 2014-02-14 REST APIs are
available via http(s)://<account name>.file.core.windows.net Uri.
• The .NET Storage Client Library starting with 4.0 version uses the REST
version 2014-02-14 and supports Azure Files.
static void Main( string[] args)
{
CloudStorageAccount account = CloudStorageAccount.Parse(cxnString);
CloudFileClient client = account.CreateCloudFileClient();
CloudFileShare share = client.GetShareReference("bar");
share.CreateIfNotExistsAsync().Wait();
}
21. • To use the share via SMB 2.1 protocol, log into the VM that requires
access to the share and execute “net use” :
net use z: <account name>.file.core.windows.net<share name>
/u:<account name> <account key>
• Share from C# code:
ExecuteCommand(“ <your command> “ );
22. “net use” demo :
• cmdkey /add:uploadfileshare.file.core.windows.net
/user:uploadfileshare
/pass:cjz1PD0ivoammgPUJGfRu2Lcy/blhmvlHUkAWX6tSN6lz2/kJVG
zTyqYJ2Byf5Y4/BwG8KNS/jWXvQfRsZiDPA==
• net use z: uploadfileshare.file.core.windows.netmyshare
23. Azure Files is a separate service from Azure Blobs. In preview,
we do not support copying Azure Blobs to Azure Files.
Microsoft Azure Import/Export Service does not support Azure
Files for preview
24. AzCopy
•Upload files from your local disk recursively to Azure Files, with all folder structures copied as well.
AzCopy d:test https://myaccount.file.core.windows.net/myfileshare/ /DestKey:key /s
• Upload files with certain file pattern from your local disk to Azure Files.
AzCopy d:test https://myaccount.file.core.windows.net/myfileshare/ /DestKey:key ab* /s
•Download all files in the file share recursively to local disk, with all folder structures copied as well.
AzCopy https://myaccount.file.core.windows.net/myfileshare/ d:test /SourceKey:key /s
•Download one file from the file share to your local disk
AzCopy https://myaccount.file.core.windows.net/myfileshare/myfolder1/ d:test
/SourceKey:key abc.txt
27. Download files from a folder on the share
CloudFile cloudFile2 = directoryToUse.GetFileReference(fileNameOnly);
cloudFile2.DownloadToFile(localPath, FileMode.Create);
Get a list of files in a folder on the share
public enum ListBoxFileItemType { File, Directory, Other };
public class ListBoxFileItem
{
public string FileName { get; set; }
public ListBoxFileItemType FileItemType { get; set; }
public override string ToString()
{
return FileName;
}
}
28. •Azure Data Disks – Provides client libraries and a REST
interface that allows data to be persistently stored and
accessed from an attached virtual hard disk.
Reasons you would use Azure Data Disks:
• You want to lift and shift applications that use native file system APIs to read
and write data to persistent disks.
• You want to store data that is not required to be accessed from outside the
virtual machine to which the disk is attached.
29. •Azure Blobs - Provides client libraries and a REST
interface that allows unstructured data to be stored and
accessed at a massive scale in block blobs.
Reasons you would use Azure Blobs:
• You want your application to support streaming and random access scenarios.
• You want to be able to access application data from anywhere.
30. •Azure Files - Provides an SMB 2.1 interface and a REST
interface that allows easy access from anywhere to stored
files.
Reasons you would use Azure Files:
• You want to lift and shift an application to the cloud which already uses
the native file system APIs to share data between it and other applications
running in Azure.
• You want to store development and debugging tools that need to be
accessed from many virtual machines.
31. •
• Azure Files 2014-04-14 version
• AzCopy
• Azure File PowerShell Cmdlets (CTP)
• Storage .NET Client Library 4.0 for 2014-04-14 version
•
•
•
• http://www.Infragistics.com/mihail_mate
ev