You are currently viewing Create Network Drive Using Azure File Storage

Create Network Drive Using Azure File Storage

This article demonstrates how to create a new instance of Azure Files and how to mount it as a network drive.

What is Azure Files ?

Azure files is completely managed file share in the cloud, that is accessible from all over the world. The files can be accessed by using the HTTP REST calls, or it can also be accessed by using SMB protocol.

The SMB protocol lets you to mount this file share as a network drive. This share can be mounted on Windows, Linux of Mac machine.

This can be very useful if you want to replace on-premises file shares with cloud file shares. It can also be useful in “Lift and Shift” of applications if applications are using file share for storing some user data.

The file shares can be used during development and testing to keep the debugging / testing tools at one common shared path, instead of copying them to each and every machine.

How to create Azure File share ?

Below are the steps for creating the Azure file share:

We already have seen how to create the storage account in one of my previous blog articles. Please follow the steps and get the storage account created.

Next, you can go to Azure Portal and navigate to your storage account.

Once you open the storage account, you should be able to see option File Shares in the left side menu of storage account.

When you click on that, you can see a new panel from where you can click on add new file share (the + button).

You can see in below snapshot that I already have a file share with name samples, and now I am trying to create file share with name samples-2.

While creating the file share you also need to specify the storage quota. The quota is nothing but the size of the file share in GiB. The maximum allowed size is 5 TB for a file share.

Once you click on create button, the file share would be created immediately.

Common Azure CLI Commands

Below CLI commands can be used to create the file share. Please note that the file share is identified uniquely by an HTTP URL and hence the name of file share should be globally unique.

# Replace $STORAGEACCT with account name
# Replace $STORAGEKEY with storage account key

# To create File Share of name samples
# Please note file share name should be globally unique
az storage share create \
    --account-name $STORAGEACCT \
    --account-key $STORAGEKEY \
    --name "samples" 

# To create a directory in file share
az storage directory create \
   --account-name $STORAGEACCT \
   --account-key $STORAGEKEY \
   --share-name "samples" \
   --name "newdirectory"

# To upload the file 
az storage file upload \
    --account-name $STORAGEACCT \
    --account-key $STORAGEKEY \
    --share-name "samples" \
    --source "~/clouddrive/SampleUpload.txt" \
    --path "newdirectory/SampleUpload.txt"

# To list the contents of storage
az storage file list \
    --account-name $STORAGEACCT \
    --account-key $STORAGEKEY \
    --share-name "samples" \
    --path "newdirectory" \
    --output table

File Share Snapshot

In this section, let’s try to understand one important capability of File Share, the snapshots.

File share snapshots capture the File share state at that point of time. A share snapshot is a read only. You can create, delete, manage using REST APIs.

The snapshot is created at file share level. But you can read the files (reading is at file level). From space usage perspective, the space used by snapshot does not contribute towards the file share space quota you specified while creating the share.

You may want to use it for backup purpose. The URL for snapshot is same as the file share URL only difference is date time query string is appended to the URL specifying the time at which snapshot was created.

Mounting as Network Drive

The file share you created can be used as a network drive in the virtual machines in cloud. You can configure the file share in such a way that only the Azure VMs,

You can also use File share as network drive on your Windows, Linux or Mac OS laptop. For demonstration perspective, this article shows how to mount the file share on windows machine.

Mounting on Windows

For mounting the file share, you need to execute below command.

Please note that firstsampleaccount is the name of storage account and samples is the name of file share.

Please replace [drive letter], with the drive letter you want to use (e.g. z: ). For authorization, you can use storage account key of the storage account. You can get storage account key from portal.

If you use storage explorer, then you can use Connect VM option, and it will generate this command for you.

Run this command on command prompt and that’s it. The share is mounted on your windows machine.

net use [drive letter] \\\samples /u:firstsampleaccount [StorageAccountKey]

I hope this article provides enough information on file share. Let me know your thoughts.

Leave a ReplyCancel reply