问题描述
我有一个队列触发器,它读取 gis 要素图层并在它写回门户时对其进行处理。除了消息没有登录到输出队列之外,它似乎工作正常。我说它工作正常,因为我可以在 gis 门户上看到正确编写的 gis 要素层。我怀疑我的绑定不好。我不需要一定要回写结果数据帧。我所需要的只是存放在输出队列上的任何消息,以便为其他进程提供资源。不能在这里发布完整的代码以保护隐私,但我的主文件 (init_py) 可以被认为是:
import logging
import json
import pandas
def main(msg: func.QueueMessage,msg1: func.Out[str]) -> None:
logging.info('Python queue trigger function processed a queue item: %s',msg.get_body().decode('utf-8'))
x=1
y=1
df=x=1
msg1.set(df)
我的function.host
{
"scriptFile": "__init__.py","bindings": [
{
"name": "msg","type": "queueTrigger","direction": "in","queueName": "outqueue12","connection": "storageaccountautom92bb_STORAGE"
},{
"type": "http","direction": "out","name": "$return"
},{
"type": "queue","name": "msg1","queueName": "outqueue13","connection": "AzureStorageQueuesConnectionString"
}
]
}
解决方法
绑定接受字符串类型和字节类型,所以下面的代码应该可以工作:
__init__.py
import logging
import azure.functions as func
def main(msg: func.QueueMessage,msg2: func.Out[str]) -> None:
num1 = 1
num2 = 1
str1 = num1+num2
msg2.set(str(str1))
function.json
{
"scriptFile": "__init__.py","bindings": [
{
"name": "msg","type": "queueTrigger","direction": "in","queueName": "test1","connection": "0730bowmanwindow_STORAGE"
},{
"type": "queue","direction": "out","name": "msg2","queueName": "test2","connection": "0730bowmanwindow_STORAGE"
}
]
}