![](/img/trans.png)
[英]Azure Durable function : Runtime Exception with non-None return value
[英]Trying to trigger an url from azure functions using python, errored saying “without a $return binding returned a non-None value”
下面是代码,
import logging
import json
import urllib.request
import urllib.parse
import azure.functions as func
def main(myblob: func.InputStream):
logging.info(f"Python blob trigger function processed blob \n"
f"Name: {myblob.name}\n"
f"Blob Size: {myblob.length} bytes")
response = urllib.request.urlopen("http://example.com:5000/processing")
return {
'statusCode': 200,
'body': json.dumps(response.read().decode('utf-8'))
}
错误:结果:失败异常:RuntimeError:function 'abc' 没有 $return 绑定返回非无值堆栈:文件“/azure-functions-host/workers/python/3.7/LINUX/X64/azure_functions_worker/dispatcher.py ",第 341 行,在 _handle__invocation_request f'function {fi.name.r} 中没有 $return 绑定'。 相同的代码适用于 lambda。请帮助我调试 azure 函数。
function.json
{
"scriptFile": "__init__.py",
"bindings": [
{
"name": "myblob",
"type": "blobTrigger",
"direction": "in",
"path": "sourcemetadata/{name}",
"connection": "AzureWebJobsStorage"
}
]
}
In the Azure function, if you use return
in the function app code, it means that you want to use output binding. 但是你没有在 function.json 中定义它。 请定义它。 有关更多详细信息,请参阅此处和此处
例如
我使用带有 blob 触发器的进程 blob,并将消息发送到带有队列 output 绑定的 azure 队列
{
"scriptFile": "__init__.py",
"bindings": [
{
"name": "myblob",
"type": "blobTrigger",
"direction": "in",
"path": "test/{name}.csv",
"connection": "AzureWebJobsStorage"
},
{
"name": "$return",
"direction": "out",
"type": "queue",
"queueName": "outqueue",
"connection": "AzureWebJobsStorage"
}
]
}
async def main(myblob: func.InputStream) :
logging.info(f"Python blob trigger function processed blob \n"
f"Name: {myblob.name}\n")
return "OK"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.