1

建立在较早的问题上。以下代码是httptrigger对 gis 图层的编辑和更新列出的。它将 url 有效负载登录到队列中。我不希望加载有效负载,而是加载特定的重复消息,以便每次都将其覆盖,因为我不想时不时地出队。我该怎么办?

import logging
import azure.functions as func
def main(req: func.HttpRequest,msg: func.Out[str]) -> func.HttpResponse:
    logging.info('Python HTTP trigger function processed a request.')
    input_msg = req.params.get('message')
    logging.info(input_msg)
    msg.set(req.get_body())
    return func.HttpResponse(
            "This is a test.",
            status_code=200
    )


**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": "msg",
  "queueName": "outqueue1",
  "connection": "AzureStorageQueuesConnectionString"
  }
  ]
  }
4

1 回答 1

1

我不希望加载有效负载,而是加载特定的重复消息,以便每次都将其覆盖,因为我不想时不时地出队。

不,当您输入相同的消息时,它不会被覆盖。它只是在队列存储中排队。

如果要处理队列中的消息,只需使用queueclient或使用azure函数的queuetrigger。(函数的queuetrigger基于queueclient,它们基本相同。)

这是队列的API参考:

https://docs.microsoft.com/en-us/python/api/azure-storage-queue/azure.storage.queue?view=azure-python

您可以使用它使用 python 代码处理队列中的消息。

而这是azure函数的queuetrigger:(这个已经集成,可以直接使用)

https://docs.microsoft.com/en-us/azure/azure-functions/functions-bindings-storage-queue-trigger?tabs=python

于 2020-11-16T08:23:51.480 回答