Search code examples
azure-functions.net-assembly

Azure Function 2 - missing a using directive or an assembly reference?


I created my Azure Function v2 using Visual Studio 2017.

I created a new Queue Trigger function.

using System;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Host;
using Microsoft.Extensions.Logging;

namespace Functions
{
    public static class queue
    {
        [FunctionName("queue")]
        public static void Run([QueueTrigger("myqueue-items", Connection = "test")]string myQueueItem, ILogger log)
        {
            log.LogInformation($"C# Queue trigger function processed: {myQueueItem}");
        }
    }
}

But the assembly of QueueTrigger could not be found

Error   CS0246  The type or namespace name 'QueueTriggerAttribute' could not be found (are you missing a using directive or an assembly reference?)
Error   CS0246  The type or namespace name 'QueueTrigger' could not be found (are you missing a using directive or an assembly reference?)
Error   CS0246  The type or namespace name 'Connection' could not be found (are you missing a using directive or an assembly reference?)

Solution

  • As Nkosi said, you could go to Azure Queue storage bindings for Azure Functions to check if you have configure binding extensions.

    For your info, I think you need to install Microsoft.Azure.WebJobs.Extensions.Storage NuGet package, version 3.x. Then everything will work fine.