Forum Discussion
NirHazan
Feb 08, 2024Copper Contributor
Authenticate Azure DevOps API Using Entra ID Managed Identity (Python)
I need my Python script to authenticate Azure DevOps API using the System Assigned Managed Identity of the VM it is running on. To do that, I use azure.identity to get the managed identity token ...
- Feb 08, 2024
Solution:
def GetMIToken(): from azure.identity import ManagedIdentityCredential logging.info('Generating System Assigned Managed Identity token') credential = ManagedIdentityCredential() token = credential.get_token('499b84ac-1321-427f-aa17-267ca6975798/.default') logging.info('Successfully generated token') return token.token
NirHazan
Feb 08, 2024Copper Contributor
Solution:
def GetMIToken():
from azure.identity import ManagedIdentityCredential
logging.info('Generating System Assigned Managed Identity token')
credential = ManagedIdentityCredential()
token = credential.get_token('499b84ac-1321-427f-aa17-267ca6975798/.default')
logging.info('Successfully generated token')
return token.token