Tutorial: Create an SMB Azure file share and connect it to a Windows VM using the Azure portal
Azure Files offers fully managed file shares in the cloud that are accessible via the industry standard Server Message Block (SMB) protocol or Network File System (NFS) protocol. In this tutorial, you will learn a few ways you can use an SMB Azure file share in a Windows virtual machine (VM).
If you don't have an Azure subscription, create a free account before you begin.
- Create a storage account
- Create a file share
- Deploy a VM
- Connect to the VM
- Mount an Azure file share to your VM
- Create and delete a share snapshot
Applies to
| File share type | SMB | NFS |
|---|---|---|
| Standard file shares (GPv2), LRS/ZRS | ||
| Standard file shares (GPv2), GRS/GZRS | ||
| Premium file shares (FileStorage), LRS/ZRS |
Getting started
Create a storage account
Before you can work with an Azure file share, you have to create an Azure storage account.
- Sign in to the Azure portal.
- On the Azure portal menu, select All services. In the list of resources, type Storage Accounts. As you begin typing, the list filters based on your input. Select Storage Accounts.
- On the Storage Accounts window that appears, choose + New.
- On the Basics tab, select the subscription in which to create the storage account.
- Under the Resource group field, select your desired resource group, or create a new resource group.
- Next, enter a name for your storage account. The name you choose must be unique across Azure. The name also must be between 3 and 24 characters in length, and may include only numbers and lowercase letters.
- Select a region for your storage account, or use the default region.
- Select a performance tier. The default tier is Standard.
- Specify how the storage account will be replicated. The default redundancy option is Geo-redundant storage (GRS).
- Select Review + Create to review your storage account settings and create the account.
- Select Create.
The following image shows the settings on the Basics tab for a new storage account:
Create an Azure file share
Next, create an SMB Azure file share.
When the Azure storage account deployment is complete, select Go to resource.
Select File shares from the storage account pane.

Select + File Share.

Name the new file share qsfileshare, enter "1" for the Quota, leave Transaction optimized selected, and select Create. The quota can be a maximum of 5 TiB (100 TiB, with large file shares enabled), but you only need 1 GiB for this.
Create a new txt file called qsTestFile on your local machine.
Select the new file share, then on the file share location, select Upload.

Browse to the location where you created your .txt file > select qsTestFile.txt > select Upload.
Deploy a VM
So far, you've created an Azure storage account and a file share with one file in it. Next, create an Azure VM with Windows Server 2019 Datacenter to represent the on-premises server.
Expand the menu on the left side of the portal and select Create a resource in the upper left-hand corner of the Azure portal.
Under Popular services select Virtual machine.
In the Basics tab, under Project details, select the resource group you created earlier.

Under Instance details, name the VM qsVM.
For Image select Windows Server 2019 Datacenter - Gen2.
Leave the default settings for Region, Availability options, and Size.
Under Administrator account, add a Username and enter a Password for the VM.
Under Inbound port rules, choose Allow selected ports and then select RDP (3389) and HTTP from the drop-down.
Select Review + create.
Select Create. Creating a new VM will take a few minutes to complete.
Once your VM deployment is complete, select Go to resource.
Connect to your VM
Now that you've created the VM, connect to it so you can mount your file share.
Select Connect on the virtual machine properties page.

In the Connect to virtual machine page, keep the default options to connect by IP address over port number 3389 and select Download RDP file.
Open the downloaded RDP file and select Connect when prompted.
In the Windows Security window, select More choices and then Use a different account. Type the username as localhost\username, where <username> is the VM admin username you created for the virtual machine. Enter the password you created for the virtual machine, and then select OK.

You may receive a certificate warning during the sign-in process. Select Yes or Continue to create the connection.
Map the Azure file share to a Windows drive
In the Azure portal, navigate to the qsfileshare fileshare and select Connect.
Select a drive letter then copy the contents of the second box and paste it in Notepad.
In the VM, open PowerShell and paste in the contents of the Notepad, then press enter to run the command. It should map the drive.
Create a share snapshot
Now that you've mapped the drive, create a snapshot.
In the portal, navigate to your file share, select Snapshots, then select + Add snapshot.

In the VM, open the qstestfile.txt and type "this file has been modified". Save and close the file.
Create another snapshot.
Browse a share snapshot
On your file share, select Snapshots.
On the Snapshots tab, select the first snapshot in the list.

Open that snapshot, and select qsTestFile.txt.
Restore from a snapshot
From the file share snapshot tab, right-click the qsTestFile, and select the Restore button.
Select Overwrite original file.

In the VM, open the file. The unmodified version has been restored.
Delete a share snapshot
On your file share, select Snapshots.
On the Snapshots tab, select the last snapshot in the list and select Delete.

Use a share snapshot in Windows
Just like with on-premises VSS snapshots, you can view the snapshots from your mounted Azure file share by using the Previous Versions tab.
In File Explorer, locate the mounted share.

Select qsTestFile.txt and > right-click and select Properties from the menu.

Select Previous Versions to see the list of share snapshots for this directory.
Select Open to open the snapshot.

Restore from a previous version
Select Restore. This copies the contents of the entire directory recursively to the original location at the time the share snapshot was created.

Note
If your file has not changed, you will not see a previous version for that file because that file is the same version as the snapshot. This is consistent with how this works on a Windows file server.
Clean up resources
When you're done, delete the resource group. Deleting the resource group deletes the storage account, the Azure file share, and any other resources that you deployed inside the resource group.
- Select Home and then Resource groups.
- Select the resource group you want to delete.
- Select Delete resource group. A window opens and displays a warning about the resources that will be deleted with the resource group.
- Enter the name of the resource group, and then select Delete.
Next steps
Maklum balas
Kirim dan lihat maklum balas untuk