Azure / Azure/azure-functions-host
Function proxy to httptrigger function with parameter returns 500
- Dominant language
- C#
- Stars
- 2k
- Forks
- 482
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 36
Description
If I have a function proxy that takes a simple url parameter and redirects to a function in the same app, the parameter seems to get lost along the way. This feels similar to https://github.com/Azure/azure-functions-host/issues/3593 but that issue seems focused on wildcards, whereas my problem occurs with any parameter. Proxy:ing to a function without any parameters works as expected.
run.csx:
```
using System.Net;
using Microsoft.AspNetCore.Mvc;
public static async Task Run(HttpRequest req, string name, ILogger log)
{
return new OkObjectResult($"Hello: {name}");
}
```
function.json
```
{
"bindings": [
{
"authLevel": "anonymous",
"name": "req",
"type": "httpTrigger",
"direction": "in",
"methods": [
"get",
"post"
],
"route": "test/{name}"
},
{
"name": "$return",
"type": "http",
"direction": "out"
}
]
}
```
proxies.json
```
{
"$schema": "http://json.schemastore.org/proxies",
"proxies": {
"testproxy": {
"matchCondition": {
"route": "alternative/{data}",
"methods": [
"GET",
"POST"
]
},
"backendUri": "http://proxybugdemo.azurewebsites.net/api/test/{data}"
}
}
}
```
[Github Repo with the above files](https://github.com/Zazcallabah/proxybugdemo) connected to https://proxybugdemo.azurewebsites.net
Please provide the following:
- Function App version (1.0 or 2.0): 2
- Function App name: proxybugdemo
- Function name(s) (as appropriate): HttpTrigger1
- Region: West Europe
#### Repro steps
The function http://proxybugdemo.azurewebsites.net/api/test/myname works as expected, but a proxy at http://proxybugdemo.azurewebsites.net/alternative/myname returns 500 with the error message
```
{ "statusCode": 500, "message": "Internal server error", "activityId": "3ad2444e-1390-4f2e-a365-a8b2c9ffd954" }
```
and this in the server log
```
2019-06-27T12:16:32.557 [Information] Executing 'Functions.testproxy' (Reason='This function was programmatically called via the host APIs.', Id=95c61127-3414-4cca-9d5f-1306e8c1ec77)
2019-06-27T12:16:32.562 [Information] Executing request via Azure Function Proxies
2019-06-27T12:16:32.572 [Information] Executing 'Functions.HttpTrigger1' (Reason='This function was programmatically called via the host APIs.', Id=01749705-766a-4b5c-88f3-e24948bba667)
2019-06-27T12:16:32.575 [Error] Executed 'Functions.HttpTrigger1' (Failed, Id=01749705-766a-4b5c-88f3-e24948bba667)Binding data does not contain expected value 'name'.
2019-06-27T12:16:32.712 [Information] Executed 'Functions.testproxy' (Succeeded, Id=95c61127-3414-4cca-9d5f-1306e8c1ec77)
2019-06-27T12:16:32.572 [Information] Executing 'Functions.HttpTrigger1' (Reason='This function was programmatically called via the host APIs.', Id=01749705-766a-4b5c-88f3-e24948bba667)
2019-06-27T12:16:32.620 [Error] Executed 'Functions.HttpTrigger1' (Failed, Id=01749705-766a-4b5c-88f3-e24948bba667)Binding data does not contain expected value 'name'.
2019-06-27T12:16:32.561 [Information] Executing 'Functions.testproxy' (Reason='This function was programmatically called via the host APIs.', Id=95c61127-3414-4cca-9d5f-1306e8c1ec77)
2019-06-27T12:16:32.562 [Information] Executing request via Azure Function Proxies
2019-06-27T12:16:32.712 [Information] Executed 'Functions.testproxy' (Succeeded, Id=95c61127-3414-4cca-9d5f-1306e8c1ec77)
```
#### Expected behavior
The proxy should redirect to the function, and return the expected message including the parameter data.
Contributor guide
Assessment
This issue has not been assessed yet.