azure-functions-core-tools icon indicating copy to clipboard operation
azure-functions-core-tools copied to clipboard

Call Function from Logic App Standard gives error BadRequest. Http request failed: 'An item with the same key has already been added. Key: Code'.

Open anthonywhite opened this issue 3 years ago • 7 comments

Using VS Code and Azure Logic App Standard extension to build a Standard Logic App locally. Using Azure Functions Core Tools for local runtime: Core Tools Version: 3.0.3904 Commit hash: c345f7140a8f968c5dbc621f8a8374d8e3234206 (64-bit) Function Runtime Version: 3.3.1.0

Calling an Azure Function deployed in Azure from the local Logic App, I get the error below. The function is still invoked and runs OK, but the Logic App Run Instance UI reports a BadRequest on the function invoke.

image

Job warning: correlationId='8b7c9843-2534-4e87-b8f4-520665bacdf2', operationName='FlowHttpEngine.GetErrorMessageFromException', jobPartition='C3B3EB386CA441A59ECADDB92E819CE9:2D08585654968131582416188788881CU00', jobId='08585654968131582416188788881CU00', message='Http request failed with exception of type 'ArgumentException' and message exception: 'An item with the same key has already been added. Key: Code'.', exception='System.ArgumentException: An item with the same key has already been added. Key: Code
[2021-11-05T11:01:25.209Z]    at System.Collections.Generic.Dictionary`2.TryInsert(TKey key, TValue value, InsertionBehavior behavior)
[2021-11-05T11:01:25.210Z]    at System.Collections.Generic.Dictionary`2.System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<TKey,TValue>>.Add(KeyValuePair`2 keyValuePair)
[2021-11-05T11:01:25.211Z]    at Microsoft.WindowsAzure.ResourceStack.Common.Extensions.ICollectionExtensions.AddRange[T](ICollection`1 source, IEnumerable`1 values)
[2021-11-05T11:01:25.212Z]    at Microsoft.Azure.Workflows.Data.Extensions.UriExtensions.WithAdditionalQueryParameters(Uri uri, QueryStringDictionary queryParameters)
[2021-11-05T11:01:25.213Z]    at Microsoft.Azure.Workflows.Data.Extensions.HttpRequestMessageExtensions.AddQueryStringAuth(HttpRequestMessage request, HttpQueryStringAuthentication authentication, ICommonEventSource logger)
[2021-11-05T11:01:25.213Z]    at Microsoft.Azure.Workflows.Data.Extensions.HttpRequestMessageExtensions.PopulateRequestAuthentication(HttpRequestMessage request, HttpAuthentication authentication, OAuthTokenCacheProvider tokenProvider, ICommonEventSource logger)
[2021-11-05T11:01:25.214Z]    at Microsoft.Azure.Workflows.Data.Engines.FlowHttpEngine.CallHttpEndpoint(ICommonEventSource logger, FlowAuthentication flowAuthentication, HttpAuthentication httpAuthentication, Nullable`1 operationOptions, HttpRequestMessage request, LoadBalancedHttpClientConfiguration configuration, OAuthTokenCacheProvider tokenProvider, CancellationToken cancellationToken, String operationName, Boolean allowTrustedRootCertificateThumbprints)
[2021-11-05T11:01:25.215Z]    at Microsoft.Azure.Workflows.Worker.Jobs.FunctionActionJob.OnExecuteRetryableAction(FlowRunActionExecutionContext actionExecutionContext, FunctionActionInput actionInput, FlowOperationState operationState)', organizationId='', activityVector='IN.09', additionalProperties='', extensionVersion='1.0.0.0', siteName='UNDEFINED_SITE_NAME', slotName='', activityId='bffa8923-c3b7-443d-8f02-fcb09a9ffcfd'.

anthonywhite avatar Nov 05 '21 12:11 anthonywhite

Update: the same behaviour happens in the Azure portal with a Standard Logic App created there, calling the Azure Function.

NB This same Azure Function invokes without error from a Consumption Logic App

anthonywhite avatar Nov 05 '21 15:11 anthonywhite

@michaelpeng36 Any news here? I'm facing the same issue when trying to call a durable azure function from a logic app.

sven5 avatar Jan 03 '22 20:01 sven5

Microsoft support told me this is an acknowledged bug and as fix is on the way...

anthonywhite avatar Jan 03 '22 21:01 anthonywhite

I'm currently working around this by using plain HTTP request instead of Azure function activity.

sven5 avatar Jan 03 '22 21:01 sven5

I'm currently working around this by using plain HTTP request instead of Azure function activity.

Me too.

anthonywhite avatar Jan 03 '22 21:01 anthonywhite

Any further news on when this will be fixed?

@sven5 and @anthonywhite - when you say you use plain HTTP, did you mean the standard action? And were you calling a durable function with this?

daverobinson64 avatar Jun 13 '22 15:06 daverobinson64

@daverobinson64 yes we were calling durable functions. Now using standard HTTP action

anthonywhite avatar Jun 17 '22 16:06 anthonywhite