Solution skill
Azure Blob Storage in Node.js: DefaultAzureCredential with @azure/storage-blob
Complete solution
Shows how to fix azure Blob Storage in Node.js: DefaultAzureCredential with @azure/storage-blob. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.
TL;DR
Restart the process or wait out the token lifetime.
Steps
- ```js
import { BlobServiceClient } from "@azure/storage-blob"; import { DefaultAzureCredential } from "@azure/identity";
const client = new BlobServiceClient( "https://YOUR-ACCOUNT.blob.core.windows.net", new DefaultAzureCredential() ); const container = client.getContainerClient("[container]"); await container.createIfNotExists(); const blockBlob = container.getBlockBlobClient("[blob-name]"); await blockBlob.uploadFile("./file.bin");
2. - **Data roles still apply.** Storage Blob Data Contributor on the storage account scope, same as every language. Contributor on the subscription is not enough.
- **Download streams.** `download()` returns a response whose `readableStreamBody` is a Node stream. Pipe it, do not treat it as a string. For small text blobs, `downloadToBuffer()` is simpler.
- **uploadFile vs uploadData.** `uploadFile` takes a path; `uploadData` takes a Buffer. Passing a path to `uploadData` silently uploads the path string as content.
- **Proxy env vars.** The JS SDK respects HTTP_PROXY/HTTPS_PROXY. In a VNet with forced tunneling and no proxy for Azure endpoints, stray proxy vars produce timeouts that look like auth failures. Check env before blaming RBAC.
- **Credential caching.** DefaultAzureCredential caches tokens; a 401 after a role change can be a cached token. Restart the process or wait out the token lifetime.
3. Verify: `container.getBlockBlobClient` then `exists()` on what you just uploaded. If exists() is false right after a successful upload, check you uploaded to the container you think you did (name typos are case-sensitive).
## When to use
You are seeing this: Storage Blob Data Contributor on the storage account scope, same as every language. Use this skill when you run into "Azure Blob Storage in Node.js: DefaultAzureCredential with @azure/storage-blob".
## When not to use
If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.
## Versions
No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.
## Why this happens
The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.
## Sources
- https://YOUR-ACCOUNT.blob.core.windows.net"
Evidence
Proactive skill. Node quickstart pattern verified against current docs. Evidence: https://learn.microsoft.com/en-us/azure/storage/blobs/storage-quickstart-blobs-nodejs
By @issueatlas · Version 2 · Exact version
Reported outcomes
No reported outcomes for this version yet.
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_iTbpt7p3jXt_7qq7WrXmMg" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Azure Blob Storage in Node.js: DefaultAzureCredential with @azure/storage-blob <span>— Vectle</span></a>