Skip to main content

Azure File (Day 21 or 31)

List of all posts from this series:

Short Description 
Azure File Storage is a shared storage for any kind of applications and systems. Is constructed over Azure Storage and is used to share data and files across applications components. Content from this repository can be accessed not only by applications using mounted shares but also via File Storage API.

Main Features 
Cloud applications and On-premises
The content from Azure File Storage can be accessed not only by virtual machines that are running on Azure, but also from On-premises system using sharing capabilities (over File Storage API).
SMB 2.1 Protocol
Azure File Storage support Service Message Protocol version 2.1 that can be used to access shared file from different networks nodes and system.  This protocol was introduced with Windows 7 and Windows Server 2008 R2 and is used worldwide for file sharing.
Simultaneously Shares
Multiple applications can connect to (mount) the same share in the same time. We are not limited to only one applications. SMB protocol handle a part of the locking headaches that appear with simultaneously read and write access.
Virtual Machine 
If you are using Azure File Storage, it is very simple to integrate this file sharing and mount it as a normal drive/directory. From the OS you will be able to access the files from it like normal files/folders. In this way you can share content to multiple virtual machines.
Because of SMB 2.1 protocol, it has full support from PowerShell. System administrators can manage and mount this storage directly from command line or PowerShell.
Azure Applications
All application hosted on Microsoft Azure can access the file storage like using simple I/O operations. Migrating application from normal storage to Azure Files is very simple and natural, with minimal integration costs.
A Share is like a container for files and directory. As base concept is the same share concept from SMB protocol. A Storage Account can have unlimited number of shares. Usually I compare a Share with the partition concept. It is not the same thing but is very similar in the way how files and director are grouped under the same root.
All shares can be accessed not only using SMB 2.1 protocol but also via REST API. This can be used with success by on-premises system that need to access this content.
Shares for Linux
Yes, there are some versions of Linux that support Azure File Storage. For example Ubuntu allow us to mount the shares.
Queue Storage give us multiple options when we talk about redundancy. By default we have redundancy at data center level – this mean that all the time there are 3 copies of the same content (and you pay only one). On top of this there are other 3 options of redundancy that I will describe below (plus the one that we already talk about):

  • LRS (Local Redundant Storage) – Content is replicate 3 times in the same data center (facility unit from region) 
  • GRS (Geo Redundant Storage) – Content is replicated 6 times across 2 regions (3 times in the same region and 3 times across different regions
Pay only what you use 
At the end of the month you will pay only the space that you used. Because of this, clients don’t pay in advance the space that will be used or to pay for the space that is not used anymore.


  • In this moment there is a capacity limit per share of 5TB (even if Azure Blobs can go to 500TB).
  • Maximum size of a file is 1TB.
  • Current IOPS speed limitation per share is 1K.
  • Maximum data transfer bandwidth per share is 60MB. 
  • SMB 2.1 protocol can be used to access content only from applications a system from the same region. For external application we need to use the REST API protocol.

Applicable Use Cases 
Below you can find some use cases when I would use Azure Files.
Audit and Diagnostics information
We can use Shares to write crash dump, logs and system metrics. In this way we can have a real time sharing mechanism between systems that create the audit and diagnostic content and the systems that analyze them.
Kits and Tools distribution
Azure File can be used as a place where we can share content to different machines and users. In this way we can have our tools shared cross machines without having copy/paste them or downloading them from a central repository.
Extend storage capabilities
On a normal VM or on-premises machine the storage capabilities are limited. On top of this there are times when you want to share the same content on multiple machines. For example a picture directory that you want to share with all the machines. Azure Files allow to do this, having content shared across the globe with multiple systems.

Code Sample 
// Get a reference to storage content
$ctx=New-AzureStorageContext fooAccount fooAccountKey
// Create a new share
$s = New-AzureStorageShare fooshare -Context $ctx
// Create a directory called car
New-AzureStorageDirectory -Share $s -Path car
// Upload a picture with a BMW
Set-AzureStorageFileContent -Share $s -Source C:\cars\bmw.jpg -Path car
// List all files and directories under car folder 
Get-AzureStorageFile -Share $s -Path car
// Download bmw.jpg picture on the local storage
Get-AzureStorageFileContent -Share $s -Path car/bmw.jpg -Destination C:\myCar
// Remove bmw.jpg pictures from our share
Remove-AzureStorageFile -Share $s -Path car/bmw.jpg 

Pros and Cons 

  • Maxim size of a file is 1TB.
  • SMB 2.1 support


  • Azure Emulator doesn’t support Azure Files in this moment.
  • No support for AD based authentication.   

When you start to calculate the cost of Azure Blob Storage you should take into account the following things:

  • Capacity (size) 
  • Number of Transactions 
  • Outbound traffic 
  • Traffic between facilities (data centers)

Azure Files can be used with success when you need to share content over multiple Virtual Machines. With support of SMB 2.1 it is a good option when you need to share a file on machines that are hosted on Azure.


Popular posts from this blog

ADO.NET provider with invariant name 'System.Data.SqlClient' could not be loaded

Today blog post will be started with the following error when running DB tests on the CI machine:
threw exception: System.InvalidOperationException: The Entity Framework provider type 'System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer' registered in the application config file for the ADO.NET provider with invariant name 'System.Data.SqlClient' could not be loaded. Make sure that the assembly-qualified name is used and that the assembly is available to the running application. See for more information. at System.Data.Entity.Infrastructure.DependencyResolution.ProviderServicesFactory.GetInstance(String providerTypeName, String providerInvariantName) This error happened only on the Continuous Integration machine. On the devs machines, everything has fine. The classic problem – on my machine it’s working. The CI has the following configuration:

TeamCity.NET 4.51EF 6.0.2VS2013
It seems that there …

Entity Framework (EF) TransactionScope vs Database.BeginTransaction

In today blog post we will talk a little about a new feature that is available on EF6+ related to Transactions.
Until now, when we had to use transaction we used ‘TransactionScope’. It works great and I would say that is something that is now in our blood.
using (var scope = new TransactionScope(TransactionScopeOption.Required)) { using (SqlConnection conn = new SqlConnection("...")) { conn.Open(); SqlCommand sqlCommand = new SqlCommand(); sqlCommand.Connection = conn; sqlCommand.CommandText = ... sqlCommand.ExecuteNonQuery(); ... } scope.Complete(); } Starting with EF6.0 we have a new way to work with transactions. The new approach is based on Database.BeginTransaction(), Database.Rollback(), Database.Commit(). Yes, no more TransactionScope.
In the followi…

GET call of REST API that contains '/'-slash character in the value of a parameter

Let’s assume that we have the following scenario: I have a public HTTP endpoint and I need to post some content using GET command. One of the parameters contains special characters like “\” and “/”. If the endpoint is an ApiController than you may have problems if you encode the parameter using the http encoder.
using (var httpClient = new HttpClient()) { httpClient.BaseAddress = baseUrl; Task<HttpResponseMessage> response = httpClient.GetAsync(string.Format("api/foo/{0}", "qwert/qwerqwer"))); response.Wait(); response.Result.EnsureSuccessStatusCode(); } One possible solution would be to encode the query parameter using UrlTokenEncode method of HttpServerUtility class and GetBytes method ofUTF8. In this way you would get the array of bytes of the parameter and encode them as a url token.
The following code show to you how you could write the encode and decode methods.