Skip to content

Generate an access token with a Managed identity #29781

@pievalentin

Description

@pievalentin
  • Package Name: azure-identity
  • Package Version: 1.12.0
  • Operating System: Ubuntu/ AzML
  • Python Version: 3.8

Bug description

I am an Azure costumer. I can't use MSAL to generate an access token for the scope of my app reg using my managed identity.

I have this setup:

  • I deployed an Azure function app that is validating access token of an Application registration. It checks that the Client has the correct role.
  • I have a compute instance that is assigned a Managed identity. I want to send a HTTP request to my azure function with an access token generated for my Managed Identity.

I also asked the MSAL team, they only have a draft PR.
For a production environment, I would need an upstream solution.

To Reproduce

  1. Create an app reg with a custom role
  2. Create a managed identity
  3. Assign the custom role to the managed identity
  4. Create a compute instance and assigned it the managed identity
  5. In the compute instance run:
from azure.identity import ManagedIdentityCredential
cred = ManagedIdentityCredential(client_id="<managed-identity-client-id>")
token = cred.get_token("api://<app-reg-client-id>/.default")

The code will run indefinitely

Expected behavior
After running token = cred.get_token("api://<app-reg-client-id>/.default") the token should be generated

What you see instead
image
Code is still running and no token is generated.

Metadata

Metadata

Assignees

Labels

Managed Identitycustomer-reportedIssues that are reported by GitHub users external to the Azure organization.needs-author-feedbackWorkflow: More information is needed from author to address the issue.needs-team-attentionWorkflow: This issue needs attention from Azure service team or SDK teamno-recent-activityThere has been no recent activity on this issue.questionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions