Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception when running ServiceBusTrigger with managed identity locally #2381

Open
mpec opened this issue Apr 4, 2024 · 6 comments
Open

Exception when running ServiceBusTrigger with managed identity locally #2381

mpec opened this issue Apr 4, 2024 · 6 comments
Labels
extensions: service-bus feature: identity potential-bug Items opened using the bug report template, not yet triaged and confirmed as a bug

Comments

@mpec
Copy link

mpec commented Apr 4, 2024

Description

When we run our functions that use ServiceBus Trigger locally we get an error log, but the function continues to run and connects to ServiceBus.

The error we see is:

False MSAL 4.56.0.0 MSAL.NetCore .NET 6.0.26 Microsoft Windows 10.0.22631 [2024-04-04 11:20:59Z - a5b037bc-4ded-4814-93cc-b888ba93c78f] Exception type: Azure.Identity.CredentialUnavailableException
[2024-04-04T11:20:59.554Z] ---> Inner Exception Details
[2024-04-04T11:20:59.554Z] Exception type: System.AggregateException
[2024-04-04T11:20:59.555Z] ---> Inner Exception Details
[2024-04-04T11:20:59.556Z] Exception type: Azure.RequestFailedException
[2024-04-04T11:20:59.557Z] ---> Inner Exception Details
[2024-04-04T11:20:59.558Z] Exception type: System.Net.Http.HttpRequestException
[2024-04-04T11:20:59.558Z] ---> Inner Exception Details
[2024-04-04T11:20:59.559Z] Exception type: System.Net.Sockets.SocketException
[2024-04-04T11:20:59.560Z]
[2024-04-04T11:20:59.560Z]    at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.ThrowException(SocketError error, CancellationToken cancellationToken)
[2024-04-04T11:20:59.561Z]    at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.System.Threading.Tasks.Sources.IValueTaskSource.GetResult(Int16 token)
[2024-04-04T11:20:59.562Z]    at System.Net.Sockets.Socket.<ConnectAsync>g__WaitForConnectWithCancellation|277_0(AwaitableSocketAsyncEventArgs saea, ValueTask connectTask, CancellationToken cancellationToken)
[2024-04-04T11:20:59.562Z]    at System.Net.Http.HttpConnectionPool.ConnectToTcpHostAsync(String host, Int32 port, HttpRequestMessage initialRequest, Boolean async, CancellationToken cancellationToken)
[2024-04-04T11:20:59.563Z] === End of inner exception stack trace ===
[2024-04-04T11:20:59.564Z]
[2024-04-04T11:20:59.564Z]    at System.Net.Http.HttpConnectionPool.ConnectToTcpHostAsync(String host, Int32 port, HttpRequestMessage initialRequest, Boolean async, CancellationToken cancellationToken)
[2024-04-04T11:20:59.565Z]    at System.Net.Http.HttpConnectionPool.ConnectAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
[2024-04-04T11:20:59.566Z]    at System.Net.Http.HttpConnectionPool.CreateHttp11ConnectionAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
[2024-04-04T11:20:59.566Z]    at System.Net.Http.HttpConnectionPool.AddHttp11ConnectionAsync(HttpRequestMessage request)
[2024-04-04T11:20:59.567Z]    at System.Threading.Tasks.TaskCompletionSourceWithCancellation`1.WaitWithCancellationAsync(CancellationToken cancellationToken)
[2024-04-04T11:20:59.568Z]    at System.Net.Http.HttpConnectionPool.GetHttp11ConnectionAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
[2024-04-04T11:20:59.568Z]    at System.Net.Http.HttpConnectionPool.SendWithVersionDetectionAndRetryAsync(HttpRequestMessage request, Boolean async, Boolean doRequestAuth, CancellationToken cancellationToken)
[2024-04-04T11:20:59.569Z]    at System.Net.Http.HttpClient.<SendAsync>g__Core|83_0(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationTokenSource cts, Boolean disposeCts, CancellationTokenSource pendingRequestsCts, CancellationToken originalCancellationToken)
[2024-04-04T11:20:59.570Z]    at Azure.Core.Pipeline.HttpClientTransport.ProcessAsync(HttpMessage message, Boolean async)
[2024-04-04T11:20:59.570Z] === End of inner exception stack trace ===
[2024-04-04T11:20:59.571Z]
[2024-04-04T11:20:59.572Z]    at Azure.Core.Pipeline.HttpClientTransport.ProcessAsync(HttpMessage message, Boolean async)
[2024-04-04T11:20:59.572Z]    at Azure.Core.Pipeline.HttpPipelineTransportPolicy.ProcessAsync(HttpMessage message, ReadOnlyMemory`1 pipeline)
[2024-04-04T11:20:59.573Z]    at Azure.Core.Pipeline.ResponseBodyPolicy.ProcessAsync(HttpMessage message, ReadOnlyMemory`1 pipeline, Boolean async)
[2024-04-04T11:20:59.574Z]    at Azure.Core.Pipeline.LoggingPolicy.ProcessAsync(HttpMessage message, ReadOnlyMemory`1 pipeline, Boolean async)
[2024-04-04T11:20:59.575Z]    at Azure.Core.Pipeline.RedirectPolicy.ProcessAsync(HttpMessage message, ReadOnlyMemory`1 pipeline, Boolean async)
[2024-04-04T11:20:59.575Z]    at Azure.Core.Pipeline.RetryPolicy.ProcessAsync(HttpMessage message, ReadOnlyMemory`1 pipeline, Boolean async)
[2024-04-04T11:20:59.576Z] === End of inner exception stack trace ===
[2024-04-04T11:20:59.577Z]
[2024-04-04T11:20:59.577Z]    at Azure.Core.Pipeline.RetryPolicy.ProcessAsync(HttpMessage message, ReadOnlyMemory`1 pipeline, Boolean async)
[2024-04-04T11:20:59.578Z]    at Azure.Identity.ManagedIdentitySource.AuthenticateAsync(Boolean async, TokenRequestContext context, CancellationToken cancellationToken)
[2024-04-04T11:20:59.579Z]    at Azure.Identity.ImdsManagedIdentitySource.AuthenticateAsync(Boolean async, TokenRequestContext context, CancellationToken cancellationToken)
[2024-04-04T11:20:59.579Z] === End of inner exception stack trace ===
[2024-04-04T11:20:59.580Z]
[2024-04-04T11:20:59.580Z]    at Azure.Identity.ImdsManagedIdentitySource.AuthenticateAsync(Boolean async, TokenRequestContext context, CancellationToken cancellationToken)
[2024-04-04T11:20:59.581Z]    at Azure.Identity.ManagedIdentityClient.AuthenticateCoreAsync(Boolean async, TokenRequestContext context, CancellationToken cancellationToken)
[2024-04-04T11:20:59.582Z]    at Azure.Identity.ManagedIdentityClient.AppTokenProviderImpl(AppTokenProviderParameters parameters)
[2024-04-04T11:20:59.583Z]    at Microsoft.Identity.Client.Internal.Requests.ClientCredentialRequest.SendTokenRequestToAppTokenProviderAsync(ILoggerAdapter logger, CancellationToken cancellationToken)
[2024-04-04T11:20:59.583Z]    at Microsoft.Identity.Client.Internal.Requests.ClientCredentialRequest.GetAccessTokenAsync(CancellationToken cancellationToken, ILoggerAdapter logger)
[2024-04-04T11:20:59.584Z]    at Microsoft.Identity.Client.Internal.Requests.ClientCredentialRequest.ExecuteAsync(CancellationToken cancellationToken)
[2024-04-04T11:20:59.585Z]    at Microsoft.Identity.Client.Internal.Requests.RequestBase.RunAsync(CancellationToken cancellationToken)

My local config for service bus is:
"ServiceBusTriggerConnection__fullyQualifiedNamespace": "xxx-yyy-local.servicebus.windows.net",

The example function signature where we see this:
[Function(nameof(DeleteContentFunction))]public async Task Run([ServiceBusTrigger("%DeleteContentTopic%", "%DeleteContentSubscription%", Connection = "ServiceBusTriggerConnection")] string messageString)

We aren't sure why we get this error, but I confirmed that it's showing up only in case of SB Trigger and managed identity.

Steps to reproduce

Run function locally.

@mpec mpec added the bug Something isn't working label Apr 4, 2024
@liliankasem liliankasem added potential-bug Items opened using the bug report template, not yet triaged and confirmed as a bug and removed bug Something isn't working labels Apr 18, 2024
@enijburg
Copy link

enijburg commented Apr 26, 2024

I can confirm this issue is happening in all of our .NET isolated function apps created with .NET 8 when running locally.
It does not matter if we use ConfigureFunctionsWorkerDefaults or ConfigureFunctionsWebApplication.

@gitFire001
Copy link

The issue is happening even with the Python functions running locally.

@adae-palfinger
Copy link

Also having this issue

@ThomasDejbjerg
Copy link

ThomasDejbjerg commented May 30, 2024

I can confirm that this also happens on our .NET isolated function apps, and that setting ExcludeManageIdentity do not change the outcome, it still tries to get the token from ManagedIdentity.

@enzosambucetti
Copy link

I can also confirm that is happening to us, in isolated mode, net 8.0, with ConfigureFunctionsWebApplication() and ConfigureFunctionsWorkerDefaults().
Any ideas?

@ibis7
Copy link

ibis7 commented Jun 18, 2024

Also having this issue running Az Function locally

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
extensions: service-bus feature: identity potential-bug Items opened using the bug report template, not yet triaged and confirmed as a bug
Projects
None yet
Development

No branches or pull requests

9 participants