0

I am trying to trigger an Azure function when a new queue message is added. Both the storage account and the azure function are in the same region.

For my Azure Function, I clicked on Add, Azure Queue Storage Trigger, I gave my function a name, and the Queue name is the same name as my queue. I tried adding a new queue message, nothing is triggered.

I then tried modifying the code as the following:

using System;

[FunctionName("QueueTrigger")]
[StorageAccount("storagetestaccount1")]

public static void Run(
    [QueueTrigger("queue1")] string myQueueItem, 
    ILogger log)
{
    log.LogInformation($"C# Queue trigger function processed: {myQueueItem}");
}

But still no success. Any idea what might be causing this?

This is my first azure function so not sure what's correct and what's not.

1
  • Use this:[QueueTrigger("myqueue-items", Connection = "StorageConnectionAppSetting")] then everything should be ok. And are you developing locally or on azure? Commented Sep 15, 2020 at 6:14

1 Answer 1

1

I think the correct code is this:

    public static class Function1
    {
        [FunctionName("Function1")]
        public static void Run([QueueTrigger("queueName", Connection = "connectString")]string myQueueItem, ILogger log)
        {
            log.LogInformation($"C# Queue trigger function processed: {myQueueItem}");
        }
    }

Note

If you develop locally, you should config your azure storage connect string in local.settings.json

enter image description here

If you develop in azure portal, you need to config connect string in Application settings:

enter image description here

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

Comments

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.