You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Function name(s) (as appropriate): Azure Functions Core Tools
Core Tools version: 3.0.3160
Repro steps
1./ Create a proxies.json file stored in the root of an azure functions' project (according to the following sentence found in https://docs.microsoft.com/en-us/azure/azure-functions/functions-proxies: "The proxies that you configure are stored in a proxies.json file, which is located in the root of a function app directory. You can manually edit this file and deploy it as part of your app when you use any of the deployment methods that Functions supports.").
2./ Copy the following value in this file (example found in https://docs.microsoft.com/en-us/azure/azure-functions/functions-create-serverless-api):
{
"$schema": "http://json.schemastore.org/proxies",
"proxies": {
"GetUserByName" : {
"matchCondition": {
"methods": [ "GET" ],
"route": "/api/users/{username}"
},
"responseOverrides": {
"response.statusCode": "200",
"response.headers.Content-Type" : "application/json",
"response.body": {
"name": "{username}",
"description": "Awesome developer and master of serverless APIs",
"skills": [
"Serverless",
"APIs",
"Azure",
"Cloud"
]
}
}
}
}
}
3./ Run your project (I use vscode and I click on the button "Attach to Python Functions" to do so)
Expected behavior
You should get a list with your Functions name, the CRUD operations they support (GET, POST, ...), and the URL associated to it.
Then you should get a message
"For detailes output, run func with --verbose flag. Host lock lease acquired by instance ID 'XXXX'. Worker process started and initialized."
Actual behavior
The proxies name stored in proxies.json are appearing along with the Functions name, so in our example case GetUserByName is added in the list.
After the message "Worker process started and initialized" appears after a short moment you should see an error popping saying "Worker failed to function id XXX. Result: Failure. Exception: IndexError: tuple index out of range."
Known workarounds
The worker is failing with function GetUserByName which is a proxy.
In order to discover that I navigated to the place the error is happening which location is AppData\Roaming\npm\node_modules\azure-functions-core-tools\bin\workers\python\3.7/WINDOWS/x64\azure_functions-worker\loader.py
l63, of the loader.py file, it is trying to assign the following:
last_part = rel_script_path.parts[-1]
parts is the tuple raising the out of range exception, this tuple should be filled with the parameter scriptFile when creating a function in function.json, please find the example below which I got on https://docs.microsoft.com/en-us/azure/azure-functions/functions-reference-python:
{
"scriptFile": "init.py",
"bindings": [
{
"authLevel": "function",
"type": "httpTrigger",
"direction": "in",
"name": "req",
"methods": [
"get",
"post"
]
},
{
"type": "http",
"direction": "out",
"name": "$return"
}
]
}
In proxies.json, we don't define such a scriptFile parameter, and this is why the exception is raised.
Thanks @chapoub for raising this issue. Confirmed that this issue happens if there's a proxies.json in the project root. It will raise an error.
Result: Failure
Exception: IndexError: tuple index out of range
Stack: File "\azure-functions-core-tools\bin\workers\python\3.7\WINDOWS\X64\azure_functions_worker\dispatcher.py", line 275, in _handle__function_load_request
func_request.metadata.entry_point)
File "\azure-functions-core-tools\bin\workers\python\3.7\WINDOWS\X64\azure_functions_worker\utils\wrappers.py", line 32, in call
return func(*args, **kwargs)
File "\azure-functions-core-tools\bin\workers\python\3.7\WINDOWS\X64\azure_functions_worker\loader.py", line 63, in load_function
last_part = rel_script_path.parts[-1]
The function is still accessible, but since a proxy is missing scriptFile field in function.json, the loader fails to handle the proxy loading (I think it should be a no-op since the proxy shares the same code as the HttpTrigger).
I attach the repo in the following link, may need further investigation before implementing a fix in Python Worker. PythonProxy.zip
Investigative information
Repro steps
1./ Create a proxies.json file stored in the root of an azure functions' project (according to the following sentence found in https://docs.microsoft.com/en-us/azure/azure-functions/functions-proxies: "The proxies that you configure are stored in a proxies.json file, which is located in the root of a function app directory. You can manually edit this file and deploy it as part of your app when you use any of the deployment methods that Functions supports.").
2./ Copy the following value in this file (example found in https://docs.microsoft.com/en-us/azure/azure-functions/functions-create-serverless-api):
{
"$schema": "http://json.schemastore.org/proxies",
"proxies": {
"GetUserByName" : {
"matchCondition": {
"methods": [ "GET" ],
"route": "/api/users/{username}"
},
"responseOverrides": {
"response.statusCode": "200",
"response.headers.Content-Type" : "application/json",
"response.body": {
"name": "{username}",
"description": "Awesome developer and master of serverless APIs",
"skills": [
"Serverless",
"APIs",
"Azure",
"Cloud"
]
}
}
}
}
}
3./ Run your project (I use vscode and I click on the button "Attach to Python Functions" to do so)
Expected behavior
You should get a list with your Functions name, the CRUD operations they support (GET, POST, ...), and the URL associated to it.
Then you should get a message
"For detailes output, run func with --verbose flag. Host lock lease acquired by instance ID 'XXXX'. Worker process started and initialized."
Actual behavior
The proxies name stored in proxies.json are appearing along with the Functions name, so in our example case GetUserByName is added in the list.
After the message "Worker process started and initialized" appears after a short moment you should see an error popping saying "Worker failed to function id XXX. Result: Failure. Exception: IndexError: tuple index out of range."
Known workarounds
The worker is failing with function GetUserByName which is a proxy.
In order to discover that I navigated to the place the error is happening which location is
AppData\Roaming\npm\node_modules\azure-functions-core-tools\bin\workers\python\3.7/WINDOWS/x64\azure_functions-worker\loader.py
l63, of the loader.py file, it is trying to assign the following:
last_part = rel_script_path.parts[-1]
parts is the tuple raising the out of range exception, this tuple should be filled with the parameter scriptFile when creating a function in function.json, please find the example below which I got on https://docs.microsoft.com/en-us/azure/azure-functions/functions-reference-python:
{
"scriptFile": "init.py",
"bindings": [
{
"authLevel": "function",
"type": "httpTrigger",
"direction": "in",
"name": "req",
"methods": [
"get",
"post"
]
},
{
"type": "http",
"direction": "out",
"name": "$return"
}
]
}
In proxies.json, we don't define such a scriptFile parameter, and this is why the exception is raised.
Contents of the requirements.txt file:
azure-functions
azure.identity
azure-keyvault-secrets
Related information
https://docs.microsoft.com/en-us/azure/azure-functions/functions-proxies
https://docs.microsoft.com/en-us/azure/azure-functions/functions-create-serverless-api
https://docs.microsoft.com/en-us/azure/azure-functions/functions-reference-python
The text was updated successfully, but these errors were encountered: