Azure Storage Files Shares Change Feed client library for .NET - version 12.0.0-beta.2

Server Version: 2026-02-06

Azure Files Change Feed tracks data and metadata operations in an Azure file share and writes them to an append-only, immutable log. The change feed enables you to determine what changed over time, build efficient incremental backup solutions, and react to file share mutations in near real-time.

Change feed is enabled per file share and records operations performed via both SMB and REST protocols, including creates, renames, deletes, writes, metadata updates, and security descriptor changes.

Source code

Getting started

Install the package

Install the Azure Storage Files Shares Change Feed client library for .NET with NuGet:

dotnet add package Azure.Storage.Files.Shares.ChangeFeed --prerelease

Prerequisites

You need an Azure subscription and a Storage Account with an Azure File Share that has change feed enabled.

To create a new Storage Account, you can use the Azure Portal, Azure PowerShell, or the Azure CLI. Here's an example using the Azure CLI:

az storage account create --name MyStorageAccount --resource-group MyResourceGroup --location westus --sku Standard_LRS

Change feed must be enabled on the file share by setting the x-ms-file-enable-change-feed: true header when creating or updating the share (requires API version 2026-02-06 or later).

Authenticate the Client

// Using a connection string
ShareChangeFeedClient changeFeedClient = new ShareChangeFeedClient(
    connectionString,
    "myfileshare");

// Using a shared key credential
ShareChangeFeedClient changeFeedClient = new ShareChangeFeedClient(
    new Uri("https://myaccount.file.core.windows.net"),
    "myfileshare",
    new StorageSharedKeyCredential(accountName, accountKey));

// Using the extension method on ShareClient
ShareServiceClient serviceClient = new ShareServiceClient(connectionString);
ShareClient shareClient = serviceClient.GetShareClient("myfileshare");
ShareChangeFeedClient changeFeedClient = shareClient.GetShareChangeFeedClient();

Key concepts

The change feed is stored as blobs in a hidden container in the same storage account as the file share. Each share that has change feed enabled gets its own container (named $fileschangefeed-<GUID>). Events are recorded in Apache Avro format and organized into 15-minute time-windowed segments.

Each ShareChangeFeedEvent contains:

  • Reason - The operation type (e.g., SmbCreate, RestDelete, SmbWrite)
  • Protocol - The protocol used (SMB or REST)
  • EventTime - When the event occurred
  • EventData - File-specific details including FileId, FileName, FullFilePath, and Identity
  • ContainerVersionNumber - Used for filtering events between snapshots

Thread safety

We guarantee that all client instance methods are thread-safe and independent of each other (guideline). This ensures that the recommendation of reusing client instances is always safe, even across threads.

Additional concepts

Client options | Accessing the response | Handling failures | Diagnostics | Mocking | Client lifetime

Examples

Get all events in the change feed

List<ShareChangeFeedEvent> events = new List<ShareChangeFeedEvent>();
await foreach (ShareChangeFeedEvent changeFeedEvent in changeFeedClient.GetChangesAsync())
{
    events.Add(changeFeedEvent);
}

Get events between a start and end time

// Events are filtered by timestamp within the specified range.
DateTimeOffset startTime = new DateTimeOffset(2024, 1, 15, 8, 0, 0, TimeSpan.Zero);
DateTimeOffset endTime = new DateTimeOffset(2024, 1, 15, 12, 0, 0, TimeSpan.Zero);

await foreach (ShareChangeFeedEvent changeFeedEvent in changeFeedClient.GetChangesAsync(
    start: startTime,
    end: endTime))
{
    events.Add(changeFeedEvent);
}

Resume with continuationToken

string continuationToken = null;
await foreach (Page<ShareChangeFeedEvent> page in changeFeedClient.GetChangesAsync().AsPages(pageSizeHint: 10))
{
    foreach (ShareChangeFeedEvent changeFeedEvent in page.Values)
    {
        events.Add(changeFeedEvent);
    }

    // Save the continuation token to resume later.
    continuationToken = page.ContinuationToken;
    break;
}

// Resume iterating from the previous position.
await foreach (ShareChangeFeedEvent changeFeedEvent in changeFeedClient.GetChangesAsync(
    continuationToken: continuationToken))
{
    events.Add(changeFeedEvent);
}

Get changes between two snapshots

// Query events that occurred between two file share snapshots, filtered by container version ID.
await foreach (ShareChangeFeedEvent changeFeedEvent in changeFeedClient.GetChangesBetweenSnapshotsAsync(
    beginSnapshot: "2024-01-15T08:00:00.000Z",
    endSnapshot: "2024-01-15T12:00:00.000Z"))
{
    events.Add(changeFeedEvent);
}

Check whether a snapshot is recorded and finalized

// Before calling GetChangesBetweenSnapshots, verify that the change feed has
// recorded and finalized the snapshot you intend to use as an endpoint.
ShareChangeFeedSnapshotStatus status = await changeFeedClient.GetSnapshotStatusAsync(
    "2024-01-15T12:00:00.000Z");

switch (status)
{
    case ShareChangeFeedSnapshotStatus.Finalized:
        // Safe to use as a begin/end snapshot for GetChangesBetweenSnapshots.
        break;
    case ShareChangeFeedSnapshotStatus.Pending:
        // Metadata exists but the snapshot has not been finalized yet; try again later.
        break;
    case ShareChangeFeedSnapshotStatus.NotFound:
        // No metadata was published for this timestamp.
        break;
}

Troubleshooting

All Azure Storage service operations will throw a RequestFailedException on failure with helpful ErrorCodes. Many of these errors are recoverable.

Common issues:

  • Change Feed not enabled: Ensure x-ms-file-enable-change-feed: true was set when creating or updating the share.
  • Container not found: The change feed container is created asynchronously after enabling. Allow a few minutes for it to appear.

Next steps

For more information about Azure Files Change Feed, see the [product documentation][product_docs].

Contributing

See the Storage CONTRIBUTING.md for details on building, testing, and contributing to this library.

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit cla.microsoft.com.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.