Repository navigation
feat(storage): add native Azure Blob transport - #2871
Conversation
|
Important Review skippedAuto reviews are limited based on label configuration. 🏷️ Required labels (at least one) (1)
Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: ASSERTIVE Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
|
@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. |
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
dd1aa2a to
19e7a54
Compare
Description
Adds native Azure Blob Storage as a third document storage transport, selectable via
NEXT_PUBLIC_UPLOAD_TRANSPORT=azure-blob. Existingdatabaseands3transports preserve their current behavior.Azure Blob does not expose an S3-compatible API: the existing
s3transport 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 thedatabasetransport. This PR closes that gap.The storage layer is refactored to a small
StorageProviderinterface. Existing S3 logic moves behind anS3Providerimplementing the interface. A newAzureBlobProvideruses the official@azure/storage-blobSDK. A factory inproviders/index.tsselects the provider at runtime based on the transport env var. The public API ofserver-actions.tsis preserved; callers do not change.Authentication uses the Azure Storage Account access key, mirroring how the
s3transport 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
StorageProviderinterface andS3Providerimplementation. Existing S3 logic moved behind the interface, no behavior change.AzureBlobProviderimplementation using@azure/storage-blob.NEXT_PUBLIC_UPLOAD_TRANSPORT(s3orazure-blob).server-actions.tsdelegates its five exported functions to the active provider.put-file.tssends thex-ms-blob-type: BlockBlobheader on the browser PUT when the transport isazure-blob; thes3path is unchanged.put-file.server.tsadds anazure-blobcase that goes through the same object-storage path ass3.NEXT_PUBLIC_UPLOAD_TRANSPORTincludesazure-blobinprocess-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).apps/docs/content/docs/self-hosting/configuration/storage.mdxdocuments the new transport and the Azurite local development workflow.@azure/storage-blobadded topackages/lib.DocumentDataType.S3_PATHis reused for blobs stored in Azure (semantically "object storage key"), avoiding a Prisma migration.Testing Performed
Verified end-to-end against Azurite locally:
getPresignPostUrland the browser PUT withx-ms-blob-type: BlockBlob).getPresignGetUrl).uploadFile).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
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:
s3path today (UI document delete drops the DB row but does not calldeleteFileon the storage backend). The same observation applies toazure-blobas introduced here. Worth tracking separately.