我有一个队列触发器,当手动将消息添加到队列中时,它会启动并按预期运行。但是,当消息通过以下计时器触发函数写入队列时,它无法启动。我可以看到消息已由触发器成功写入。
**初始化.py**
import datetime
import logging
import os, uuid
from azure.storage.queue import (
QueueClient,
BinaryBase64EncodePolicy,
BinaryBase64DecodePolicy
)
import os, uuid
import azure.functions as func
def main(mytimer: func.TimerRequest) -> None:
utc_timestamp = datetime.datetime.utcnow().replace(
tzinfo=datetime.timezone.utc).isoformat()
conn_str = os.environ['AzureWebJobsStorage']
queue_name="outqueue12"
message = u"Hello234"
queue_client = QueueClient.from_connection_string(conn_str, queue_name)
# Setup Base64 encoding and decoding functions
queue_client.message_encode_policy = BinaryBase64EncodePolicy()
queue_client.message_decode_policy = BinaryBase64DecodePolicy()
queue_client.send_message(message)
logging.info('Python timer trigger function ran at %s', utc_timestamp)
主机.json
{
"version": "2.0",
"logging": {
"applicationInsights": {
"samplingSettings": {
"isEnabled": true,
"excludedTypes": "Request"
}
}
},
"extensionBundle": {
"id": "Microsoft.Azure.Functions.ExtensionBundle",
"version": "[1.*, 2.0.0)"
}
}
有什么我错过了吗?