Azure Functions - Can I use an HTTP request parameter called "code"

Joseph Jobbings 96 Reputation points
2021-02-18T11:19:38.96+00:00

I want to use an Azure Function to serve as the redirect_uri for an oauth2/authorize request. The oauth2/authorize endpoint will redirect to our Azure function - following successful authentication - and supply an authorization code via a parameter called 'code'. In my Function under development, using the example code generated by the CLI func new ... the HTTP trigger code (typescript/ node js) responds fine to a request like,
http://orange-moss-04231ae03.azurestaticapps.net/api/xyz?name=foo
but changing the request to
http://orange-moss-04231ae03.azurestaticapps.net/api/xyz?code=foo
results in

This page isn’t working
orange-moss-04231ae03.azurestaticapps.net is currently unable to handle this request.
HTTP ERROR 500

Tagging some helpful users in this forum: @dixitaro-MSFT @Jeff Hollan [MSFT]

My questions are

  1. is this behaviour a result of the code parameter being reserved for Azure API Authorization keys? i.e. https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-http-webhook-trigger?tabs=csharp#authorization-keys
  2. if the answer to my question (1) is "yes the Function bombs out because the code= parameter value is not known to Azure" then is there a way i can configure my Azure Function to get around this - i.e so that the oauth2 request code parameter value is successfully delivered to my function code?
Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
4,679 questions
0 comments No comments
{count} votes

Accepted answer
  1. Joseph Jobbings 96 Reputation points
    2021-02-22T11:55:05.447+00:00

    Thanks @Pramod Vasanth for you reply.
    Could you share how you confirmed that my use case should work? My Function is running in Azure Static Web Apps. My function.json already specifies, { "bindings": [ {"authLevel": "anonymous", ...}

    Since posting this question last week I've heard back from Microsoft, confirming this is an known issue see https://github.com/Azure/static-web-apps/issues/165, there is no date for when this will be fixed but the github issue includes a workaround.


1 additional answer

Sort by: Most helpful
  1. Pramod Valavala 20,611 Reputation points Microsoft Employee
    2021-02-19T08:01:44.737+00:00

    If the Authentication Level is set to Anonymous, the code query parameter can be used as required in your case, which I can confirm works.

    0 comments No comments