I’m excited about the Preview of the Microsoft Azure File Server and today and I want show you how I got it working. I am using a test account, so I will share all of the details with you as I set this up. And yes this storage account was deleted before I posted this blog.
I want to start by pointing you to this blog that gives you all the detail on the Microsoft Azure File Service, I will make multiple references to this blog because it is a wealth of information. This post will talk about how I boiled down the information in the blog to connect my Azure VMs to this Azure File Server.
Now down to the detail. I’m assuming you already have an Azure account setup and I’ll move directly into setting up the storage account.
First you need to setup a Storage account in Azure.
Details: During the Preview, existing storage accounts do not have access to Azure Files, so you need to create a new storage account. Once your share is created, it can be accessed via the SMB or REST protocol from any Azure node (VM/Worker/Web role) hosted in the same region as the storage account hosting the share. Since this share is only accessible to the Azure workloads in the same region, I put my storage account in the same affinity group as the Virtual Network that contains the VMs that will be accessing the share. This ensures that the storage account is always available to my Azure workloads (VMs) that need the share. Remember the geographical limit here is the region, so any VMs within the same region should be able to access this share as well.
Second, Now that I’ve setup the storage account, we now need to configure access to it. First take a look at the Storage Account dashboard and it will show you the access points for your new storage account. Notice the added line of Files (in Preview).
Third, the first two steps have been easy via the User Interface, now we will have to use a bit of PowerShell. We need to make sure PowerShell and the new Azure File Share CmdLets are installed. If you need to install PowerShell, you can install it from here. Once PowerShell is installed, you need to install the CmdLets for Azure File Share here, be sure to read FAQ.7 on how to install the File Share CmdLets.
Fourth, now on to the actual connection. We setup the actual file share via PowerShell. The article I’m referencing covers other ways to access the File Share, but I’m just going to talk about PowerShell here. Below is a screen shot of my Azure PowerShell screen executing the PowerShell commands to setup this share. Don’t worry, I’ll give you more detail below, but I wanted to make sure you saw EVERYTHING. I don’t like it when I have to figure out the “little details”, so I wanted to show you verbatim what happened. And yes, I deleted this storage account before I published this blog.
Before we can actually use the File Share capabilities, we need to import the module for Azure File Shares, and then point to the new storage account we created. Remember when I told you I was sharing all of the “little details”? The third line of my PowerShell sample, the one that starts with $ctx=, contains my Azure Storage Account Name ‘azurefilesharedemo’ and then the Access Key for my azure storage account. Hint: the name of your share needs to be all lower case.
# import module and create a context for account and key
$ctx=New-AzureStorageContext 'azurefilesharedemo' 'wB9Rld+X/iDeHXdRgjxDaX8ePLyY8z0KusM8Qo2VAQPHAztNRN8/J19hNc7kBFKjNnVjbFqniI5KCiBjLCvm6g=='
You can access your Storage Account Name and Access Key from the MANAGE ACCESS KEYS icon at the bottom of the dashboard for your storage account.
Fifth, Now we have identified our Azure share and the credentials, the command below will tell PowerShell to create the share and storage.
# create a new share
$s = New-AzureStorageShare 'newshare' -Context $ctx
# create a directory in the test share just created
New-AzureStorageDirectory -Share $s -Path testdir
Now we’ve setup the storage and am able to connect to your storage (using a net share) from your Virtual Machines. Here is the actual net use command I used to connect to my new storage.
net use * \\azuredemoshare.file.core.windows.net\demofileshare1 /u:azuredemoshare GgMyRwNO4ay/WhraF459AYDCKV99JTlybjItMRA5y5Ijeds8VNULLXLLS/sWH/fkVYmH3OODznusCL9zhTzI0g==
Here is the screen shot of the actual net use command and a directory of my new share. I went ahead and created the TestMe directory and hello.txt file so I’d have something to show you.
Now, remember that this connection is only supported from with the Azure Region because we are using SMB 2.1. I wasn’t able to connect to this share from my local machine, but I could connect to it from multiple VMs with my Azure account. If you need global access to this share, you have to use the REST API, which is also discussed in the article I referenced.
(June 12, 2014) I wanted to share some updated information around Azure File Shares. As I mentioned, you can access the File Share from any VM within the same Region of your File Share, but you cannot access the File Share from on-premises resources connected via a Virtual Network unless you are using ExpressRoute. According to my teammate Todd Sweetser, ExpressRoute opens up this new File Share capability to your ExpressRoute connections as well as your VMs located in the same Region.
Finally, now you have a drive letter mapped to a 5TB file share within Microsoft Azure. I will use a share like this to store my installation files and other items that will be leveraged by more than one VM. Also remember that multiple VMs can connect to this share at the same time.
Until next time,
I have the file share created and I am able to map the share on 2 of my VM's. I have to be logged on for the servers to see the map drive. Is there a way to have the shares mapped without having a user log on? My goal is to have a group of web servers use the
share, but not have any user logged on. Is this even possible? I have posted questions on MSDN, but so far no answers.
I have created the file share and have attempted to use the net use * \\azuredemoshare.file.core.windows.net\demofileshare1 /u:azuredemoshare GgMyRwNO4ay/WhraF459AYDCKV99JTlybjItMRA5y5Ijeds8VNULLXLLS/sWH/fkVYmH3OODznusCL9zhTzI0g== with updated account
details but I am getting syntax error on PS
Does anyone know whether it will be possible in future to map Azure Files on a local machine connected via a VPN not using ExpressRoute?
@rob and jay, did you get a response to your questions? We have similar need as well.
hi, I've tried to create a Storage Account in the Portal Preview, but I don't see the Files (Preview) being displayed in the portal... Am I missing a step?
@Paddy, you have to enable Files (preview) service to be able to use it. Once enabled, any new storage account you add will have this feature for you to use. Good Luck.
Hi, is there a way in hybrid scenario to mount the mapped drive as a network drive accessible by machines not in azure but in our network?
I am wondering about tha same thing as Vinny. Is it possible to map the network drive directly on my computer?
is it possible to create multiple 5TB shares and map them all from the same vm?
I am trying to do this for sometime, and am consistently getting 'specified network name is no longer available' system error 64.
Trying this over an azure hosted IAAS VM on the same region as the storage account. Could it be firewalled? any specific ports needs to be opened..
Oh k. My VM was in a different region :( and hence the error.
Great article. Thanks for sharing!