An Azure service that provides an event-driven serverless compute platform.
Hello Jayapriya J,
Welcome to the Microsoft Q&A and thank you for posting your questions here.
I understand that you are getting Unhandled exception when using Environment variable for DefaultAzureCredential.
The issue you're having was NOT environment variables but incorrect constructor usage of DefaultAzureCredential
Replace: var defaultAzureCredential = new DefaultAzureCredential(DefaultAzureCredential.DefaultEnvironmentVariableName);
with: var defaultAzureCredential = new DefaultAzureCredential();
Also, avoid: Setting AZURE_TOKEN_CREDENTIALS, over-configuring credentials, and mixing credential types unnecessarily, If environment variables are required, ensure these are set (only if using EnvironmentCredential explicitly):
- AZURE_CLIENT_ID
- AZURE_TENANT_ID
- AZURE_CLIENT_SECRET
https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/azure-iis-errors-reference
I hope this is helpful! Do not hesitate to let me know if you have any other questions or clarifications.
Please don't forget to close up the thread here by upvoting and accept it as an answer if it is helpful.