TokenAcquirerFactory reffers to wrong location for configuration in Azure function V4 #2471
Labels
Azure Functions
duplicate
This issue or pull request already exists
question
Further information is requested
Microsoft.Identity.Web Library
Microsoft.Identity.Web.DownstreamApi
Microsoft.Identity.Web version
2.13.4
Web app
Not Applicable
Web API
Not Applicable
Token cache serialization
Distributed caches
Description
I am trying to configure a V4 Azure Function(Servicebus Trigger), which is calling external APIs, And I am trying to use DownstreamApi.
The TokenAcquirerFactory.GetDefaultInstance() is refferring to the wrong location(AppData\Local\AzureFunctionsTools\Releases\4.51.0\cli_x64), instead of output directory. the below code is returning the azure function cli location instead of output directory. And it nether adds environment variables to the Configuration inside TokenAcquirerFactory.
// TokenAcquirerFactory.cs in Microsoft.Identity.Web.TokenAquisition
protected virtual string DefineConfiguration(IConfigurationBuilder builder)
{
Assembly assembly = Assembly.GetEntryAssembly() ?? Assembly.GetExecutingAssembly();
return Path.GetDirectoryName(assembly!.Location)!;
}
Reproduction steps
Error message
at Microsoft.Identity.Web.MergedOptions.PrepareAuthorityInstanceForMsal()
at Microsoft.Identity.Web.TokenAcquisition.BuildConfidentialClientApplication(MergedOptions mergedOptions)
at Microsoft.Identity.Web.TokenAcquisition.GetOrBuildConfidentialClientApplication(MergedOptions mergedOptions)
at Microsoft.Identity.Web.TokenAcquisition.GetAuthenticationResultForAppAsync(String scope, String authenticationScheme, String tenant, TokenAcquisitionOptions tokenAcquisitionOptions)
at Microsoft.Identity.Web.DefaultAuthorizationHeaderProvider.d__3.MoveNext()
at Microsoft.Identity.Web.DownstreamApi.d__18.MoveNext()
Id Web logs
No response
Relevant code snippets
Regression
No response
Expected behavior
Should load configuration from the appsettings.json file from output directory.
The text was updated successfully, but these errors were encountered: