简体   繁体   English

Azure HTTPtrigger函数未写入Azure存储队列

[英]Azure HTTPtrigger function not writing to Azure Storage Queue

I am expecting the below code to take a JSON body from func.HttpRequest , write that message to an Azure Storage Queue and then return a success message to the caller. 我期望以下代码从func.HttpRequest获取JSON主体,将该消息写入Azure存储队列,然后将成功消息返回给调用者。 This works except that my Storage Queue is blank. 除了我的存储队列是空白之外,这是有效的。

import logging

import azure.functions as func


def main(req: func.HttpRequest,
         orders: func.Out[func.QueueMessage]) -> func.HttpResponse:


    logging.info('Python HTTP trigger function processed a request.')
    message = req.get_json()
    logging.info(message)
    orders.set(message)
    return func.HttpResponse(
        body=”success”,
        status_code=200
    )

Function.json Function.json

{
  "scriptFile": "__init__.py",
  "bindings": [
    {
      "authLevel": "anonymous",
      "type": "httpTrigger",
      "direction": "in",
      "name": "req",
      "methods": [
        "get",
        "post"
      ]
    },
    {
      "type": "http",
      "direction": "out",
      "name": "$return"
    },
  {
    "type": "queue",
    "direction": "out",
    "name": "orders",
    "queueName": "preprocess",
    "connection": "orders_STORAGE"
  }
  ]
}

Local.settings.json Local.settings.json

{
  "IsEncrypted": false,
  "Values": {
    "FUNCTIONS_ER_RUNTIME": "python",
    "AzureWebJobsStorage": "AzureWebJobsStorage",
    "orders_STORAGE": "DefaultEndpointsProtocol=https;AccountName=orders;AccountKey=*****;EndpointSuffix=core.windows.net"
  }
}

Terminal output: 终端输出:

… [4/17/2019 5:54:39 PM] Executing 'Functions.QueueTrigger' (Reason='New queue message detected on 'preprocess'.', Id=f27fd7d1-1ace-****-****-00fb021c9ca4) ... [4/17/2019 5:54:39 PM]执行'Functions.QueueTrigger'(Reason ='在'preprocess'上检测到新队列消息。',Id = f27fd7d1-1ace - **** - **** -00fb021c9ca4)

[4/17/2019 5:54:39 PM] Trigger Details: MessageId: d28f96c5-****-****-9191-93f96a4423de, DequeueCount: 1, InsertionTime: 4/17/2019 5:54:35 PM +00:00 [4/17/2019 5:54:39 PM]触发详情:MessageId:d28f96c5 - **** - **** - 9191-93f96a4423de,DequeueCount:1,InsertionTime:4/17/2019 5:54:35 PM +00:00

[4/17/2019 5:54:39 PM] INFO: Received FunctionInvocationRequest, request ID: 5bf59a45-****-****-9705-173d9635ca94, function ID: fa626dc9-****-****-a59b-6a48f08d87e1, invocation ID: f27fd7d1-1ace-****-****-00fb021c9ca4 [4/17/2019 5:54:39 PM]信息:收到FunctionInvocationRequest,请求ID:5bf59a45 - **** - **** - 9705-173d9635ca94,功能ID:fa626dc9 - **** - *** * -a59b-6a48f08d87e1,调用ID:f27fd7d1-1ace - **** - **** - 00fb021c9ca4

[4/17/2019 5:54:39 PM] Python queue trigger function processed a queue item: name2 [4/17/2019 5:54:39 PM] Python队列触发器函数处理了一个队列项:name2

[4/17/2019 5:54:39 PM] INFO: Successfully processed FunctionInvocationRequest, request ID: 5bf59a45-****-****-9705-173d9635ca94, function ID: fa626dc9-3313-****-****6a48f08d87e1, invocation ID: f27fd7d1-1ace-****-****-00fb021c9ca4 [4/17/2019 5:54:39 PM]信息:已成功处理FunctionInvocationRequest,请求ID:5bf59a45 - **** - **** - 9705-173d9635ca94,功能ID:fa626dc9-3313 - **** - **** 6a48f08d87e1,调用ID:f27fd7d1-1ace - **** - **** - 00fb021c9ca4

[4/17/2019 5:54:39 PM] Executed 'Functions.QueueTrigger' (Succeeded, Id=f27fd7d1-1ace-****-****-00fb021c9ca4) [4/17/2019 5:54:39 PM]执行'Functions.QueueTrigger'(成功,Id = f27fd7d1-1ace - **** - **** - 00fb021c9ca4)

INFO: Successfully processed 信息:已成功处理

– makes me think this worked and I should see a message in my queue, but it is blank. - 让我觉得这很有效,我应该在队列中看到一条消息,但它是空白的。

Why am I not seeing the message in the queue? 为什么我没有看到队列中的消息?

Thanks 谢谢

Your Terminal output shows the QueueTrigger detected the new message preprocess , so actually it has been write in. 您的终端输出显示QueueTrigger检测到新消息preprocess ,因此实际上它已写入。

As for no message in your queue, because it's processed to your function. 至于队列中没有消息,因为它已处理到您的函数。 After a message is delivered it will be removed from the queue. 邮件传递后,它将从队列中删除。 That's why your queue is blank. 这就是你的队列空白的原因。

And from the tutorial: Test the function , you could also find the description : 从教程: 测试函数 ,您还可以找到描述:

Back in Storage Explorer, click Refresh and verify that the message has been processed and is no longer in the queue. 回到Storage Explorer,单击Refresh并验证消息是否已处理并且不再在队列中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用python的azure函数使用定时器触发器触发HttpTrigger函数 - Trigger the HttpTrigger function using Timer trigger using azure function for python 如何使用 python 在 azure function 中的 httpTrigger 中创建调度程序? - How to create scheduler in httpTrigger in azure function using python? 部署后访问 azure 函数应用程序中的 HTTPTrigger 中的文件时出现问题? - There's problem in accessing files inside HTTPTrigger in azure function app after deployment? 禁止打印来自 Azure 队列存储的响应 - Suppress printing of response from Azure Queue Storage 适用于Python中Azure功能的Azure存储队列集成行为异常 - Azure Storage queue integration for Azure Functions in Python behaves abnormally Azure 函数队列为空 - Azure Functions Queue empty 在 Visual Studio Code 上的 Python 中创建 Azure function 以触发队列 - Create a Azure function in Python on Visual Studio Code to trigger queue Azure 表存储备份 - Azure Table Storage Backup Azure存储队列-create_queue-获取'binascii.Error:不正确的填充' - Azure storage queues - create_queue - getting 'binascii.Error: Incorrect padding' 部署的Azure python函数无法运行,因为找不到“ azure.storage”模块 - Deployed Azure python function, can not run because 'azure.storage' module could not be found
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM