1

I tried creating a simple Azure Functions App through the UI both on Linux and Windows machines and it works. However having a simple proxies configuration seems to be completely ignored. It doesn't work locally either using the provided Docker base image.

The app is using the Node v12 runtime on the latest azure functions runtime ~3, all defaults:

hosts.json

{
  "version": "2.0",
  "extensions": {
    "http": {
      "routePrefix": ""
    }
  },
  "functions": [ "hello" ]
}

hello/function.json

{
  "disabled": false,
  "bindings": [
    {
      "type": "httpTrigger",
      "direction": "in",
      "name": "req",
      "methods": ["get", "post"],
      "route": "/bar",
      "authLevel": "anonymous"
    },
    {
      "type": "http",
      "direction": "out",
      "name": "$return"
    }
  ]
}

hello/index.js

module.exports = async (context, req) => {
  return {status: 200, body: 'ok'}
}

proxies.json

{
  "$schema": "http://json.schemastore.org/proxies",
  "proxies": {
    "something": {
      "matchCondition": {
        "route": "/foo",
        "methods": [
          "GET",
          "POST"
        ]
      },
      "backendUri": "https://[INSERT APP NAME HERE].azurewebsites.net/bar"
    }
  }
}

Navigating to https://[INSERT APP NAME HERE].azurewebsites.net/bar shows the little ok message on the screen.

Navigating to https://[INSERT APP NAME HERE].azurewebsites.net/foo however returns 404.

I tried numerous other proxy configurations and my assumption at this point is that the proxy configuration is being ignored completely. I'm on the free consumption plan if that makes any difference.

simo
  • 15,078
  • 7
  • 45
  • 59
  • Can you inspect the host startup logs to see if any proxy routes are registered upon app start? As a side note, if your proxy backend uri is in the same app you can use localhost instead of the full address for the app. – Tom Biddulph Jul 16 '20 at 10:18
  • When running it locally I have the `AzureFunctionsJobHost__Logging__Console__IsEnabled` env var set, and it was printing out that the proxy was loaded. It was also trowing errors if I messed up the config somehow. When deployed .. I can't find those logs yet in the UI at least, but the deployment is basically identical to what I have locally. – simo Jul 16 '20 at 11:34
  • 1
    You can find the host logs in azure by using Kudu which is available under the 'Advanced Tools' blade. https://[INSERT APP NAME HERE].scm.azurewebsites.net/api/vfs/LogFiles/Application/Functions/Host/ – Tom Biddulph Jul 16 '20 at 14:28
  • Wow, I just re-created absolutely everything from scratch again using the Web UI, and it worked .. so I guess something was missing, I'll let you know. Obviously that means that the official documentation is out of date or incomplete, because you can't get it working just by following it. Thanks for the above link too, proxies were loaded again similar to what I had locally. – simo Jul 16 '20 at 15:09
  • 1
    Thanks everyone, the issue turned out to be pretty dumb .. I was specifying the `functions` key explicitly in the `hosts.json`. Then I was seeing in the logs that 1 proxy and 1 function were loaded, where the loaded functions had to be 2 instead. And so either removing the `functions` key or explicitly adding the proxy to the list of `functions` to load fixes the issue, because the proxy is a function, but I totally overlooked the debug log messages. I'm going to reach out to the Azure Function Apps team to improve the documentation. – simo Jul 17 '20 at 13:24

0 Answers0