Azure Docs

Azure Files File Service REST API

The Azure Files service provides a REST API for managing file shares and their contents. This API allows you to programmatically interact with Azure Files from any client that can send an HTTP request.

The Azure Files REST API supports the following operations:

Share Operations

  • Create Share: Creates a new file share.
  • Get Share Properties: Retrieves properties for a specified file share.
  • List Shares: Lists all file shares associated with the storage account.
  • Delete Share: Deletes a specified file share.
  • Set Share Properties: Sets properties for a specified file share.

Directory Operations

  • Create Directory: Creates a new directory within a file share.
  • Get Directory Properties: Retrieves properties for a specified directory.
  • List Directories and Files: Lists the directories and files within a specified directory.
  • Delete Directory: Deletes a specified directory.
  • Rename Directory: Renames a specified directory.

File Operations

  • Create File: Creates a new file or overwrites an existing file.
  • Get File: Retrieves a file or its properties.
  • Get File Properties: Retrieves properties for a specified file.
  • List Files: Lists the files within a specified directory.
  • Delete File: Deletes a specified file.
  • Update File: Uploads a range of bytes to a file.
  • Rename File: Renames a specified file.
  • Acquire Lease: Acquires a lease on a file.
  • Release Lease: Releases the lease on a file.
  • Break Lease: Breaks an existing lease on a file.

Authentication

All requests to the Azure Files REST API must be authenticated. You can authenticate using:

  • Shared Key Authentication: Using the storage account name and account key.
  • Shared Access Signature (SAS): A token that grants delegated access to Azure Files resources.
  • Azure Active Directory (Azure AD): For enhanced security and identity management.

Request and Response Headers

Common headers include:

  • x-ms-version: Specifies the version of the REST API to use.
  • Authorization: Contains the authentication credentials.
  • Content-Type: The MIME type of the request body.
  • Accept: The MIME type the client expects in the response.

Example: List Shares

To list all shares in a storage account using shared key authentication, you would send a GET request to the following URI:

GET https://myaccount.file.core.windows.net/?comp=list&restype=account
            Authorization: SharedKey myaccount:mykey
            x-ms-version: 2019-02-02
            Date: Mon, 26 Jan 2024 22:51:30 GMT

A successful response would return an XML document listing the shares.

Note: For detailed information on request parameters, response formats, and specific error codes, please refer to the official Azure Files REST API Reference.

Security Alert: Never embed your account keys directly in client-side code. Use managed identities or Azure AD authentication for production applications.