0

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. 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

{
  "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

{
  "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] 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] 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] Python queue trigger function processed a queue item: 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] Executed 'Functions.QueueTrigger' (Succeeded, 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

1 Answer 1

0

Your Terminal output shows the QueueTrigger detected the new message preprocess, so actually it has been write in.

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.

Sign up to request clarification or add additional context in comments.

4 Comments

that documentation is for a function that reads the Queue when a message has been created. (Create a function triggered by Azure Queue storage) My function is having issues writing to the queue. -thank you.
this is odd, when i create a message from the portal and then start my app, the message disappears, this function should be writing to the Queue, NOT reading it.
George, thanks. i had forgotten that i created a queuetrigger function when i was paying around with the different functions and had not deleted the sample code. So you were correct it was being created and then immediately passed to the other function. once i removed the queuetrigger function, everything worked as expected.
@Jay42, if this could help you, you could mark it as the answer. Thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.