How do you test Azure Queue trigger functions locally? How do you test Azure Queue trigger functions locally? azure azure

How do you test Azure Queue trigger functions locally?


Where messages in queue can be found

According to this article:

The storage emulator uses a local Microsoft SQL Server instance and the local file system to emulate Azure storage services. By default, the storage emulator uses a database in Microsoft SQL Server 2012 Express LocalDB. You can choose to configure the storage emulator to access a local instance of SQL Server instead of the LocalDB instance.

Therefore, you need to:

  • install and configure Azure Storage Emulator;
  • start it;
  • when it's running, access Queue service via url: http://127.0.0.1:10001/<account-name>/<resource-path>

In the worst case, you can bind your local function to real Azure Storage Queue.

Queue connection string

In few words: install VS Tools for Azure Functions; add local settings; add QueueTrigger attribute to your function method parameter.

Visual Studio Tools for Azure Functions.

Once you create a new Function project, add local.settings.json file to the root of your solution with the similar content:

{  "IsEncrypted": false,  "Values": {    "AzureWebJobsStorage": "UseDevelopmentStorage=true",    "AzureWebJobsDashboard": "UseDevelopmentStorage=true",    "YourQueueConnectionString": "http://127.0.0.1:10001/MyAccount"  }}

Add QueueTrigger attribute. Your Azure Function entry point should be like:

[FunctionName("MyQueueFunction")]public static async Task Run([QueueTrigger("MyQueue", Connection = "YourQueueConnectionString")] string message, TraceWriter log)


1) To view the messages in your queue, you can use the Azure Storage Explorer: https://azure.microsoft.com/en-us/features/storage-explorer/

2) To have your function connect to the queue, you will need the storage account's key. You can get this by following this SO answer: https://stackoverflow.com/a/43219736/84395

Once you have the key, add a new value in the local.settings.json:

{  "IsEncrypted": false,     "Values": {    "AzureWebJobsStorage": "<connection string>",     "AzureWebJobsDashboard": "<connection string>",    "MyStorageAccountConnection": "DefaultEndpointsProtocol=https;AccountName=[XXXX_YOUR_ACCOUNT_NAME_XXXX];AccountKey=[XXXX_YOUR_KEY_XXXX];EndpointSuffix=core.windows.net"  }}

So to answer your second question: You would specify MyStorageAccountConnection as the name of the connection.