1

I am using Azure Queue Trigger v4 to get it triggered through managed identity having Storage Queue Data Contributor Role, but when new message is added in Queue, this azure function does not get triggered. I checked the application insight but there is no error.


[FunctionName("TestSyncFunction")]
    public async Task Run(
    [QueueTrigger("file-queue", Connection = "QueueConection")] QueueMessage queueMessage,
    ILogger log)
    {
      log.LogInformation($"TestSyncFunction function executed at: {DateTime.Now}");
      
    }

//My local.settings.json looks like this: "QueueConection__queueServiceUri": "https://xyz.queue.core.windows.net/", "QueueConection__credential": "managedidentity"

Also, I referred to 2 existing links but there is no help at all.

Azure Functions - use queue trigger with managed identity

Azure Functions - use queue trigger with managed identity

10
  • on Azure portal, locally it will not work since I don't have access to managed identity. Commented Aug 23, 2023 at 10:27
  • I am using the correct queue name. Commented Aug 23, 2023 at 10:30
  • local.settings.json QueueConection":"your storageconnection string: In managed identity, we dont have to use the storageconnection string, its a direct url to your queue. refer this: learn.microsoft.com/en-us/azure/azure-functions/… Commented Aug 23, 2023 at 10:32
  • I already sent the message in Queue manually, I have done all testing but its not triggering the Azure queue function, Commented Aug 23, 2023 at 10:33
  • are you using system-assigned identity or user-assigned identity here? Commented Aug 23, 2023 at 10:56

1 Answer 1

2

I have reproduced the issue and got the expected output using following steps-

Primarily I updated the package to Microsoft.Azure.WebJobs.Extensions.Storage.Queues" Version="5.1.3 and then added the following roles to my function app in storage account as stated in MS Docs.

enter image description here

enter image description here

Once you added these roles, then you will be able to see them in your function app as below

enter image description here

Then I added the below role to my account in the storage account-

enter image description here

I have tested my function locally as well as in Portal and it worked as expected in both cases.

Code:

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

local.setting

{
    "IsEncrypted": false,
  "Values": {
    "AzureWebJobsStorage": "UseDevelopmentStorage=true",
    "FUNCTIONS_WORKER_RUNTIME": "dotnet",
    "QueueConection__queueServiceUri": "https://<storageaccount name>.queue.core.windows.net/"
  }
}

Local Output:

enter image description here

Portal:

App Settings

enter image description here

Application Insight:

enter image description here

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

1 Comment

scope should be on storage account level not on the queue, didnt work on the queue level. Thanks for the answer.

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.