Python 3.x 计时器触发器不会触发队列,但手动输入不会触发队列

Python 3.x 计时器触发器不会触发队列,但手动输入不会触发队列,python-3.x,azure-functions,timer-trigger,queuetrigger,Python 3.x,Azure Functions,Timer Trigger,Queuetrigger,我有一个队列触发器,当消息被手动添加到队列中时,它会启动并按预期运行。但是,当以下计时器触发函数将消息写入队列时,它无法启动。我可以看到触发器已成功写入消息 **init.py** host.json { "version": "2.0", "logging": { "applicationInsights": { "samplingSettings": {

我有一个队列触发器,当消息被手动添加到队列中时,它会启动并按预期运行。但是,当以下计时器触发函数将消息写入队列时,它无法启动。我可以看到触发器已成功写入消息

**init.py**

host.json

{
  "version": "2.0",
  "logging": {
    "applicationInsights": {
      "samplingSettings": {
        "isEnabled": true,
        "excludedTypes": "Request"
      }
    }
  },
  "extensionBundle": {
    "id": "Microsoft.Azure.Functions.ExtensionBundle",
    "version": "[1.*, 2.0.0)"
  }
}

有什么我遗漏的吗?

根据一些测试,问题与base64编码有关。我添加了三行代码:

message_bytes = message.encode('ascii')
base64_bytes = base64.b64encode(message_bytes)
base64_message = base64_bytes.decode('ascii')
请参考下面的整个功能代码:

host.json

{
  "version": "2.0",
  "logging": {
    "applicationInsights": {
      "samplingSettings": {
        "isEnabled": true,
        "excludedTypes": "Request"
      }
    }
  },
  "extensionBundle": {
    "id": "Microsoft.Azure.Functions.ExtensionBundle",
    "version": "[1.*, 2.0.0)"
  }
}
function.json

{
  "scriptFile": "__init__.py",
  "bindings": [
    {
      "name": "mytimer",
      "type": "timerTrigger",
      "direction": "in",
      "schedule": "*/20 * * * * *"
    }
  ]
}

如果您不想使用base64编码(我个人不建议这样做),那么设置策略没有意义,只需删除以下行,您的原始代码就可以工作:

    # Setup Base64 encoding and decoding functions
    queue_client.message_encode_policy = BinaryBase64EncodePolicy()
    queue_client.message_decode_policy = BinaryBase64DecodePolicy()

从文档中。

好的,让我检查一下,当您测试时,这是否会在您端触发队列?它表示它已成功运行。但是与以前不同,队列或posion队列中没有消息。队列触发器无法获取started@wwnde我的队列触发器是在计时器触发器函数向队列发送消息后成功触发的。请在回答中添加您的主机和function.json。好的,对我来说并不简单,但我感谢您的帮助尝试了这种方法。消息正在写入队列。但是,由于队列被填充,队列触发器没有触发。
    # Setup Base64 encoding and decoding functions
    queue_client.message_encode_policy = BinaryBase64EncodePolicy()
    queue_client.message_decode_policy = BinaryBase64DecodePolicy()