0

Azure Functions Proxies support the usage of AppSettings in the backendUri and request.headers in requestOverrides.

{
   "$schema": "http://json.schemastore.org/proxies",
   "proxies": {
      "myProxyName": {
         "matchCondition": {
            "route": "/"
         },
         "backendUri": "%MY_APP_SETTING%",
         "requestOverrides": {
            "backend.request.headers.myCustomHeader":"request.headers.host"
         } 
      }
   }
}

Question: is it possible to use a request.header value in the backendUri?

{
   "$schema": "http://json.schemastore.org/proxies",
   "proxies": {
      "myProxyName": {
         "matchCondition": {
            "route": "/"
         },
         "backendUri": "%MY_APP_SETTING%/{request.headers.my_header_value}"
      }
   }
}
Florian Eckert
  • 301
  • 2
  • 9

1 Answers1

0

Yes it is Possible to use request.header value in backend uri.

Below is the sample code with related information

"Example show how you can",
                "1. Read headers (request.header.<<header name>>), segements({xyz}) and querystring (request.querystring.<<param name>>) from input request ",
                "2. Set the backend headers (backend.request.header.<<header name>>, querystring (backend.request.querystring.<<param name>>)",
                "3. Set the response headers (repsonse.header.<<header name>>), status (response.status)",
                "4. You can use AppSettings in your proxy definitons by enclosing theam with %% For e.g.%APP_SETTING_NAME%",
                "Sample input: https://<<yourhostname>>/test2/1?operation=posts&version=1.2"
            ],
            "matchCondition": {
                "methods": [
                    "GET"
                ],
                "route": "/test2/{uid}"
            },
            "backendUri": "https://jsonplaceholder.typicode.com/users/{uid}/{request.querystring.operation}",
            "requestOverrides": {
                "backend.request.querystring.newkey": "request.header.me",
                "backend.request.querystring.userId": "{uid}",
                "backend.request.querystring.token": "%MY_CUSTOM_TOKEN%",
                "backend.request.header.appname": "Appname is %CUSTOM_SETTING%",
                "backend.request.header.myheaderv": "request.querystring.version"
            }

Also check the Function Proxy and Backend URI with the related discussions.

SaiSakethGuduru
  • 2,218
  • 1
  • 5
  • 15