Python Azure函数队列绑定

2024-09-29 18:55:57 发布

您现在位置:Python中文网/ 问答频道 /正文

如何在pythonazure函数中使用队列输出绑定。这是我的函数.json在

{
  "type": "queueTrigger",
  "name": "myQueue", 
  "direction": "out",
  "queueName": "qname",
  "connection": "CONNECTION"
}

我的代码以这个结尾

^{pr2}$

我只是遇到一个错误,无法打开QueueAttribute进行写入。任何人都有这方面的经验,因为根本没有文档。在


Tags: 函数代码namejson队列typeconnectionout
1条回答
网友
1楼 · 发布于 2024-09-29 18:55:57

我尝试在pythonazure函数中使用队列存储输出绑定,它对我很好,我没有重现您的问题。在

你可以参考我的步骤。在

步骤1:为Python创建HttpTrigger。在

enter image description here

步骤2:配置队列存储输出绑定,如下所示。在

enter image description here

第三步:检查运行.py代码和函数.json在

运行.py

import os
import json

postreqdata = json.loads(open(os.environ['req']).read())
response = open(os.environ['res'], 'w')
response.write("hello world from "+postreqdata['name'])
response.close()

函数.json

^{pr2}$

步骤4:运行函数并检查存储队列消息。在

enter image description here

您也可以引用official tutorialQueue Storage Output Binding Configuration。在

希望对你有帮助。在

相关问题 更多 >

    热门问题