I am trying to use Azure Storage for that I am using DefaultAzureCredential for authentication. I already logged in with the az login command. but when I run my Azure function, it gives me this error response.
{ "message": "{"odata.error":{"code":"AuthorizationPermissionMismatch","message":{"lang":"en-US","value":"This request is not authorized to perform this operation using this permission.\nRequestId:1fedb6ef-3002-0070-7133-fc1d53000000\nTime:2023-10-11T11:09:48.2823331Z"}}}" }
When I try this in console:-
const credential = new DefaultAzureCredential();
console.log(credential)
It's consoling this
DefaultAzureCredential { [2023-10-11T11:17:18.644Z] UnavailableMessage: 'DefaultAzureCredential => failed to retrieve a token from the included credentials. To troubleshoot, visit [https://aka.ms/azsdk/js/identity/defaultazurecredential/troubleshoot.'](https://aka.ms/azsdk/js/identity/defaultazurecredential/troubleshoot.%27), [2023-10-11T11:17:18.645Z] _sources: [
I don't know why it's not able to retrieve tokens from my CLI. I already tried AzureCliCredential its not working either.
Does anyone know how to fix it?
I am using Macbook Air M1 2020 OS Ventura 13.3
I tried using
DefaultAzureCredentialsin my local VS Code and tried accessing a blob inside my storage container via typescript Azure function and I was able to access the Blob successfully refer below:-I added the myself Storage Blob Data Contributor role at the Storage account level like below:-
I have this role assigned at subscription level thus it is inherited, You can add it at the storage account resource level too.
My httpTrigger1.ts:-
Output:-
I am also logged into my Account in my Vs code extension here:-
Reference:-
Assign an Azure role for access to blob data - Azure Storage | Microsoft Learn