Last Update: Sep 04, 2024 | Published: Jul 14, 2014
Transferring files between virtual machines in Azure, or between an on premise server and a virtual machine (VM) in the cloud, has been a bit of a hassle up until now. But that’s all about to end with Azure Files, a new service from Microsoft that’s now in preview. In this article, I’ll show you how to create and connect to a file share in the cloud with Azure Files.
Azure Files lets administrators create standard Server Message Block (SMB) file shares, which is the type of file shares that would be created if you set up a shared folder on Windows Server in the cloud without provisioning a file server running in a virtual machine.
This allows organizations to port applications that rely on connecting to an SMB file share more easily to the cloud, and transfer files between VMs or on-site devices. Azure Files currently works on SMB 2.1, but there are plans to upgrade it to SMB 3.0 in the future. The Azure Files feature is billed according to file sizes, as opposed to bytes written in the case of Azure Blobs.
Because Azure Files is currently in preview, you’ll need to sign up and activate Azure Files to access this feature. You can add the feature to a current Azure subscription. Once the feature has been activated, you will receive a confirmation email from Microsoft. This could take a few days as the preview is being phased out gradually.
Once activated, Azure Files is only enabled for new storage accounts, so even if you have an already existing storage account associated with your subscription, you will need to create a new one as follows:
Create a new storage account in Azure (Image: Russell Smith)
Make sure that the LOCATION field on the Create Storage Account panel is set to the same location as where the VMs are located from which you would like to access file shares.
After a few minutes, the new storage account will appear in a tile on the portal start page. While we are in the portal, let’s get the management key for the new storage account.
Getting the management key for a storage account in Azure. (Image: Russell Smith)
Make a note of this key by pasting it into a convenient place. You’ll need it later.
Now we have a new storage account with the Azure Files feature enabled, we can create a file share. But before proceeding, make sure that you have the PowerShell tools for Azure configured on your management workstation. For more information on setting up PowerShell tools for Azure, see “Setup Windows Azure PowerShell Management” on the Petri IT Knowledgebase. Also, make sure to install the Windows Azure Storage Tools as part of this process using the Web Platform Installer.
In addition to the Windows Azure Storage Tools and PowerShell tools for Azure, you will need to install the Azure Files tools separately, as they are not currently included in either of the above packages while the feature is in preview. The following steps describe how to install the Azure Files tools:
Unblock security before unzipping the Azure Storage Files download. (Image: Russell Smith)
Let’s start PowerShell and create a new file share. Before following the instructions below, you need to set up the PowerShell tools for Azure, making sure they are connected to your subscription.
In a few seconds, you should see a message in the PowerShell console showing the URL of the storage account, and the name and last modified date of the new file share.
PowerShell console displaying storage account URL. (Image Russell Smith)
You can now connect to the file share from any VM located in the same region as the storage account. To connect to the file share, use any method that you would normally use to connect to an SMB file share in Windows. In this example, I’ll show you how to connect using the net use command.
Map a drive with net use. (Image: Russell Smith)
You need to replace <StorageAcc> with the name of the storage account we created earlier, <Key> with the long management key that we copied out of the management portal, and filesrms.file.core.windows.netmyfiles2 with the URL to your file share, which can be derived by adding the name of the share to the URL for your storage account, which was displayed in PowerShell after the file share was created.
The mapped drive in File Explorer. (Image: Russell Smith)
The easiest way to upload files to Azure is to use the AZCopy tool, which is part of the Windows Azure Storage Tools, and can be downloaded using Microsoft’s Web Platform Installer.
You should now see a progress message in the command prompt window showing you details of the requested upload.