I am working on a function app (python v2 model) that puts a message into an Azure Queue.
- When I run the function from the project, I get a successful response BUT the message does not actually show up in the queue.
- When I run the function outside of my VS Code environment (Jupyter notebook), the message shows in the queue.
Below is a sample of the function:
import azure.functions as func
from azure.storage.queue import QueueServiceClient, QueueMessage
import logging
........
def add_message_to_queue(queue_name, connection_string, message):
# Create a QueueServiceClient using the connection string
queue_service_client = QueueServiceClient.from_connection_string(connection_string)
# Get the queue client
queue_client = queue_service_client.get_queue_client(queue_name)
# Add the message to the queue
queue_client.send_message(message)
return queue_client.send_message(message)
def addTolog_queue(message):
queue_name = 'xxxxxxx'
connection_string = 'xxxxxxxxxxxx'
return add_message_to_queue(queue_name, connection_string, message)
@app.route(route="xxxxx", auth_level=func.AuthLevel.FUNCTION)
def xxxxxx(req: func.HttpRequest, context: func.Context) -> func.HttpResponse:
.............
print(addTolog_queue(log_payload))
return func.HttpResponse(
body=json.dumps({}),
mimetype="application/json",
status_code=200
)
@app.queue_trigger(arg_name="azqueue", queue_name="xxxxxxx",
connection="xxxxxx_STORAGE")
def queue_trigger(azqueue: func.QueueMessage):
logging.info('Python Queue trigger processed a message: %s',
azqueue.get_body().decode('utf-8'))
que_payload = azqueue.get_body().decode('utf-8')
print(que_payload)
print("posting")
post_log(que_payload)
The response from the function is the following (displayed from the print statement.)
{'id': '1f5fe7dd-6d69-45d1-9bf4-86e62a3e4249', 'inserted_on': datetime.datetime(2023, 12, 15, 6, 43, 51, tzinfo=datetime.timezone.utc), 'expires_on': datetime.datetime(2023, 12, 22, 6, 43, 51, tzinfo=datetime.timezone.utc), 'dequeue_count': None, 'content': xxxxxxxxxx, 'pop_receipt': 'AgAAAAMAAAAAAAAACVCVECIv2gE=', 'next_visible_on': datetime.datetime(2023, 12, 15, 6, 43, 51, tzinfo=datetime.timezone.utc)}
Has anyone ran into this before? Any ideas on how to fix it? I could not find single article where someone ran into the same issue.
UPDATE #1
Strangely enough, I created a brand new queue and the message successful enters the queue on the Azure portal. I still don't know why but this is concerning functionality. Something is compromising the other queues from fully ingesting the message.
UPDATE #2
Getting closer...
I noticed when I remove the Queue function, the problem goes away. When I re-add the problem starts again. The issue has something to with the fact that I'm adding a message to a queue in the same environment that is triggered off adding the message to the queue.
Related article, although increasing workers has not helped: Why is Azure httpTrigger waiting for queueTrigger to finish processing?





