azureazure-functionsazure-function-app-proxy

Azure function - send all requests to the same function


I'm trying to set up Azure function so that all requests are sent to the same function. The proxies.json file is extremely simple:

{
  "$schema": "http://json.schemastore.org/proxies",
  "proxies": {
    "Root URI to Redirector Trigger Function": {
      "matchCondition": {
        "route": "/{*path}",
        "methods": [
          "GET",
          "POST"
        ]
      },
      "backendUri": "http://%WEBSITE_HOSTNAME%/myfunc"
    }
  }
}

So far so good, but when a request is sent, the proxied requests ends up being processed by the proxy again - ending in an infinite loop.

How can I specify in my proxies to proxy all requests accept those to /myfunc resource?


Solution

  • I finally solved the issue, although it's not very elegant. My proxies.json now looks like this:

    {
      "$schema": "http://json.schemastore.org/proxies",
      "proxies": {
        "Root URI to Redirector Trigger Function": {
          "matchCondition": {
            "route": "/{path}",
            "methods": [
              "GET",
              "POST"
            ]
          },
          "backendUri": "http://%WEBSITE_HOSTNAME%/"
        }
      }
    }
    

    I also edited my function.json to have `"route": "/". Now all calls to anything other than root are proxied to my function. Calls to route end up going to the function directly (and need to be handled separately).