1

我有一个队列触发器,它读取一个 gis 要素图层并在它写回门户时对其进行处理。它似乎工作正常,除了消息没有记录到 outqueue 中。我说它工作正常,因为我可以在 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)
    

我的函数.host

{
  "scriptFile": "__init__.py",
  "bindings": [
    {
      "name": "msg",
      "type": "queueTrigger",
      "direction": "in",
      "queueName": "outqueue12",
      "connection": "storageaccountautom92bb_STORAGE"
    },
    {
      "type": "http",
      "direction": "out",
      "name": "$return"
    },
    {
    "type": "queue",
    "direction": "out",
    "name": "msg1",
    "queueName": "outqueue13",
    "connection": "AzureStorageQueuesConnectionString"
    }
  ]
}
4

1 回答 1

1

绑定接受字符串类型和字节类型,所以下面的代码应该可以工作:

__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"
    }
  ]
}
于 2020-12-22T08:38:20.627 回答