Loading components
convex-azure-blob enables direct browser-to-Azure Blob Storage uploads via signed URLs, with reactive metadata stored in Convex and no Azure SDK required.
npm install convex-azure-blobconvex-azure-blob integrates Azure Blob Storage with Convex by handling signed URL generation, metadata synchronization, and direct browser uploads without routing file data through your backend. Files are uploaded via short-lived SAS URLs using a PUT request, and blob metadata (size, content type, ETag, last modified) is stored in a Convex table for reactive querying. Read URLs are signed locally inside queries with no network call to Azure, keeping latency low and enabling stable browser caching.
convex-azure-blob provides a useUploadFile React hook that handles the full upload flow: it fetches a signed URL from Convex, PUTs the file directly to Azure, then calls syncMetadata to record the blob in Convex. You export generateUploadUrl, syncMetadata, and related functions from your convex/files.ts using azureBlob.clientApi, which lets you attach auth checks and post-upload logic.
convex-azure-blob provides azureBlob.getUrl(key), which signs a read-only URL using the account key locally with no network request, so it can be called directly inside a Convex query. URLs default to one hour expiry and are rounded to expiry-window boundaries so the same URL is returned on repeated query runs, allowing browsers to cache the file.
In a Convex action, call azureBlob.store(ctx, blob) to upload a Blob or buffer directly to Azure without a browser. You can optionally pass a custom key and content type. Note that store holds the entire file in memory, so it is subject to Convex action memory limits.
Call azureBlob.deleteObject(ctx, key) from a Convex action to delete the blob from Azure and remove its metadata from Convex in one operation. The call succeeds even if the blob no longer exists in Azure.
No. convex-azure-blob does not use the Azure SDK and runs entirely in the default Convex runtime. It communicates with Azure Blob Storage directly via the REST API using HMAC-signed requests, which avoids large dependency bundles and SDK compatibility issues.
Signed upload URLs cannot restrict file size or content type at the Azure level. Instead, use the onUpload callback in azureBlob.clientApi to check blob.size and blob.contentType after the upload completes. To reject an upload, delete the blob with azureBlob.deleteObject and throw an error from within onUpload.
convex-azure-blob requires three Convex environment variables: AZURE_STORAGE_ACCOUNT (account name), AZURE_STORAGE_ACCOUNT_KEY (an account access key), and AZURE_STORAGE_CONTAINER (container name). Microsoft Entra ID and managed identities are not currently supported. Because the account key grants full storage account access, the README recommends using a dedicated storage account for the app.
In the Azure portal under Settings, navigate to Resource sharing (CORS) for the Blob service and add a rule with your app's origin, PUT as the allowed method, x-ms-blob-type and content-type as allowed headers, and a max age of 3600. You can also use the Azure CLI with az storage cors add. Without this rule, browser PUT requests to Azure will be blocked.
Yes. Create one AzureBlob instance per container, passing different accountName, accountKey, and containerName options to the constructor. Each instance manages its own metadata table and signed URL generation independently.