Skip to content

File Share Storage

This guide explains how to enable and integrate Azure Storage file shares with API services using the Forge platform.

Experimental Feature

File Share Storage support is experimental and newly added to the Forge platform. Behavior, defaults, and documentation may change without notice — validate carefully in a non-production environment before relying on it, and report issues you find.

đŸŽ¯ Overview

Azure Storage file shares provide fully managed, SMB/REST-accessible file storage on the same storage account used by Blob Storage. The Forge platform provides:

  • Terraform Module: Automated Azure Storage file share provisioning, scoped to a single app's storage account
  • RBAC Authentication: Secure, token-based access via the app's Entra identity over REST (no keys, no SAS tokens, no SMB mount)
  • Feature Flag: Independent enable/disable configuration, separate from blob/queue

🔧 Infrastructure Setup (Terraform)

Prerequisites

enable_storage_file and storage_file_settings are members of the feature_flags object, which uses optional(...) attributes and therefore requires Terraform >= 1.3.0 — the same floor this change raises saif-api-service to. See the Terraform version compatibility table if you're on an older Terraform version.

Enable File Share Storage Feature Flag

Storage file is a feature flag on the saif-apiservice module, so it is configured in the module call that the templates generate for you — infra/api/app.generated.tf.

Add a feature_flags block to the existing module "saif-appservices" call:

feature_flags = {
  enable_storage_file = true
  storage_file_settings = {
    file_shares          = [{ name = "shared-config", quota_gb = 50 }]
    contributor_group_id = "group-object-id-guid"
  }
}

âš ī¸ enable_storage_file and storage_file_settings are members of the feature_flags object — they are not top-level module arguments. If the module call already has a feature_flags block (for example from Cosmos DB or Blob Storage), add these members to the existing object instead of adding a second feature_flags = { ... } block — Terraform rejects a duplicate.

Configuration Options:

Property Type Description
enable_storage_file bool Enable/disable file share provisioning
storage_file_settings.file_shares list(object({ name, quota_gb })) File shares to create; quota_gb defaults to 100
storage_file_settings.contributor_group_id string Entra ID group object ID granted Storage File Data Privileged Contributor ("" = app identity only)

Terraform validates file_shares at plan time, so invalid entries fail before any Azure call. Each share name must be 3-63 characters long, use only lowercase letters, digits, and hyphens, start and end with a letter or digit, and contain no consecutive hyphens. Share names must be unique within the list. Each quota_gb must be a whole number of GiB between 1 and 5120 (5 TiB).

âš ī¸ Hardcode the object ID — don't resolve it with a data source. Terraform plans that look up the group at plan time fail the Organization Policy Check. Look up your team's Entra ID group object ID once (Entra admin center or az ad group show --group "<display name>" --query id -o tsv) and paste the literal GUID into storage_file_settings. This matches the pattern used by blob_storage_settings.contributor_group_id — see Blob Storage.

Generated Resources

When enable_storage_file = true, the following resources are automatically created:

  • 📁 File Shares — one azurerm_storage_share per entry in file_shares, sized by quota_gb, on the app's storage account (shared with blob/queue if those are also enabled)
  • 🔐 RBAC — Storage File Data Privileged Contributor assigned to the application's Entra app registration service principal (the runtime data-plane identity) and to the group in storage_file_settings.contributor_group_id. This is the only built-in file-share role that authorizes OAuth/Entra ID REST calls — the SMB Share roles only cover SMB-mounted access, which Forge apps don't use.
  • âš™ī¸ App Setting: ConnectionStrings__storagefile is added to the web app with the primary file endpoint of the storage account
  • 🔌 Private Endpoint — file sub-resource in the services subnet, registered in the privatelink.file.core.windows.net DNS zone

App Configuration can shadow this app setting

AddAzureDefaults() registers the Azure App Configuration provider after the App Service environment-variable provider, and the last provider registered wins, so a ConnectionStrings:storagefile key published centrally to App Configuration silently overrides the ConnectionStrings__storagefile app setting emitted here. See Feature Flags for the full ordering rules.

Network isolation follows the same deny-by-default firewall + private endpoint model as blob storage — see Network Isolation; the same corporate/colocation IP allowances and VPN caveat apply here.

Outputs

The module exposes storage_file_share_names, a list of strings with the names of the file shares it created (from storage_file_settings.file_shares). The value is null when feature_flags.enable_storage_file is false, so guard against null in consumers. For example, from the project's root Terraform:

output "file_share_names" {
  value = module.saif-appservices.storage_file_share_names
}

locals {
  file_share_names = coalesce(module.saif-appservices.storage_file_share_names, [])
}

See Blob Storage for the related queue output.

💰 Cost, Quota, and Operational Trade-offs

  • Cost: File shares are billed by provisioned quota (quota_gb), not actual usage — right-size the quota rather than over-provisioning by default.
  • Access model: Forge apps access shares over REST via the Azure SDK using DefaultAzureCredential, not by mounting the share over SMB — no VNet-joined client or SMB port (445) access is required.
  • Quota range: this module validates quota_gb as a whole number of GiB between 1 and 5120 (up to 5 TiB) per share; resize by updating quota_gb and reapplying Terraform.

đŸ–Ĩī¸ Using the SDK

File share access uses DefaultAzureCredential — no connection strings, no shared keys. The generated app setting is an endpoint URL, not a full connection string, matching the blob storage pattern:

Aspire has no file share client integration, so register the Azure SDK client directly.

using Azure.Identity;
using Azure.Storage.Files.Shares;
using Azure.Storage.Files.Shares.Models;

builder.Services.AddSingleton(sp =>
    new ShareServiceClient(
        new Uri(builder.Configuration["ConnectionStrings:storagefile"]!),
        new DefaultAzureCredential(),
        new ShareClientOptions { ShareTokenIntent = ShareTokenIntent.Backup }));
using Azure.Storage.Files.Shares;

app.MapGet("/api/config/{fileName}", async (string fileName, ShareServiceClient shareServiceClient) =>
{
    var shareClient = shareServiceClient.GetShareClient("shared-config");
    var fileClient = shareClient.GetRootDirectoryClient().GetFileClient(fileName);

    if (!await fileClient.ExistsAsync())
    {
        return Results.NotFound();
    }

    var download = await fileClient.DownloadAsync();
    return Results.Stream(download.Value.Content, "application/octet-stream");
});

â„šī¸ In Azure, the platform pins the credential chain to the app registration service principal (AZURE_TOKEN_CREDENTIALS=environmentcredential), which holds the Storage File Data Privileged Contributor role granted above — the same pattern used by blob storage.

❓ FAQ

Q: How do I add more file shares after initial deployment?

A: Update the file_shares list in storage_file_settings and reapply Terraform.

Q: Why is the file share role "Storage File Data Privileged Contributor" instead of an SMB role?

A: Forge apps access file shares over REST via the Azure SDK, not by mounting the share over SMB. The SMB Share Contributor/Reader roles only authorize SMB-mounted access; Privileged Contributor is the built-in role that authorizes OAuth/Entra ID REST calls from the SDK.

Q: Can I enable file share alongside blob and queue?

A: Yes — blob, queue, and file share are independent feature flags and share the same storage account when enabled together on the same app. Table storage is not currently supported — see the Table Storage status page for details.