Azure Storage Files Reference

Overview

The Azure File storage service offers fully managed file shares in the cloud that are accessible via the SMB protocol. This reference provides details on the REST API, SDK methods, and best practices for working with files and directories.

Authentication & Authorization

All requests to the File service must be authorized. Azure supports Shared Key authentication, Shared Access Signatures (SAS), and Azure AD integration.

Authorization: SharedKey <accountName>:<signature>
Authorization: SharedAccessSignature <sv>=<version>...

Operations

OperationHTTP MethodURIPurpose
Create SharePUT/<shareName>Create a new file share
Delete ShareDELETE/<shareName>Delete an existing share
Create DirectoryPUT/<shareName>/<directoryPath>Create a directory inside a share
Delete DirectoryDELETE/<shareName>/<directoryPath>Delete a directory
Create FilePUT/<shareName>/<directoryPath>/<fileName>Create an empty file
Upload RangePUT/<shareName>/<directoryPath>/<fileName>?comp=rangeUpload data to a file range
Download RangeGET/<shareName>/<directoryPath>/<fileName>?comp=rangeDownload a file range
Set File PropertiesPUT/<shareName>/<directoryPath>/<fileName>?comp=propertiesSet file metadata, attributes
Get File PropertiesGET/<shareName>/<directoryPath>/<fileName>?comp=metadataRetrieve file properties
List Files & DirectoriesGET/<shareName>/<directoryPath>?restype=directory&comp=listList contents of a directory
Code Samples

Creating a File Share (C#)

using Azure.Storage.Files.Shares;
var serviceClient = new ShareServiceClient("");
var shareClient = serviceClient.GetShareClient("myshare");
await shareClient.CreateIfNotExistsAsync();

Uploading a File (Python)

from azure.storage.fileshare import ShareFileClient
file_client = ShareFileClient.from_connection_string(
    conn_str="",
    share_name="myshare",
    file_path="docs/readme.txt")
with open("readme.txt","rb") as data:
    file_client.upload_file(data)

Downloading a Range (REST)

GET https://myaccount.file.core.windows.net/myshare/docs/readme.txt?comp=range&range=bytes=0-1023 HTTP/1.1
Authorization: SharedKey myaccount:<signature>
x-ms-version: 2023-09-01

Best Practices

  • Use SAS tokens for limited-time, scoped access.
  • Leverage parallelism when uploading large files (multiple range PUTs).
  • Enable SMB encryption for on-premises access.
  • Monitor with Azure Monitor metrics: FileShareCapacity, FileShareTransactions.