question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

DefaultAzureCredential and User Assigned Identity in node Function App

See original GitHub issue
  • Package Name: @azure/identity
  • Package Version: 1.2.3
  • Operating system: Linux
  • nodejs
    • version: 12

Describe the bug

This works:

const credentials = new identity.ManagedIdentityCredential(process.env.USER_ASSIGNED_ID)

This doesn’t:

const credentials = new identity.DefaultAzureCredential()

I have an Azure Function App to which a User Assigned Identity is being used. It works fine with ManagedIdentityCredential, where I can specify the Client Id of the user assigned identity. I can’t see a way to use DefaultAzureCredential instead.

To Reproduce Steps to reproduce the behavior:

  1. Create a function app and a user assigned identity. Give the identity permissions to do something (e.g. Storage Blob Data Reader).
  2. Assign the user assigned identity to the function app.
  3. Try to create a DefaultAzureCredential.

Expected behavior I expect the DefaultAzureCredential to pick up the user assigned identity, or at least give me some way to assign the client id of the user assigned identity like ManagedIdentityCredential does.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
ashiccommented, Feb 27, 2021

@sadasant Thanks… looking at the code, I simply added an AZURE_CLIENT_ID app setting that equals the Client ID of the user assigned managed identity. It works as expected. Having it being passed through options can also come in handy.

0reactions
sadasantcommented, Apr 13, 2021

@ashic thank you for using our SDKs! Please let us know if you find any other issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Azure Identity client library for JavaScript | Microsoft Learn
Environment - The DefaultAzureCredential will read account information specified via environment variables and use it to authenticate. Managed ...
Read more >
Azure Identity 201 - DefaultAzureCredential Options
Azure Identity is a fundamental building block of the new Azure SDKs. ... By default, DefaultAzureCredential will use system-assigned ...
Read more >
@azure/identity node.js cannot authenticate - Stack Overflow
The DefaultAzureCredential works in your issue, even though it shows the unavailable message. You could console the EnvironmentCredential ...
Read more >
Azure Functions, Managed Identity, NodeJS, and Key Vault
Next, assign and identity. az functionapp identity assign --resource-group ${RG} --name ${APPNAME}.
Read more >
A Secure way to use Credentials and Secrets in Azure Functions
We will also demonstrate how to access environment variables in a Node.js function. ... Azure Functions App: Create a managed identity (Image by...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found