@azure/storage-blob
>=12.0.0postconditions58functions22last verified2026-06-24coverage score88%Postconditions: what we check
- download · successinfoWhenblob exists and download succeedsReturnsBlobDownloadResponse with readableStreamBody and blob metadataRequired handlingNo action required — use the returned value as needed.costmediumin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[1]
- download · blob-not-founderrorWhenblob does not existThrows
RestError with statusCode 404 and x-ms-error-code: BlobNotFoundRequired handlingCaller MUST catch RestError and check error.statusCode === 404 or error.response.headers.get('x-ms-error-code') === 'BlobNotFound' to handle missing blobs.costmediumin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[2] - download · blob-archivederrorWhenblob is in archived tierThrows
RestError with statusCode 409 and errorCode: BlobArchivedRequired handlingCaller MUST catch RestError and handle archived blobs by either rehydrating the blob first or returning appropriate error to user.costmediumin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[2] - download · network-errorerrorWhennetwork failure, connection timeout, or DNS resolution failureThrows
Error with code ECONNREFUSED, ETIMEDOUT, or ENOTFOUNDRequired handlingCaller MUST catch errors and implement retry logic with exponential backoff for transient network failures.costmediumin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[3] - getProperties · successinfoWhenblob existsReturnsBlobGetPropertiesResponse with metadata, contentType, lastModified, etc.Required handlingNo action required — use the returned value as needed.costmediumin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[4]
- getProperties · blob-not-founderrorWhenblob does not existThrows
RestError with statusCode 404 and errorCode: BlobNotFoundRequired handlingCaller MUST catch RestError and check error.statusCode === 404 to handle missing blobs. Common pattern is to check existence before accessing properties.costmediumin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[2] - getProperties · container-not-founderrorWhencontainer does not existThrows
RestError with statusCode 404 and errorCode: ContainerNotFoundRequired handlingCaller MUST catch RestError and distinguish between BlobNotFound and ContainerNotFound to provide appropriate error messages.costmediumin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[2] - upload · successinfoWhenupload succeedsReturnsBlockBlobUploadResponse with requestId, version, and ETagRequired handlingNo action required — use the returned value as needed.costmediumin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[5]
- upload · blob-already-existserrorWhenblob exists and If-None-Match: * is setThrows
RestError with statusCode 409 and errorCode: BlobAlreadyExistsRequired handlingCaller MUST catch RestError and check error.statusCode === 409 to handle conflicts when blob already exists.costmediumin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[2] - upload · container-not-founderrorWhencontainer does not existThrows
RestError with statusCode 404 and errorCode: ContainerNotFoundRequired handlingCaller MUST catch RestError and either create container first or return appropriate error. Common mistake is not checking container existence.costmediumin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[2] - upload · invalid-blob-typeerrorWhenblob exists as different type (e.g., page blob)Throws
RestError with statusCode 409 and errorCode: InvalidBlobTypeRequired handlingCaller MUST catch RestError and handle type conflicts appropriately.costmediumin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[2] - upload · network-errorerrorWhennetwork failure during uploadThrows
Error with code ECONNREFUSED, ETIMEDOUT, or ENOTFOUNDRequired handlingCaller MUST catch errors and implement retry logic for transient failures.costmediumin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[3] - uploadFile · successinfoWhenfile upload succeedsReturnsBlobUploadCommonResponse with requestId, version, and ETagRequired handlingNo action required — use the returned value as needed.costmediumin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[6]
- uploadFile · container-not-founderrorWhencontainer does not existThrows
RestError with statusCode 404 and errorCode: ContainerNotFoundRequired handlingCaller MUST catch RestError and create container before uploading.costmediumin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[2] - uploadFile · network-errorerrorWhennetwork failure during multipart uploadThrows
Error with network error codeRequired handlingCaller MUST catch errors and retry failed uploads with exponential backoff.costmediumin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[3] - uploadData · successinfoWhendata upload succeedsReturnsBlobUploadCommonResponse with requestId, version, and ETagRequired handlingNo action required — use the returned value as needed.costmediumin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[7]
- uploadData · container-not-founderrorWhencontainer does not existThrows
RestError with statusCode 404 and errorCode: ContainerNotFoundRequired handlingCaller MUST catch RestError and handle missing container appropriately.costmediumin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[2] - uploadData · network-errorerrorWhennetwork failureThrows
Error with network error codeRequired handlingCaller MUST catch errors and implement retry logic.costmediumin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[3] - create · successinfoWhencontainer creation succeedsReturnsContainerCreateResponse with requestId and ETagRequired handlingNo action required — use the returned value as needed.costmediumin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[8]
- create · container-already-existserrorWhencontainer with same name already existsThrows
RestError with statusCode 409 and errorCode: ContainerAlreadyExistsRequired handlingCaller MUST catch RestError and check error.statusCode === 409 to handle existing containers. Common pattern is to check exists() first or catch and continue.costmediumin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[2] - create · container-being-deletederrorWhencontainer is currently being deletedThrows
RestError with statusCode 409 and errorCode: ContainerBeingDeletedRequired handlingCaller MUST catch RestError and wait for deletion to complete before retrying.costmediumin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[2] - create · auth-errorerrorWhenauthentication fails or insufficient permissionsThrows
RestError with statusCode 403Required handlingCaller MUST catch RestError with statusCode 403 and handle authentication/authorization failures.costmediumin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[2] - delete · successinfoWhencontainer deletion succeedsReturnsContainerDeleteResponse with requestIdRequired handlingNo action required — use the returned value as needed.costmediumin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[9]
- delete · container-not-founderrorWhencontainer does not existThrows
RestError with statusCode 404 and errorCode: ContainerNotFoundRequired handlingCaller MUST catch RestError and handle missing containers. Common pattern is to check exists() first or catch 404 and treat as success.costmediumin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[2] - delete · lease-id-missingerrorWhencontainer has active lease but lease ID not providedThrows
RestError with statusCode 412 and errorCode: LeaseIdMissingRequired handlingCaller MUST catch RestError with statusCode 412 and handle lease conflicts.costmediumin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[2] - exists · successinfoWhencheck completes successfullyReturnsboolean indicating whether container existsRequired handlingNo action required — use the returned value as needed.costmediumin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[10]
- exists · auth-errorwarningWhenauthentication failsThrows
RestError with statusCode 403Required handlingCaller SHOULD catch RestError for permission errors even when checking existence.costmediumin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[2] - listContainers · successinfoWhenlisting succeedsReturnsAsyncIterableIterator of ContainerItem objectsRequired handlingNo action required — use the returned value as needed.costmediumin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[11]
- listContainers · auth-errorerrorWhenauthentication failsThrows
RestError with statusCode 403Required handlingCaller MUST catch RestError when iterating containers to handle auth failures.costmediumin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[2] - deleteBlob · blob-delete-snapshots-presenterrorWhenblob has one or more snapshots and deleteSnapshots option was not set — throws RestError with statusCode 409 and errorCode SnapshotsPresent. A very common silent bug: code that successfully deletes blobs in development (no snapshots) fails in production after versioning or backup jobs create snapshots.Throws
RestError with statusCode 409 and errorCode: SnapshotsPresentRequired handlingCaller MUST either pass { deleteSnapshots: 'include' } to delete blob and all snapshots together, or catch RestError with statusCode 409 and errorCode SnapshotsPresent to handle the conflict.costmediumin prodimmediate exceptionusers seelost datavisibilitysilent - deleteBlob · blob-delete-not-founderrorWhenblob does not exist — throws RestError with statusCode 404 and errorCode BlobNotFound. Common in cleanup flows where the blob was already deleted by another process.Throws
RestError with statusCode 404 and errorCode: BlobNotFoundRequired handlingCaller MUST catch RestError and check error.statusCode === 404 to handle already-deleted blobs gracefully. Or use deleteIfExists() which returns { succeeded: false } instead of throwing.costlowin prodimmediate exceptionusers seeservice unavailablevisibilityvisible - deleteBlob · blob-delete-lease-conflicterrorWhenblob has an active lease but no lease ID was provided — throws RestError with statusCode 412 and errorCode LeaseIdMissing or LeaseIdMismatchWithBlobOperation.Throws
RestError with statusCode 412 and errorCode: LeaseIdMissing or LeaseIdMismatchWithBlobOperationRequired handlingCaller MUST provide the active lease ID via options.conditions.leaseId when deleting leased blobs. Catch RestError with statusCode 412 to detect lease conflicts.costlowin prodimmediate exceptionusers seeservice unavailablevisibilityvisible - uploadStream · uploadstream-no-try-catcherrorWhenany network failure, auth error, or storage service error during block staging or commit — throws RestError. Because uploadStream() makes multiple HTTP requests (one stageBlock per bufferSize chunk), any intermediate failure throws and the partial upload is left uncommitted.Throws
RestError (from @azure/core-rest-pipeline) with statusCode reflecting the HTTP failureRequired handlingCaller MUST wrap uploadStream in try-catch. On error, the partially staged blocks are automatically cleaned up by Azure after 7 days, but the upload must be retried from the beginning.costhighin prodimmediate exceptionusers seelost datavisibilitysilent - uploadStream · uploadstream-container-not-founderrorWhenthe target container does not exist — throws RestError with statusCode 404 and errorCode ContainerNotFound. Common in multi-tenant apps where containers are provisioned lazily and creation fails silently.Throws
RestError with statusCode 404 and errorCode: ContainerNotFoundRequired handlingCaller MUST ensure container exists before calling uploadStream. Catch RestError with statusCode 404 and errorCode ContainerNotFound to detect missing containers and provision them via containerClient.createIfNotExists().costmediumin prodimmediate exceptionusers seeservice unavailablevisibilityvisible - uploadBlockBlob · uploadblockblob-no-try-catcherrorWhenany network failure, auth error, or service error — throws RestError. Same error profile as BlockBlobClient.upload() since it delegates to that method. Commonly called in API route handlers without try-catch because callers assume the container already exists.Throws
RestError (from @azure/core-rest-pipeline) on any service or network failureRequired handlingCaller MUST wrap in try-catch. The returned blockBlobClient can be used to retry the upload after creating the container if needed.costmediumin prodimmediate exceptionusers seeservice unavailablevisibilityvisible - uploadBlockBlob · uploadblockblob-container-not-founderrorWhenthe container encoded in the ContainerClient URL does not exist — throws RestError with statusCode 404 and errorCode ContainerNotFound. Every blob upload to the container fails until the container is created.Throws
RestError with statusCode 404 and errorCode: ContainerNotFoundRequired handlingCaller MUST ensure container exists. Use containerClient.createIfNotExists() before the first upload to a new container.costhighin prodimmediate exceptionusers seeservice unavailablevisibilityvisible - deleteBlob · container-deleteblob-snapshots-presenterrorWhenblob has snapshots and deleteSnapshots option is not set — throws RestError with statusCode 409 and errorCode SnapshotsPresent. Same behavior as BlobClient.delete(). Affects blobs that have been snapshotted by Azure Backup or versioning policies.Throws
RestError with statusCode 409 and errorCode: SnapshotsPresentRequired handlingCaller MUST pass { deleteSnapshots: 'include' } option or handle the 409 RestError with errorCode SnapshotsPresent to detect snapshot conflicts.costmediumin prodimmediate exceptionusers seelost datavisibilitysilent - deleteBlob · container-deleteblob-not-foundwarningWhenthe named blob does not exist — throws RestError with statusCode 404 and errorCode BlobNotFound. Common in eventual-consistency scenarios where the blob was deleted between a list operation and the delete call.Throws
RestError with statusCode 404 and errorCode: BlobNotFoundRequired handlingCaller MUST catch RestError with statusCode 404 to handle already-deleted blobs, or create a BlobClient and use deleteIfExists() instead for idempotent deletion.costlowin prodimmediate exceptionusers seeservice unavailablevisibilityvisible - beginCopyFromURL · begincopy-poll-not-awaitederrorWhencaller does not await poller.pollUntilDone() after beginCopyFromURL() — the destination blob remains in 'pending' state while code proceeds as if the copy completed. No exception is thrown; the result is a silently incomplete blob.Throws
Does NOT throw at copy initiation. The copy runs asynchronously server-side. Only pollUntilDone() throws if the copy fails. Using the destination blob before pollUntilDone() completes results in reading partial or empty content.Required handlingCaller MUST await poller.pollUntilDone() after beginCopyFromURL(). Pattern: const poller = await blobClient.beginCopyFromURL(sourceUrl); const result = await poller.pollUntilDone(); Then check result.copyStatus === 'success' before using destination blob.costhighin prodsilent failureusers seelost datavisibilitysilent - beginCopyFromURL · begincopy-source-not-accessibleerrorWhensource URL is inaccessible to the storage service — throws RestError with statusCode 400 or 403. Causes: source blob requires SAS token not provided, source is in a different account without cross-account SAS, or SAS token expired.Throws
RestError with statusCode 400 or 403 from the storage serviceRequired handlingCaller MUST catch RestError on both beginCopyFromURL() and pollUntilDone() calls. For cross-account copies, source URL must include a valid SAS token with read permissions.costmediumin prodimmediate exceptionusers seeservice unavailablevisibilityvisible - syncCopyFromURL · synccopy-no-try-catcherrorWhenany network failure, source access error, or service error — throws RestError. Unlike beginCopyFromURL(), syncCopyFromURL() blocks until the copy completes so the await must be wrapped in try-catch.Throws
RestError (from @azure/core-rest-pipeline) on any service or network failureRequired handlingCaller MUST wrap syncCopyFromURL in try-catch. For large blobs (>256MB) or when size is unknown, use beginCopyFromURL() instead.costmediumin prodimmediate exceptionusers seeservice unavailablevisibilityvisible - syncCopyFromURL · synccopy-source-inaccessibleerrorWhensource URL requires authentication the storage service cannot provide — throws RestError with statusCode 403. Also throws for source blob size > 256 MiB limit. Developers testing with public URLs succeed but production with private blobs fails.Throws
RestError with statusCode 403 (auth) or 400 (size limit exceeded)Required handlingCaller MUST ensure source URL includes appropriate SAS token for private Azure blobs, and validate source blob size is within 256 MiB limit.costmediumin prodimmediate exceptionusers seeservice unavailablevisibilityvisible - downloadToBuffer · downloadtobuffer-no-try-catcherrorWhenany network failure, auth error, or service error during parallel range downloads — throws RestError. If one parallel range request fails mid-download, the entire operation throws and partial data is discarded.Throws
RestError (from @azure/core-rest-pipeline) on any service or network failureRequired handlingCaller MUST wrap downloadToBuffer in try-catch. For very large blobs, use download() with streaming instead to avoid loading the entire file into memory.costmediumin prodimmediate exceptionusers seelost datavisibilitysilent - downloadToBuffer · downloadtobuffer-blob-not-founderrorWhenblob does not exist — throws RestError with statusCode 404 and errorCode BlobNotFound. Common in file processing queues where the blob was deleted between enqueue and processing.Throws
RestError with statusCode 404 and errorCode: BlobNotFoundRequired handlingCaller MUST catch RestError with statusCode 404 to distinguish missing blobs from transient network errors. Missing blobs should not be retried.costmediumin prodimmediate exceptionusers seeservice unavailablevisibilityvisible - downloadToFile · downloadtofile-no-try-catcherrorWhennetwork failure, storage service error, or filesystem error during download — throws RestError (storage errors) or Node.js filesystem Error with code ENOENT, EACCES, or ENOSPC (disk full). The partial file written to disk is NOT automatically cleaned up on failure.Throws
RestError for storage service errors, or Error with code ENOENT/EACCES/ENOSPC for filesystem errors. Partial file remains on disk in both cases.Required handlingCaller MUST wrap downloadToFile in try-catch AND clean up the partial file on error: catch (err) { await fs.unlink(filePath).catch(() => {}); throw err; }costmediumin prodimmediate exceptionusers seelost datavisibilitysilent - downloadToFile · downloadtofile-blob-not-founderrorWhensource blob does not exist — throws RestError with statusCode 404 and errorCode BlobNotFound. The local file may be created as empty or partially written before the error surfaces from the stream.Throws
RestError with statusCode 404 and errorCode: BlobNotFoundRequired handlingCaller MUST check error.statusCode === 404 to detect missing blobs and delete any partially created local file before re-throwing.costmediumin prodimmediate exceptionusers seelost datavisibilitysilent - getUserDelegationKey · getuserdelegationkey-no-try-catcherrorWhencredential lacks the Microsoft.Storage generateUserDelegationKey permission — throws RestError with statusCode 403. Also throws RestError on network failures. In production, RBAC permissions are often more restrictive than development environments, causing this to fail at runtime.Throws
RestError with statusCode 403 (permission denied) or 401 (unauthenticated)Required handlingCaller MUST wrap getUserDelegationKey in try-catch. The calling identity needs Storage Blob Delegator role (Microsoft.Storage/storageAccounts/blobServices/ generateUserDelegationKey). Cache the returned key until its expiresOn time.costhighin prodimmediate exceptionusers seeservice unavailablevisibilityvisible - getUserDelegationKey · getuserdelegationkey-expired-windowwarningWhenuser delegation key is cached past its expiresOn timestamp — SAS tokens signed with an expired key return 403 AuthorizationPermissionMismatch when clients use them. No error is thrown at key retrieval time.Throws
Does NOT throw at key retrieval. SAS tokens signed with the expired key return HTTP 403 when used. The error surfaces in downstream client operations, not here.Required handlingCaller MUST track key.expiresOn and refresh the key before it expires. Do NOT cache user delegation keys indefinitely. Cache with TTL of expiresOn minus 5 minutes to ensure rotation before expiry.costmediumin prodsilent failureusers seelost datavisibilitysilent - generateSasUrl · generatesasurl-not-shared-keyerrorWhenContainerClient was constructed with TokenCredential (Azure AD) or AnonymousCredential instead of StorageSharedKeyCredential — throws Error locally without making a network call. Teams migrating from account key to managed identity break SAS generation at runtime.Throws
Error with message "A shared key credential must be provided to generate a SAS URL". Local error — no network call is made.Required handlingCaller MUST use StorageSharedKeyCredential for SAS generation, or use generateUserDelegationSasUrl() with a user delegation key obtained from getUserDelegationKey() when using managed identity / Azure AD credentials.costhighin prodimmediate exceptionusers seeservice unavailablevisibilityvisible - generateSasUrl · generatesasurl-expired-saswarningWhengenerated SAS URL is cached or shared and used after options.expiresOn — clients using the URL receive 403 AuthorizationPermissionMismatch. No error is thrown at generation time; the invalid SAS is silently issued.Throws
Does NOT throw at SAS generation. Clients using the expired SAS URL receive HTTP 403 AuthorizationPermissionMismatch from the storage service.Required handlingCaller MUST set options.expiresOn to an appropriate future time (typically 15 minutes for upload forms, up to 1 hour for download links). Communicate expiry to end users and provide a mechanism to generate fresh URLs.costmediumin prodsilent failureusers seelost datavisibilitysilent - exists · blob-exists-no-try-catcherrorWhencredential lacks read permission on the blob (statusCode 403), or the storage service throttles the request (statusCode 429), or the account enforces a network ACL the client violates (statusCode 403 AuthorizationFailure) — exists() re-throws RestError. The boolean return contract misleads callers into omitting try-catch.Throws
RestError (from @azure/core-rest-pipeline) — statusCode 403 (auth/ACL), 429 (throttling), or network error codeRequired handlingCaller MUST wrap exists() in try-catch and distinguish (a) the boolean false result (truly missing) from (b) a thrown RestError (auth / throttling / network). Do NOT treat a thrown error as equivalent to "blob does not exist" — that produces silent data loss when permissions regress in production.costmediumin prodimmediate exceptionusers seeservice unavailablevisibilityvisible - exists · blob-exists-race-conditionwarningWhenanother writer creates or deletes the blob between the exists() check and a subsequent operation (download, delete, copy). exists() is a point-in-time read; the result is stale the moment it returns. Time-of-check / time-of-use (TOCTOU) bugs in cleanup jobs and migration scripts.Throws
Does NOT throw on race. The race manifests in the next operation as a RestError 404 BlobNotFound on download/delete, or 409 BlobAlreadyExists on upload.Required handlingCaller SHOULD prefer single-call patterns over check-then-act. For deletes use deleteIfExists(); for conditional uploads use If-None-Match or If-Match conditional headers (options.conditions.ifMatch); for downloads catch the RestError 404 directly. exists() is appropriate ONLY for read-only telemetry / dashboards where staleness is acceptable.costmediumin proddelayed failureusers seelost datavisibilitysilent - deleteIfExists · blob-deleteifexists-snapshots-presenterrorWhenblob has one or more snapshots and deleteSnapshots option was NOT set — deleteIfExists throws RestError statusCode 409 errorCode SnapshotsPresent (forwarded from delete()). This is the same critical production bug as BlobClient.delete() — succeeds in development without snapshots, fails in production after Azure Backup or versioning policy creates snapshots.Throws
RestError with statusCode 409 and errorCode: SnapshotsPresent (not swallowed by the "if exists" wrapper)Required handlingCaller MUST either pass { deleteSnapshots: 'include' } to delete blob and snapshots together, or wrap deleteIfExists in try-catch and check error.details?.errorCode === 'SnapshotsPresent'. The boolean succeeded flag does NOT cover this case — the call throws before returning.costmediumin prodimmediate exceptionusers seelost datavisibilitysilent - deleteIfExists · blob-deleteifexists-lease-conflicterrorWhenblob has an active lease and no lease ID was provided — deleteIfExists throws RestError statusCode 412 errorCode LeaseIdMissing or LeaseIdMismatchWithBlobOperation. The wrapper does NOT swallow lease errors.Throws
RestError with statusCode 412 and errorCode: LeaseIdMissing or LeaseIdMismatchWithBlobOperationRequired handlingCaller MUST provide the active lease ID via options.conditions.leaseId for leased blobs. The "if exists" wrapper is NOT a replacement for try-catch around the call.costlowin prodimmediate exceptionusers seeservice unavailablevisibilityvisible - deleteIfExists · blob-deleteifexists-auth-and-throttlingerrorWhencredential lacks delete permission on the blob (403), or the storage service throttles the request (429 ServerBusy / TimeoutException) — the wrapper re-throws RestError. Cleanup batch jobs that iterate large blob counts commonly trigger throttling; without try-catch the batch halts mid-iteration leaving an inconsistent dataset.Throws
RestError with statusCode 403 (auth) or 429 (throttling — ServerBusy / OperationTimedOut)Required handlingCaller MUST wrap deleteIfExists in try-catch even though the name implies safety. For batch cleanup jobs, implement retry-with-backoff on RestError 429 and surface 403 to the operator (RBAC regression, not a transient fault).costmediumin prodimmediate exceptionusers seeservice unavailablevisibilityvisible - setTags · settags-precondition-failederrorWhenoptions.conditions.ifTags or .ifMatch is provided and the current blob state does not satisfy the predicate — throws RestError statusCode 412 errorCode ConditionNotMet (ifMatch) or TagConditionNotMet (ifTags). New in 12.30.0; legacy callers pinned to <=12.29.x will not encounter this.Throws
RestError with statusCode 412 and errorCode: ConditionNotMet or TagConditionNotMetRequired handlingCaller MUST catch RestError with statusCode 412 to detect conditional-write races. Typical pattern is retry with a fresh ETag or back off and re-read tags via getTags() before re-attempting setTags.costmediumin prodimmediate exceptionusers seelost datavisibilityvisible - setTags · settags-invalid-tag-valueerrorWhentag name violates the 1-128 char rule, value violates the 0-256 char rule, tag name contains disallowed characters, or the blob already has 10 tags and a new tag is being added — throws RestError statusCode 400 errorCode InvalidXmlNodeValue / InvalidInput. Often triggered by serializing user-supplied metadata directly into tags without validation.Throws
RestError with statusCode 400 and errorCode: InvalidInput or InvalidXmlNodeValueRequired handlingCaller MUST validate tag inputs against Azure's rules BEFORE calling setTags, or catch RestError 400 and surface the validation error to the end user. Storing user-supplied data as tags requires explicit allowlist / sanitization.costlowin prodimmediate exceptionusers seelost datavisibilityvisible - setTags · settags-blob-not-founderrorWhentarget blob does not exist or is in a deleted state — throws RestError statusCode 404 errorCode BlobNotFound. Often encountered after async deletion in retention workflows.Throws
RestError with statusCode 404 and errorCode: BlobNotFoundRequired handlingCaller MUST catch RestError statusCode 404 to handle the deleted-between-list-and-tag race that retention pipelines hit. Skip and log; do not abort the batch.costlowin prodimmediate exceptionusers seeservice unavailablevisibilityvisible
Sources
Every postcondition cites at least one of these. Grouped by source type; numbered to match the footnotes above.
- [1]learn.microsoft.com/en-us/javascript/apiBlobclient
- [2]learn.microsoft.com/en-us/rest/apiBlob Service Error Codes
- [4]learn.microsoft.com/en-us/javascript/apiBlobclient
- [5]learn.microsoft.com/en-us/javascript/apiBlockblobclient
- [6]learn.microsoft.com/en-us/javascript/apiBlockblobclient
- [7]learn.microsoft.com/en-us/javascript/apiBlockblobclient
- [8]learn.microsoft.com/en-us/javascript/apiContainerclient
- [9]learn.microsoft.com/en-us/javascript/apiContainerclient
- [10]learn.microsoft.com/en-us/javascript/apiContainerclient
- [11]learn.microsoft.com/en-us/javascript/apiBlobserviceclient
- [12]learn.microsoft.com/en-us/javascript/apiBlobclient
- [13]learn.microsoft.com/en-us/javascript/apiBlockblobclient
- [14]learn.microsoft.com/en-us/javascript/apiContainerclient
- [15]learn.microsoft.com/en-us/javascript/apiContainerclient
- [16]learn.microsoft.com/en-us/javascript/apiBlobclient
- [17]learn.microsoft.com/en-us/rest/apiCopy Blob
- [18]learn.microsoft.com/en-us/javascript/apiBlobclient
- [19]learn.microsoft.com/en-us/rest/apiCopy Blob From Url
- [20]learn.microsoft.com/en-us/javascript/apiBlobclient
- [21]learn.microsoft.com/en-us/rest/apiGet Blob
- [22]learn.microsoft.com/en-us/javascript/apiBlobclient
- [23]learn.microsoft.com/en-us/javascript/apiBlobserviceclient
- [24]learn.microsoft.com/en-us/rest/apiGet User Delegation Key
- [25]learn.microsoft.com/en-us/javascript/apiContainerclient
- [26]learn.microsoft.com/en-us/rest/apiConstructing A Service Sas
- [27]learn.microsoft.com/en-us/javascript/apiBlobclient
- [28]learn.microsoft.com/en-us/rest/apiSpecifying Conditional Headers For Blob Service Operations
- [29]learn.microsoft.com/en-us/javascript/apiBlobclient
- [30]learn.microsoft.com/en-us/rest/apiStorage Service Throttle Warnings
- [32]learn.microsoft.com/en-us/rest/apiSet Blob Tags
- [33]learn.microsoft.com/en-us/azure/storageStorage Manage Find Blobs
- [34]learn.microsoft.com/en-us/javascript/apiBlobclient
- [31]github.com/Azure/azure-sdk-for-js/blobAzure/azure-sdk-for-js · CHANGELOG.md
- [3]github.com/Azure/azure-sdk-for-js/issuesAzure/azure-sdk-for-js issue #4999
Research notes
Curator notes from SOURCES.md captured when the profile was written so you can verify the reasoning, not just the rules.
Sources: @azure/storage-blob
Package: @azure/storage-blob Contract Version: 1.0.0 Last Verified: 2026-02-27 Status: Draft (Phase 6-7 incomplete)
Official Documentation
Primary Documentation
-
Azure Storage Blob Client Library for JavaScript
https://learn.microsoft.com/en-us/javascript/api/overview/azure/storage-blob-readme?view=azure-node-latest
Official Microsoft Learn documentation for the @azure/storage-blob SDK. Documents all client classes, methods, authentication patterns, and basic error handling. -
npm Package
https://www.npmjs.com/package/@azure/storage-blob
Official npm registry page with version history, installation instructions, and package metadata.
API Reference
-
BlobClient API Reference
https://learn.microsoft.com/en-us/javascript/api/@azure/storage-blob/blobclient
Complete API documentation for BlobClient class including download(), getProperties(), delete(), and exists() methods. -
BlockBlobClient API Reference
https://learn.microsoft.com/en-us/javascript/api/@azure/storage-blob/blockblobclient
Complete API documentation for BlockBlobClient class including upload(), uploadFile(), and uploadData() methods. -
ContainerClient API Reference
https://learn.microsoft.com/en-us/javascript/api/@azure/storage-blob/containerclient
Complete API documentation for ContainerClient class including create(), delete(), and exists() methods. -
BlobServiceClient API Reference
https://learn.microsoft.com/en-us/javascript/api/@azure/storage-blob/blobserviceclient
Complete API documentation for BlobServiceClient class including listContainers() and container management methods.
Getting Started
- Quickstart: Azure Blob Storage for Node.js
https://learn.microsoft.com/en-us/azure/storage/blobs/storage-quickstart-blobs-nodejs
Official Microsoft quickstart guide showing how to create a Node.js application that uses Azure Blob Storage.
Error Handling Documentation
Error Codes
- Blob Service Error Codes (REST API)
https://learn.microsoft.com/en-us/rest/api/storageservices/blob-service-error-codes
CRITICAL: Comprehensive list of 60+ error codes including BlobNotFound (404), BlobAlreadyExists (409), ContainerNotFound (404), ContainerAlreadyExists (409), InvalidBlobType (409), LeaseIdMissing (412), BlobArchived (409), and more. Each error code includes HTTP status code and user message.
Error Handling Patterns
-
Error Handling in Storage SDKs - GitHub Issue #4999
https://github.com/Azure/azure-sdk-for-js/issues/4999
CRITICAL: Documents incomplete error parsing in the SDK. Error codes must be manually extracted from response headers usingerr.response.headers.get('x-ms-error-code')because the SDK does not automatically deserialize Azure-specific error information. This is a known limitation. -
Top Level Error Fields Missing Data - GitHub Issue #12997
https://github.com/Azure/azure-sdk-for-js/issues/12997
Documents thaterror.details?.errorCodeis available but inconsistent. Developers should use multiple methods to access error codes.
Troubleshooting
- Troubleshoot Client Application Errors
https://learn.microsoft.com/en-us/troubleshoot/azure/azure-storage/blobs/alerts/troubleshoot-storage-client-application-errors
Official Microsoft troubleshooting guide for common client-side errors including authentication failures, permission errors, and network issues.
Security & Vulnerability Information
Security Recommendations
- Security Recommendations for Blob Storage
https://learn.microsoft.com/en-us/azure/storage/blobs/security-recommendations
Official Microsoft security best practices for Azure Blob Storage including authentication, authorization, network security, and encryption.
CVE Information
- CVE-2022-30187: CBC Padding Oracle in Azure Blob Storage Encryption Library
https://github.com/advisories/GHSA-64x4-9hc6-r2h6
Security vulnerability in Java Azure Blob Storage Encryption SDK (not JavaScript). Included for awareness of encryption-related security concerns across Azure SDK family.
Contract Rationale
Postcondition: download - blob-not-found
Error Code: BlobNotFound (404)
Rationale: When attempting to download a blob that doesn't exist, the SDK throws RestError with statusCode 404. Applications must handle this to distinguish between missing blobs (expected) and actual failures (unexpected). Unhandled exceptions cause application crashes.
Source: https://learn.microsoft.com/en-us/rest/api/storageservices/blob-service-error-codes
Postcondition: download - blob-archived
Error Code: BlobArchived (409)
Rationale: Blobs in archived tier cannot be downloaded directly and must be rehydrated first. Applications must catch this error and either initiate rehydration or return appropriate error to user.
Source: https://learn.microsoft.com/en-us/rest/api/storageservices/blob-service-error-codes
Postcondition: upload - blob-already-exists
Error Code: BlobAlreadyExists (409)
Rationale: When using If-None-Match: * header, upload fails if blob exists. Applications must handle conflicts appropriately, either by overwriting (different API call) or returning error.
Source: https://learn.microsoft.com/en-us/rest/api/storageservices/blob-service-error-codes
Postcondition: upload - container-not-found
Error Code: ContainerNotFound (404)
Rationale: Uploading to non-existent container throws 404. Common mistake is not creating container first. Applications must either ensure container exists or handle 404 and create container.
Source: https://learn.microsoft.com/en-us/rest/api/storageservices/blob-service-error-codes
Postcondition: create - container-already-exists
Error Code: ContainerAlreadyExists (409)
Rationale: Creating a container that already exists throws 409. Common pattern is to check exists() first or catch 409 and continue. Applications must not crash on this expected error.
Source: https://learn.microsoft.com/en-us/rest/api/storageservices/blob-service-error-codes
Postcondition: create - container-being-deleted
Error Code: ContainerBeingDeleted (409)
Rationale: Container deletion is not instant. Attempting to create during deletion throws 409. Applications must wait and retry with exponential backoff.
Source: https://learn.microsoft.com/en-us/rest/api/storageservices/blob-service-error-codes
Postcondition: network-error (all operations)
Error Codes: ECONNREFUSED, ETIMEDOUT, ENOTFOUND
Rationale: All async operations can fail due to network issues. Applications must implement retry logic with exponential backoff for transient failures.
Source: https://github.com/Azure/azure-sdk-for-js/issues/4999
Common Patterns
Pattern 1: Upload with Container Creation
try {
const containerClient = blobServiceClient.getContainerClient('mycontainer');
const blockBlobClient = containerClient.getBlockBlobClient('myblob');
await blockBlobClient.upload(data, data.length);
} catch (error) {
if (error instanceof RestError && error.statusCode === 404) {
// Container doesn't exist, create it first
await containerClient.create();
await blockBlobClient.upload(data, data.length);
} else {
throw error;
}
}
Pattern 2: Download with 404 Handling
try {
const response = await blobClient.download();
return response;
} catch (error) {
if (error instanceof RestError && error.statusCode === 404) {
console.log('Blob not found');
return null; // Return null for missing blobs
}
throw error; // Re-throw other errors
}
Pattern 3: Container Existence Check
try {
const exists = await containerClient.exists();
if (\!exists) {
await containerClient.create();
}
} catch (error) {
if (error instanceof RestError && error.statusCode === 409) {
// Container created by another process, continue
return;
}
throw error;
}
Detection Characteristics
Error Pattern: All operations THROW exceptions (RestError) Detection Rate: 85% (estimated, similar to axios, stripe, prisma) Analyzer Capability: High - analyzer detects missing try-catch blocks well Production Ready: No - requires Phase 6 (Analyzer Testing) and Phase 7 (Real-World Validation) Draft Reason: Build issues prevented analyzer testing; validation incomplete
Additional References
-
GitHub Repository
https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/storage/storage-blob
Source code and samples for the Azure Storage Blob SDK -
CHANGELOG
https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/storage/storage-blob/CHANGELOG.md
Version history including service version 2026-02-06 support -
Complete Guide & Tutorial (2025)
https://generalistprogrammer.com/tutorials/azure-storage-blob-npm-package-guide
Third-party comprehensive guide with code examples and best practices
Research Date: 2026-02-27
Researcher: Claude Sonnet 4.5 (behavioral-contracts corpus team)