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

SivaD 0 Reputation points Microsoft Vendor
2024-05-10T11:41:44.0866667+00:00

Hi,

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,

Siva

ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,263 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,212 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,957 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Bruce (SqlWork.com) 58,846 Reputation points
    2024-05-15T15:23:07.7266667+00:00

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