I use proxies for a SPA, and to handle OAuth2 authorization code grant flow. When my function app receives a redirect with the code, state, and id_token query params, I was noticing that the function wouldn't even execute. There is no error in the logs either. So I tested by truncating the value of the query params and it turns out that if the length exceeds 2102, then the routing doesn't work for some reason.
Note: I have provided information of a normal execution of my function. When the problem occurs, there is actually nothing in the logs that would indicate this problem. Furthermore, Proxy-Trace-Enabled header attribute doesn't help either because no function has executed.
After step 2, the proxy rule would be invoked and the function should execute.
The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.Use the request body instead of query-params.
EDIT: I wanted to clarify that the length I am talking about is the total length of the URL with the query params, and not just the length of the query params put together.
EDIT2: Updated the notes under Actual Behavior.
How are you invoking the Function App? Are you using Internet Explorer?
Chrome. I'll try other browsers as well. Didn't think this would be a browser issue but I can test and rule that out.
IE has a max URL character limit of 2083.
If you are using Chrome, then it should work.
I believe this cap is also enforced on the server-side (IIS) by default. I will need to check and confirm later. In general though, the best practice is to limit your URL length to be cross-browser compatible.
The service I rely on uses AAD as its OAuth2 AuthN server. I have no control over the length of the authorization code it generates, and the id_token is a standard JWT.
Also, thank you for your time looking into this.
FYI -- In the functions web.config we set the max url to 4096: https://github.com/Azure/azure-webjobs-sdk-script/blob/v1.x/src/WebJobs.Script.WebHost/Web.config#L38.
@safihamid -- could Proxies be affecting this somehow?
@tohling I can confirm that I have this issue in FF 57 and Chrome. Unfortunately, I couldn't test on Edge and IE because my code change to use form_post instead of query string args took effect.
Also, I must say that this doesn't seem like a browser limitation to me. It seems that the server is rejecting my request by responding with a 404 and the response body has The resource you are looking for has been removed, had its name changed, or is temporarily unavailable..
hmm the request doesn't even make it to proxy. looks like the default max querystring length in IIS is 2048. https://docs.microsoft.com/en-us/iis/configuration/system.webServer/security/requestFiltering/requestLimits/ if this needs to be updated we will need to increase it for function apps.
@safihamid I think you are right. I just checked the length of the querystring alone in the URL that was failing, and it is 2048 characters long (not including the leading ?). If I delete just one character from it, my proxy rule is executed and the function is executed after that just fine.
OK I sent a PR to increase the querystring max length to 4096.
@safihamid that's awesome! Will this fix land in the v1.0 runtime?
Yes it will land in v1.0
@safihamid I see that your PR is now merged and was just wondering when your fix would be released out to all of the regions of Azure Functions? My function app is in the West US.
@praneetloke it will be in the next runtime release of Functions. It will be out in a week or two.
Ok that's good. I'll be on the lookout for it then. Thank you, @safihamid.
@safihamid I see that your fix was released with the release 1.0.11510. I verified that the portal now shows the same version number for runtime version under the Function App Settings. However, I still have the problem described in this issue.
My app settings has the FUNCTIONS_EXTENSION_VERSION setting with the value ~1. I even restarted/redeployed the code for the function app. The only thing I haven't done is to tear down and setup the entire function app. Is there something else I should do for your fix to be effective in my function app?
EDIT: here's a screenshot of the Function App Settings page.

@praneetloke hmm are you sure you are hitting the exact same issue? Is your function app running on only one instance?
Yeah it's a Dynamic consumption plan. I tested by appending a 2048-long query-string and invoked my function and it works. But when I add even a single character to go over 2048, it doesn't work. Same thing that I did previously. I can try to create a new function app and see if it works there.
@safihamid I created a new function app and reproduced this issue with that as well. I setup a proxy rule that forwarded requests to my function to mimic what I am doing in the other function app and still reproduced it. I also removed the proxy and tried to invoke the function with a 2049 character-long query string and it didn't work. Both function apps are on the runtime version 1.0.11510 according to the portal.
@praneetloke Is your URL any different than what we have in our tests? Our test is passing fine. look for LongQueryString() @ https://github.com/Azure/azure-webjobs-sdk-script/blob/v1.x/test/WebJobs.Script.Tests.Integration/ProxyEndToEndTests.cs
@safihamid I just took the query string value from LongQueryString() and used it with my function URL and I can reproduce the error. If I reduce the length of the query string to 2048 or less, it works just fine.
@praneetloke I tested this again on a new function app and it's working for me. can you please send me your function app name, proxies.json and the url your are using? you can email me directly at hamids at microsoft dot com
This is fixed now with the runtime version 1.0.11535.0. I just tested a very length query-string against my function app and the proxy rule was handled correctly.
hi my function app v1 still meet this issue, I try to set a maxAllowedContentLength parameter in web.config, but it seems that doesn鈥檛 work.
<security>
<requestFiltering allowDoubleEscaping="true">
<requestLimits maxAllowedContentLength="104857600" maxUrl="8192" maxQueryString="4096"/>
</requestFiltering>
</security>
FUNCTIONS_EXTENSION_VERSION =~1
thanks .