Edit

Configure network endpoints for accessing Azure file shares

✔️ Applies to: Classic file shares created with the Microsoft.Storage resource provider

✔️ Applies to: File shares created with the Microsoft.FileShares resource provider

Azure Files provides two main types of endpoints for accessing Azure file shares:

  • Public endpoints, which have a public IP address and can be accessed from anywhere in the world.
  • Private endpoints, which exist within a virtual network and have a private IP address from within the address space of that virtual network.

For classic file shares (created with the Microsoft.Storage resource provider), public and private endpoints exist on the Azure storage account. For file shares created with the Microsoft.FileShares resource provider, public and private endpoints are created at the file share level rather than the storage account level.

This article focuses on how to configure a private endpoint for accessing the Azure file share directly. Much of this article also applies to how Azure File Sync interoperates with public and private endpoints for the storage account. For more information about networking considerations for Azure File Sync, see configuring Azure File Sync proxy and firewall settings.

We recommend reading Azure Files networking considerations before reading this guide.

Prerequisites

  • This article assumes that you already created an Azure subscription. If you don't already have a subscription, then create a free account before you begin.
  • This article assumes that you already created an Azure file share in a storage account that you want to connect to from on-premises. To learn how to create an Azure file share, see Create an Azure file share.
  • If you intend to use Azure PowerShell, install the latest version.
  • If you intend to use the Azure CLI, install the latest version.

Endpoint configurations

You can configure your endpoints to restrict network access to your storage account. There are two approaches to restricting access to a storage account to a virtual network:

  • Create one or more private endpoints and restrict all access to the public endpoint. This ensures that only traffic originating from within the desired virtual networks can access the Azure file shares. See Private Link cost.
  • Restrict the public endpoint to one or more virtual networks. This works by using a capability of the virtual network called service endpoints. When you restrict the traffic to a storage account via a service endpoint, you're accessing via the public IP address, but access is only possible from the locations you specify in your configuration.

Create a private endpoint

When you create a private endpoint for your file shares, the following Azure resources are deployed:

  • A private endpoint: An Azure resource representing the private endpoint. You can think of this as a resource that connects a target resource and a network interface.
  • A network interface (NIC): The network interface that maintains a private IP address within the specified virtual network/subnet. This is the exact same resource that gets deployed when you deploy a virtual machine (VM), however instead of being assigned to a VM, it's owned by the private endpoint.
  • A private Domain Name System (DNS) zone: If you haven't deployed a private endpoint for this virtual network before, a new private DNS zone will be deployed for your virtual network. A DNS record will also be created in this DNS zone. If you've already deployed a private endpoint in this virtual network, a new record will be added to the existing DNS zone. Deploying a DNS zone is optional. However, it's highly recommended, and required if you're mounting your Azure file shares with an AD service principal or using the FileREST API.

Note

This article uses DNS suffix for the Azure Public regions, core.windows.net. This commentary also applies to Azure Sovereign clouds such as the Azure US Government cloud and the Microsoft Azure operated by 21Vianet cloud. Just substitute the appropriate suffixes for your environment.

Classic vs. new file share experience

The private endpoint creation process differs slightly depending on whether you're using classic file shares or the new file share:

Classic file shares (Microsoft.Storage) New file shares (Microsoft.FileShares)
Private endpoint target Storage account File share
Resource cmdlet Get-AzStorageAccount Get-AzFileShare
Group ID (sub-resource) file FileShare
DNS A record name Storage account name Host name prefix (e.g., fs-xxxxxxxxxxxxxxxxx)

The virtual network setup, private endpoint creation, and DNS zone configuration steps are identical for both experiences. Only the resource reference, group ID, and DNS record name differ.

Navigate to the resource group in which you would like to create a private endpoint. Click + Create and search for Private Endpoint. Select the private endpoint resource, and then select Create.

The resulting wizard has multiple pages to complete.

In the Basics blade, select the desired subscription, resource group, name, network interface name, and region for your private endpoint. You must create the private endpoint in the same region as the virtual network you wish to create the private endpoint in. Then select Next: Resource.

Screenshot showing how to provide the project and instance details for a new private endpoint.

If you're using classic file shares:

In the Resource blade, choose Microsoft.Storage/storageAccounts from the drop-down menu for the resource type. Then select the specific storage account you want to connect to as Resource. The target sub-resource will auto-populate with file. Then select Next: Virtual Network.

If you're using the new file share:

In the Resource blade, choose Microsoft.FileShares/fileShares from the drop-down menu for the resource type. Then select the specific file share you want to connect to as Resource. The target sub-resource will auto-populate with FileShare. Then select Next: Virtual Network.

The Virtual Network blade allows you to select the specific virtual network and subnet you would like to add your private endpoint to. Select dynamic or static IP address allocation for the new private endpoint. If you select static, you'll also need to provide a name and a private IP address. You can also optionally specify an application security group. When you're finished, select Next: DNS.

Screenshot showing how to provide virtual network, subnet, and IP address details for the new private endpoint.

The DNS blade contains the information for integrating your private endpoint with a private DNS zone. Make sure the subscription and resource group are correct, then select Next: Tags.

Screenshot showing how to integrate your private endpoint with a private DNS zone.

You can optionally apply tags to categorize your resources, such as applying the name Environment and the value Test to all testing resources. Enter name/value pairs if desired, and then select Next: Review + create.

Screenshot showing how to optionally tag your private endpoint with name/value pairs for easy categorization.

Select Create to create the private endpoint.

Verify connectivity

If you have a VM inside of your virtual network, or you've configured DNS forwarding as described in Configuring DNS forwarding for Azure Files, you can test that your private endpoint is set up correctly. Run the following commands from PowerShell, the command line, or the terminal (works for Windows, Linux, or macOS).

For classic file shares, replace <storage-account-name> with the appropriate storage account name:

nslookup <storage-account-name>.file.core.windows.net

For file shares created with the Microsoft.FileShares resource provider, use the file share's host name. In the overview tab of the file share, Select JSON view from the upper right. In the JSON view, under properties, copy the value for hostName. The format looks like fs-xxxxxxxxxxxxxxxxx.xx.file.storage.azure.net.

nslookup <file-share-host-name>

If successful, you should see output similar to the following, where 192.168.0.5 is the private IP address of the private endpoint in your virtual network (output shown for Windows).

For classic file shares:

Server:  UnKnown
Address:  10.2.4.4

Non-authoritative answer:
Name:    storageaccount.privatelink.file.core.windows.net
Address:  192.168.0.5
Aliases:  storageaccount.file.core.windows.net

For file shares created with the Microsoft.FileShares resource provider:

Server:  UnKnown
Address:  10.2.4.4

Non-authoritative answer:
Name:    <hostNamePrefix>.privatelink.file.core.windows.net
Address:  192.168.0.5
Aliases:  <hostNamePrefix>.<zone>.file.storage.azure.net

Restrict public endpoint access

Limiting public endpoint access first requires you to disable general access to the public endpoint. Disabling access to the public endpoint does not impact private endpoints. After the public endpoint is disabled, you can select specific networks or IP addresses that may continue to access it. In general, most firewall policies for a storage account restrict networking access to one or more virtual networks.

Disable access to the public endpoint

When access to the public endpoint is disabled, the storage account can still be accessed through its private endpoints. Otherwise valid requests to the storage account's public endpoint will be rejected, unless they are from a specifically allowed source.

For classic file shares:

Navigate to the storage account for which you would like to restrict all access to the public endpoint. In the table of contents for the storage account, select Networking.

At the top of the page, select the Enabled from selected virtual networks and IP addresses radio button. This will un-hide a number of settings for controlling the restriction of the public endpoint. Select Allow Azure services on the trusted services list to access this storage account to allow trusted first party Microsoft services such as Azure File Sync to access the storage account.

Screenshot of the Networking blade with the required settings to disable access to the storage account public endpoint.

For file shares created with the Microsoft.FileShares resource provider:

Navigate to the file share for which you would like to disable public access. In the service menu, under Settings, select Configuration. Set Public network access to Disabled, and then select Save.

Restrict access to the public endpoint to specific virtual networks

When you restrict the storage account to specific virtual networks, you're allowing requests to the public endpoint from within the specified virtual networks. This works by using a capability of the virtual network called service endpoints. This can be used with or without private endpoints.

For classic file shares:

Navigate to the storage account for which you would like to restrict the public endpoint to specific virtual networks. In the table of contents for the storage account, select Networking.

At the top of the page, select the Enabled from selected virtual networks and IP addresses radio button. This will un-hide a number of settings for controlling the restriction of the public endpoint. Select +Add existing virtual network to select the specific virtual network that should be allowed to access the storage account via the public endpoint. Select a virtual network and a subnet for that virtual network, and then select Enable.

Select Allow Azure services on the trusted services list to access this storage account to allow trusted first party Microsoft services such as Azure File Sync to access the storage account.

Screenshot of the Networking blade with a specific virtual network allowed to access the storage account via the public endpoint.

For file shares created with the Microsoft.FileShares resource provider:

Navigate to the file share for which you would like to restrict public access. In the service menu, under Settings, select Configuration. Under Public network access, select Enabled from selected virtual networks, then add the virtual networks and subnets allowed to access the share, and select Save.

See also