question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Get target route parameters when using proxies

See original GitHub issue

Investigative information

Please provide the following:

  • Function App version: 2.0.12285
  • Python worker version: 1.0.0b3
  • Function name: test-list

Repro steps

  1. Create sample function based on source code below
  2. Hit API /api/list_proxy/group_1/product_a?validate=true
  3. It should be routed to /api/list/

Expected behavior

I expected to have route parameter from the target function and some additional information from source proxy in another property:

{
  "route_params": {
    "group": "group_1",
    "product": "product_a"
  },
  "params": {
    "validate": "true"
  }
}

Actual behavior

Instead I have the route params from the original proxy:

{
  "method": "POST",
  "url": "http://localhost:7071/api/list/group_1/product_a?validate=true",
  "headers": {
    "connection": "keep-alive"
  },
  "route_params": {
    "restOfPath": "group_1/product_a"
  },
  "params": {
    "validate": "true"
  },
  "get_body": ""
}

Known workarounds

We will add logic to our Function App to reconstruct the route params by using the URL and route from function.json.

Related information

Provide any related information

  • Sample source files
Source
## function.json
{
  "scriptFile": "__init_py",
  "bindings": [
    {
      "authLevel": "anonymous",
      "type": "httpTrigger",
      "direction": "in",
      "name": "request",
      "methods": [
        "post"
      ],
      "route": "list/{group}/{product}"
    },
    {
      "type": "http",
      "direction": "out",
      "name": "$return"
    }
  ]
}
## proxies.json
{
  "proxies": {
    "internal-routing": {
      "matchCondition": {
        "route": "/api/list_proxy/{*restOfPath}"
       },
       "backendUri": "https://localhost/api/list/{restOfPath}"
      },
  }
}
## __init_py
def main(request: azure.functions.HttpRequest) -> azure.functions.HttpResponse:

    route_params = {}
    if hasattr(request, 'route_params'):
        route_params = dict(request.route_params)
    params = {}
    if hasattr(request, 'params'):
        params = dict(request.params)
    headers = dict(request.headers)
    return json.dumps({
        'method': request.method,
        'url': request.url,
        'headers': headers,
        'route_params': route_params,
        'params': params,
        'get_body': request.get_body().decode(),
    })

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
alexkarcher-msftcommented, Feb 27, 2019

Cool! I was able to repo this issue on my own with a JS function, and setting the app setting AZURE_FUNCTION_PROXY_DISABLE_LOCAL_CALL to true restored the correct behavior.

We’re going to take a look at the root cause for this, but that app setting should mitigate the issue for the time being 🙂

0reactions
jeffhollancommented, Feb 27, 2019

Thanks @alexkarcher-msft and @eduardomourar for investigation. Closing this one and will track work item here: https://github.com/Azure/azure-functions-host/issues/3593

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to map the target endpoint URL parameters to the proxy url
Hi created a spec and proxy as shown in the below code with the base path as /generate_otp and target endpoint as http://control.msg91.com....
Read more >
Angular proxy config; proxying URL get parameters
For troubleshooting, I created a simple server with route handler for GET /address/cities and using your exact proxy configuration I got the ...
Read more >
Using target proxies | Load Balancing - Google Cloud
Target proxies are referenced by one or more forwarding rules. Target proxies terminate connections from the client and creates new connections to the...
Read more >
Understanding routes | Apigee Edge
Determining the URL of the API proxy endpoint; Determining the URL of the target endpoint. Direct URL; Single target; Conditional targets; Null route....
Read more >
how to pass new parameters to initial request #256 - GitHub
I'm trying to use the proxyReqBodyDecorator you mentioned but the value is not actually getting added to the request body that goes out...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found