In this tutorial we are going to map a network drive on our computer to a file storage in the cloud using Azure File Storage. This can be very helpful if you want to share files among multiple computers and, bearing in mind that the storage is in the cloud, you can scale your drive as much as you need.
First of all, let’s start with the basics and learn some things about Azure Storage.
What is Azure Storage?
Azure Storage is the cloud storage solution for modern applications that rely on durability, availability and scalability. You can store as much data as you want and use it in many different ways based on the usage scenario you are interested in. It is accessible from anywhere in the world, from any type of application, whether it’s running on the cloud, on the desktop, on an on-premises server, or on a mobile or tablet device.
Azure Storage provides four services:
- Blob Storage stores unstructured object data. A blob can be any type of text or binary data, such as a document, a media file, or an application installer. Blob storage is also referred to as Object storage.
- Table Storage stores structured datasets. Table storage is a NoSQL key-attribute data store, which allows for rapid development and fast access to large quantities of data.
- Queue Storage provides reliable messaging for workflow processing and for communication between components of cloud services.
- File Storage, which we are going to use in this post, offers shared storage for legacy applications using the standard SMB protocol. Azure virtual machines and cloud services can share file data across application components via mounted shares, and on-premises applications can access file data in a share via the File service REST API.
For more information on Azure Storage you can start from this introductory article.
What is File Storage?
Azure File storage is a service that offers file shares in the cloud using the standard Server Message Block (SMB) Protocol (SMB 2.1 or SMB 3.0). You can mount a File Storage share to access file data, just as you would mount a typical SMB share. There is no limitation to the number of computers or roles that can mount and access the File storage share simultaneously. While in the cloud, you can scale as much as you want based on your needs.
File Storage contains the following components:
- Storage account that provides access to Azure Storage.
- Share which is an SMB file share in Azure. All directories and files must be created in a parent share. An account can contain an unlimited number of shares, and a share can store an unlimited number of files, up to the 5 TB total capacity of the file share.
- Directory which is nothing more than an optional hierarchy of directories.
- File that stands for the actual file and that can be up to 1 TB in size.
For more info on Azure File Storage you can start here.
Create Storage Account
First of all you need to create a storage account that will give you access to the File Storage service that you are going to use. You can do that through the Azure portal:
To create a new Storage Account you need to follow the steps below:
- specify a Name, which shall be unique across all storage account names in Azure,
- select the deployment model; for new applications, Resource Manager is a better choice as it provides more benefits,
- choose between standard and premium performance; in our case standard is better, as data is stored in magnetic drives and it provides lower costs per GB,
- select the replication strategy that matches your durability requirements, in our case Locally-Redundant Storage (LRS) replicates data within the region in which you created your storage account by creating 3 copies on separate nodes,
- create a new or use an existing resource group to group your resources and
- select the location of the datacenter where your storage account should be created on and click create.
Create File Storage
After your Azure Storage Account is created you need to create a File Share. From the storage account you have previously created, select Files and add a new File Service. Name your service and set a Quota in GB, to limit the total size of files on the share.
Note that you can change quota whenever you want and scale your drive based on your needs.
Map Network Drive
Now that your file share is created, you can map it as a network drive in your computer. You can achieve that in many ways but for all of them you are going to need three things:
- The url for your share which can be found if you click on the properties button on your file share toolbar:
Note that you should change
\\in order to mount the file share.
- The storage account name and the storage account key to allow access to your file share:
Map network drive in Linux
To connect to this file share from a Linux computer, run this command:
$ sudo mount -t cifs //ppolstorage.file.core.windows.net/cloud-drive [mount point]
-o vers=3.0,username=ppolstorage,password=[storage account access key],dir_mode=0777,file_mode=0777
Map network drive in Windows
Using Command Line
To connect to this file share from a Windows computer, run this command:
$ net use [drive letter] \\ppolstorage.file.core.windows.net\cloud-drive
/u: [storage account access key]
Using Windows Explorer
Open your Windows Explorer and from File click on Map network drive. Select the drive letter to use, specify the folder and be sure to check the Connect using different credentials. When you click Finish a security popup will appear where you shall specify:
- storage account name as username and
- storage account key as password
Now you can drag’n’drop files in your new network drive, which will automatically appear in Azure Portal and in all connected devices.