Richard Lindner
Richard Lindner

Reputation: 125

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?)

Upvotes: 6

Views: 11671

Answers (2)

karunakar bhogyari
karunakar bhogyari

Reputation: 679

I created a queue trigger function in Visual studio code using cli tools. It created azure function with version 2.0 in host.json file. When I run the function I got the same error. I could resolve this by adding below lines in .csproj file.

<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Storage" Version="3.0.0" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="1.0.24" />

Upvotes: 2

Joey Cai
Joey Cai

Reputation: 20067

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.

Upvotes: 12

Related Questions