I was trying to use a user-assigned managed identity with the DefaultAzureCredential
, but am getting the 403 permissions mismatch error. I'm following the code example found in MS docs and it still fails. However, replacing the DefaultAzureCredential
with the explicit ManagedIdentityCredential
works just fine.
This is my code:
const { BlobServiceClient } = require('@azure/storage-blob');
const { DefaultAzureCredential } = require('@azure/identity');
const {url, clientId} = require('./config');
const cred = new DefaultAzureCredential({managedIdentityClientId: clientId});
const containerClient = new BlobServiceClient(url, cred).getContainerClient('container-name');
(async () => {
const exists = await containerClient.exists();
console.log({exists});
})();
This looks like it should work, but it does not. Any thoughts?
versions:
- "@azure/identity": "^1.1.0",
- "@azure/storage-blob": "^12.12.0",
- node v16.18.1