ManagedIdentityApplication.AcquireTokenForManagedIdentity("api://AzureADTokenExchange") giving error in local machine.

SivaD 0 Reputation points Microsoft Vendor


I am implementing the "Federated Identity Credential" along with User Managed identity in .net core 3.1 web api.

Getting the error code: "managed_identity_unreachable_network" with error message "A socket operation was attempted to an unreachable network." in local machine in visual studio. Please suggest the solution for the below code.

IManagedIdentityApplication mi = ManagedIdentityApplicationBuilder.Create(ManagedIdentityId.WithUserAssignedClientId(userAssignedMSI)).Build();
AuthenticationResult assertion= await mi.AcquireTokenForManagedIdentity("api://AzureADTokenExchange/.default").ExecuteAsync().ConfigureAwait(false);

Thank you,


A set of technologies in the .NET Framework for building web applications and XML web services.
4,227 questions
Active Directory Federation Services
Active Directory Federation Services
An Active Directory technology that provides single-sign-on functionality by securely sharing digital identity and entitlement rights across security and enterprise boundaries.
1,204 questions
Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
19,767 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Bruce ( 57,641 Reputation points

    The url you pass to AcquireTokenForManagedIdentity() is not valid.

    0 comments No comments