Skip to content

feat(storage): add native Azure Blob transport - #2871

Merged
Mythie merged 2 commits into
documenso:mainfrom
kengru-digito:feat/doc-2870-azure-blob-transport
May 27, 2026
Merged

Mythie merged 2 commits into
documenso:mainfrom
kengru-digito:feat/doc-2870-azure-blob-transport

Conversation

@kengru-digito

Copy link
Copy Markdown
Contributor

Description

Adds native Azure Blob Storage as a third document storage transport, selectable via NEXT_PUBLIC_UPLOAD_TRANSPORT=azure-blob. Existing database and s3 transports preserve their current behavior.

Azure Blob does not expose an S3-compatible API: the existing s3 transport pointed at an Azure endpoint does not work because of different required headers, signed-URL scheme (SAS), and authentication. Self-hosters on Azure today have to run an S3-to-Blob gateway, host MinIO themselves, or stay on the database transport. This PR closes that gap.

The storage layer is refactored to a small StorageProvider interface. Existing S3 logic moves behind an S3Provider implementing the interface. A new AzureBlobProvider uses the official @azure/storage-blob SDK. A factory in providers/index.ts selects the provider at runtime based on the transport env var. The public API of server-actions.ts is preserved; callers do not change.

Authentication uses the Azure Storage Account access key, mirroring how the s3 transport keeps credentials in env vars. Managed Identity with user delegation SAS is a natural follow-up over the same provider and is intentionally out of scope here.

Related Issue

Fixes #2870.

Changes Made

  • New StorageProvider interface and S3Provider implementation. Existing S3 logic moved behind the interface, no behavior change.
  • New AzureBlobProvider implementation using @azure/storage-blob.
  • New provider factory selecting by NEXT_PUBLIC_UPLOAD_TRANSPORT (s3 or azure-blob).
  • server-actions.ts delegates its five exported functions to the active provider.
  • Client: put-file.ts sends the x-ms-blob-type: BlockBlob header on the browser PUT when the transport is azure-blob; the s3 path is unchanged.
  • Server: put-file.server.ts adds an azure-blob case that goes through the same object-storage path as s3.
  • Types: NEXT_PUBLIC_UPLOAD_TRANSPORT includes azure-blob in process-env.d.ts. New optional env vars: NEXT_PRIVATE_UPLOAD_AZURE_ACCOUNT_NAME, NEXT_PRIVATE_UPLOAD_AZURE_ACCOUNT_KEY, NEXT_PRIVATE_UPLOAD_AZURE_CONTAINER, NEXT_PRIVATE_UPLOAD_AZURE_ENDPOINT (optional, for Azurite or custom endpoints).
  • Docs: apps/docs/content/docs/self-hosting/configuration/storage.mdx documents the new transport and the Azurite local development workflow.
  • Dependency: @azure/storage-blob added to packages/lib.

DocumentDataType.S3_PATH is reused for blobs stored in Azure (semantically "object storage key"), avoiding a Prisma migration.

Testing Performed

Verified end-to-end against Azurite locally:

  • Document upload via the UI (covers getPresignPostUrl and the browser PUT with x-ms-blob-type: BlockBlob).
  • Document preview via the UI (covers getPresignGetUrl).
  • Full document signing flow including the server-side PDF seal upload (covers uploadFile).
  • Two non-UI operations (getAbsolutePresignPostUrl, deleteFile) verified via a standalone script that mirrors the provider logic and confirms blobs are created, overwritten via SAS PUT, and deleted in Azurite.

S3 transport regression-checked by running the same operations through the refactored abstraction. Build (npm run build) passes locally.

Checklist

  • I have tested these changes locally and they work as expected.
  • I have added/updated tests that prove the effectiveness of these changes.
  • I have updated the documentation to reflect these changes, if applicable.
  • I have followed the project's coding style guidelines.
  • I have addressed the code review feedback from the previous submission, if applicable.

Additional Notes

Direction coordinated with the Documenso team via Slack before opening; the team confirmed interest in this contribution and asked to open an issue (#2870) and self-claim it, which is the path followed here.

Tests for the new transport were not added in this PR, following the convention used by the existing S3 path, which is similarly untested. Happy to add E2E coverage if desired.

Future work, out of scope for this PR:

  • Managed Identity with user delegation SAS as an alternative auth scheme for the same provider (no secret in env vars; first-class cloud-native option for Azure App Service deployments).
  • The orphan-blob situation that exists for the s3 path today (UI document delete drops the DB row but does not call deleteFile on the storage backend). The same observation applies to azure-blob as introduced here. Worth tracking separately.

@coderabbitai

coderabbitai Bot commented May 27, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are limited based on label configuration.

🏷️ Required labels (at least one) (1)
  • coderabbit

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: d39d24de-2b42-4499-9a18-1ab320cb0a83

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@vercel

vercel Bot commented May 27, 2026

Copy link
Copy Markdown

@kengru-digito is attempting to deploy a commit to the Documenso Team Team on Vercel.

A member of the Team first needs to authorize it.

@vercel

vercel Bot commented May 27, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
prd-openpage-api Ignored Ignored May 27, 2026 3:13am

Request Review

@kengru-digito
kengru-digito force-pushed the feat/doc-2870-azure-blob-transport branch from dd1aa2a to 19e7a54 Compare May 27, 2026 03:13
@kengru-digito
kengru-digito marked this pull request as ready for review May 27, 2026 03:13
@Mythie
Mythie merged commit 9da2db2 into documenso:main May 27, 2026
9 of 10 checks passed
scoobs-mystery-bytes pushed a commit to scoobs-mystery-bytes/documenso that referenced this pull request May 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add azure-blob as a native document storage transport

2 participants