1

I am new to Azure. Forgive me if the question is basic. I have the following http trigger intended to stream messages to the Queue Storage.

import logging
import azure.functions as func
def main(req: func.HttpRequest, msg: func.Out[func.QueueMessage]) -> func.HttpResponse:
    logging.info('Python HTTP trigger function processed a request.')
    input_msg = req.params.get('message')
    logging.info(input_msg)
    msg.set(input_msg)

    return func.HttpResponse(status_code=200, body='GotIt')

Tested it Locally and; enter image description here

Deployed it and it runs ok as well enter image description here

However, when I check the queue it is empty;

enter image description here

Questions;

  1. Why is the queue empty and what can I do to ensure it registers messages?
  2. Is it not locking because my code is not writing messages?

Your help will be highly appreciated.

4
  • Also didn't send message to queue when you did it on local? Commented Nov 13, 2020 at 7:12
  • Yes, it did not... and cant just figure out what the issue is. Commented Nov 13, 2020 at 7:13
  • @ Bowman Zhu from my local run it prints GotIt. Nothing goes into the queue Commented Nov 13, 2020 at 7:15
  • I have post an answer, you can have a try to see whether the problem still happens on your side. Commented Nov 13, 2020 at 7:18

1 Answer 1

1

Update:

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": "outqueue",
      "connection": "AzureStorageQueuesConnectionString"
    }
  ]
}

local.settings.json

{
  "IsEncrypted": false,
  "Values": {
    "AzureWebJobsStorage": "",
    "FUNCTIONS_WORKER_RUNTIME": "python",
    "AzureStorageQueuesConnectionString":"DefaultEndpointsProtocol=https;AccountName=0730bowmanwindow;AccountKey=xxxxxx;EndpointSuffix=core.windows.net"
  }
}

host.json

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

Original Answer:

I have do a simple test. Below code works fine on my side, you can have a try:

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(input_msg)
    return func.HttpResponse(
            "This is a test.",
            status_code=200
    )

This is the doc:

https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-storage-queue-output?tabs=python#example

Send:

enter image description here

Queue Storage:

enter image description here

enter image description here

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

18 Comments

I will try and revert
still nothing gets written
@wwnde I test the same code of you. I works with no problem. So it should have no problem with your code. Any limit of your storage account? You can also have a check of the configuration settings I updated.
are there queue settings that maybe I need to check?
@wwnde If you use connection string you should have totally access to queue. Can you show the structure of your AzureStorageQueuesConnectionString?(No need to show the account key and account)
|

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.