首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >将QueueTrigger写入队列-Python

将QueueTrigger写入队列-Python
EN

Stack Overflow用户
提问于 2020-12-22 08:36:03
回答 1查看 134关注 0票数 1

我有一个队列触发器,它读取gis特性层并在它写回门户时处理它。它似乎正常工作,除非消息没有登录到外部队列。我说它可以正常工作,因为我可以看到gis特性保护器正确地写在gis门户上。我想我的装订不太好。我不一定需要将结果数据写入回。我所需要的只是保存在外部队列上的任何消息,以便为其他进程提供资源。为了隐私起见,不能在这里发布完整的代码,但是我的主文件(init_py)可以被认为是:

代码语言:javascript
复制
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

代码语言:javascript
复制
{
  "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"
    }
  ]
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-12-22 08:38:20

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

__init__.py

代码语言:javascript
复制
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

代码语言:javascript
复制
{
  "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"
    }
  ]
}
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/65405476

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档