Skip to content
← Engineering handbook

Cloud & DevOps · Backend · Data & Caching· 8 min read

Swappable cloud storage: abstracting AWS S3 and Azure Blob with SAS tokens

Designing a unified cloud storage driver. How to seamlessly switch between AWS S3 signed URLs and Azure Blob SAS tokens without changing application business logic.

Cloud StorageAWS S3Azure BlobArchitectureSecurity

On this page

In enterprise software, client infrastructure mandates differ. Some enterprise clients require all documents to reside within their existing AWS account in the EU-West region; other corporate accounts require Azure Cloud in the UK-South region. In my e-signature and document platform (`pratul03/e-sign`), I designed an abstraction layer allowing the platform to swap between AWS S3 and Azure Blob Storage seamlessly via environment configuration.

The storage provider interface

typescript
export interface IStorageProvider {
  getSignedUploadUrl(bucket: string, key: string, expiresInSeconds: number): Promise<string>;
  getSignedDownloadUrl(bucket: string, key: string, expiresInSeconds: number): Promise<string>;
  uploadStream(bucket: string, key: string, stream: NodeJS.ReadableStream): Promise<void>;
  deleteObject(bucket: string, key: string): Promise<void>;
}
StorageProvider: common contract for multi-cloud document storage.

Whether generating a 15-minute AWS S3 presigned PUT URL or an Azure Blob Storage Shared Access Signature (SAS) token, the calling service interacts with the identical interface. Storage credentials remain locked inside cloud key vaults and are never exposed to browser clients.