Back

Azure Files API Essential Guide

Aug 7, 20246 minute read

What type of API does Azure Files provide?

Azure Files provides a REST API for interacting with file shares and files programmatically. The key points about the Azure Files API are:

Type of API

  • Azure Files uses a REST API, often referred to as the FileREST API.

Key Features

  • The FileREST API allows you to create HTTPS requests against FileREST HTTPS endpoints.
  • It enables access to Azure Files features that are not available over SMB or NFS protocols.
  • The API can perform certain operations, like copy, more efficiently than SMB or NFS.

Use Cases

  • The stateless nature of HTTPS makes the FileREST API useful for cloud services or applications that need to access many Azure file shares.
  • It's commonly used for value-added services or applications, such as antivirus, backup, data management, or replication products.
  • Azure File Sync and Azure Backup are notable Microsoft services that extensively use the FileREST API.

API Structure

  • The API models two important objects in the file system space: files and directories.
  • It provides operations on Azure Files, file shares, directories, and files.

Authentication and Authorization

  • The control plane operations exposed through Azure Resource Manager use Microsoft Entra ID for authentication and authorization.
  • This allows management of Azure Files using role-based access control (RBAC).

Best Practices

  • For most management operations, it's recommended to use the storage resource provider APIs through Azure Resource Manager.
  • However, for high-scale operations (e.g., creating or modifying thousands of file shares within the same storage account), using the FileREST data plane management APIs may provide better performance.

SDK Support

  • Microsoft provides Azure SDKs that use the FileREST API, offering idiomatic language wrappers for popular languages like C#, Java, Python, JavaScript, and Go.

Does the Azure Files API have webhooks?

Based on the search results provided, it appears that the official Azure Files API does not have built-in webhook functionality. The search results primarily discuss webhooks in the context of Azure Event Grid, which is a separate service for event routing and delivery.

Azure Files API and Webhooks

  1. There is no direct mention of webhooks for the Azure Files API in the search results.

  2. The search results focus on Azure Event Grid, which is a service that can be used to handle events from various Azure services.

Azure Event Grid and Webhooks

While not directly related to Azure Files, Azure Event Grid does support webhooks:

  1. Azure Event Grid allows you to receive events via webhooks.

  2. When using webhooks with Event Grid, you need to prove ownership of your webhook endpoint before it starts delivering events.

  3. Event Grid supports two ways of validating webhook subscriptions:

    • Synchronous handshake
    • Asynchronous handshake
  4. For webhook event delivery, you must return an HTTP 200 OK response status code within 30 seconds.

Event Types for Event Grid

While not specific to Azure Files, Event Grid supports various event types:

  1. The search results mention "git.push" as an example event type for Azure DevOps.

  2. Event Grid supports multiple event types, but you cannot create a single webhook subscription that listens to all event types.

  3. To receive multiple event types, you would need to create separate webhook subscriptions for each event type.

In conclusion, while Azure Event Grid supports webhooks for event delivery from various Azure services, there is no specific mention of webhook support for the Azure Files API in the provided search results. If you need event-driven functionality with Azure Files, you might need to explore other options or integrate with Azure Event Grid separately.

Rate Limits and other limitations

Based on the search results provided, here are the key points regarding API rate limits for Azure Files:

Azure Storage Resource Provider Limits

For management operations using Azure Resource Manager with Azure Storage, the following limits apply per region:

  • Storage account management operations (read): 800 per 5 minutes
  • Storage account management operations (write): 10 per second / 1200 per hour
  • Storage account management operations (list): 100 per 5 minutes

Azure Files Scale Targets

For individual files stored in Azure file shares:

  • Maximum concurrent request rate:

    • Standard file shares: 1,000 IOPS
    • Premium file shares: Up to 8,000 IOPS
  • Maximum ingress for a file:

    • Standard file shares: 60 MiB/sec
    • Premium file shares: 200 MiB/sec (Up to 1 GiB/s with SMB Multichannel)
  • Maximum egress for a file:

    • Standard file shares: 60 MiB/sec
    • Premium file shares: 300 MiB/sec (Up to 1 GiB/s with SMB Multichannel)

Azure File Share Scale Targets

At the file share level:

  • Maximum request rate (Max IOPS):

    • Standard file shares: 20,000 (1,000 or 100 requests per 100 ms, default)
    • Premium file shares: Baseline IOPS: 3000 + 1 IOPS per GiB, up to 102,400; IOPS bursting: Max (10,000, 3x IOPS per GiB), up to 102,400
  • Throughput (ingress + egress) for a single file share:

    • Standard file shares: Up to storage account limits (Up to 60 MiB/sec, default)
    • Premium file shares: 100 + CEILING(0.04 * ProvisionedStorageGiB) + CEILING(0.06 * ProvisionedStorageGiB)

Storage REST API Limits

For Storage REST API operations:

  • Standard storage account: 20,000 requests/second

It's important to note that these limits may vary depending on the specific Azure Files service tier and configuration. Additionally, exceeding these limits may result in throttling of requests by the Azure Storage Service.

Latest API Version

Based on the search results provided, here are the key points regarding the most recent version of the Azure Files API:

Current Version

The most recent version of the Azure Files API is 2024-11-04 [2]. This is the current version of the Azure storage services, including Azure Files.

Key Features of the Latest Version

The 2024-11-04 service version includes the following features [2]:

  • Support for token-based authentication for all data plane APIs in the files service.
  • Support for paid bursting on premium file share accounts. This feature can be enabled with the Create Share and Set Share Properties APIs.
  • Support for the binary format when getting and setting file permissions in the files service.

API Types

Azure Files provides two types of APIs [1]:

  1. Control plane API: This is part of the Microsoft.Storage resource provider and is recommended for most management operations.

  2. Data plane API (FileREST API): This is used for direct operations on files and directories.

Recent Developments

  • Azure Files management is now available through the control plane, enabling better management capabilities and RBAC support [4].
  • Azure Active Directory support for Azure Files REST API with OAuth authentication is now generally available [4].
  • A new SLA of 99.99% uptime for Azure Files Premium Tier is generally available [4].
  • Snapshot support for NFS Azure premium file shares is generally available [4].

Best Practices

  • It's recommended to use the latest version (2024-11-04) where possible [2].
  • For management operations, it's generally recommended to use the control plane APIs rather than the data plane APIs [4].
  • When using shared access signatures (SAS), make sure to specify the correct version in the SignedVersion (sv) parameter [2].

Summary

The Azure Files API is regularly updated, with the most recent version being 2024-11-04. This version includes improvements in authentication, performance, and functionality. When working with Azure Files, it's important to use the appropriate API (control plane or data plane) depending on the operation, and to stay updated with the latest versions and features.

How to get a Azure Files developer account and API Keys?

To get a developer account for Azure Files and create an API integration, you'll need to follow these steps:

1. Create an Azure Account

First, you need to create an Azure account if you don't already have one. You can sign up for a free account at https://azure.microsoft.com/.

2. Set up an API Management instance

To create an API integration, you'll need an API Management service instance. If you don't have one:

  1. Go to the Azure portal (https://portal.azure.com/).
  2. Create a new API Management service instance.
  3. Follow the "Quickstart - Create an Azure API Management instance" guide for detailed steps.

3. Create a Storage Account

You'll need an Azure storage account with the static websites feature enabled:

  1. In the Azure portal, create a new storage account.
  2. Enable the static websites feature for this account.
  3. Follow the "Create a storage account" guide for detailed instructions.

4. Set up your local development environment

To work with Azure Files and create an API integration, you'll need to set up your local environment:

  1. Install Git on your machine.
  2. Install Node.js (LTS version, v10.15.0 or later) and npm.
  3. Install Azure CLI by following the Azure CLI installation steps.

5. Clone the API Management Developer Portal repository

To get started with API integration:

  1. Clone the api-management-developer-portal repo:
    git clone https://github.com/Azure/api-management-developer-portal.git
    
  2. Navigate to the cloned repository:
    cd api-management-developer-portal
    
  3. Check out the latest release of the portal.

6. Configure JSON files

You'll need to configure several JSON files for your API integration:

  1. Edit config.design.json, config.publish.json, and config.runtime.json in the src folder.
  2. Replace placeholders with your API Management instance details.
  3. Generate and add a SAS token for direct REST API access to your API Management instance.

7. Configure CORS settings

Configure CORS settings for the developer portal backend to allow requests from your self-hosted developer portal.

8. Authorize access to file data

To access Azure Files using OAuth over REST:

  1. Use the Azure Identity client library to simplify getting an OAuth 2.0 access token.
  2. Use the token credential to create a service client object for performing authorized operations against the Azure Files service.

What can you do with the Azure Files API?

Based on the search results, here are the key data models you can interact with using the Azure Files API:

File System Objects

  • Files

    • Perform operations on individual files
    • Read, write, delete, copy files
    • Set metadata on files
  • Directories

    • Perform operations on directories
    • Create, delete, list directories
    • Set metadata on directories

File Shares

  • Create and manage file shares
  • Set properties and metadata on shares
  • Create snapshots of shares
  • List contents of shares

File Service

  • Manage settings that apply to all file shares in a storage account
  • Only one File Service resource per storage account, named "default"

Key Points:

  • The API provides a hierarchical file system model with files and directories
  • You can interact with individual files, directories, and entire file shares
  • Operations are available for both data plane (file content) and control plane (management)
  • The File Service resource allows configuring account-wide settings

Best Practices:

  • Use control plane APIs via Azure Resource Manager when possible for better authentication and authorization
  • Use data plane APIs directly for high-scale operations like creating many shares
  • Consider performance and scalability limits when working with large numbers of shares in a single account

Summary:

The Azure Files API allows you to programmatically interact with files, directories, shares, and account-level settings using a REST interface. It provides both data access and management capabilities for Azure file storage.