Queue is not an attribute class

In this azure tutorial, we will discuss how to fix the error, Queue is not an attribute class. This error I got while creating an Azure function using the Visual Studio 2019.

Queue is not an attribute class

Recently, while I was trying to create an Azure function using the Visual Studio 2019, I got the error Queue is not an attribute class or ‘Queue’ is not an attribute class.

Queue attribute error

Below is the C# code that i was trying to execute in the Azure Function. Below is the part of the code of the function.

public static class Function1
    {
        [FunctionName("Function1")]
        public static async Task<IActionResult> Run(
            [HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req,
            ILogger log, [Queue("myDetails", Connection = "AzureWebJobsStorage")] IAsyncCollector<UserDetails> outputQueue)
        {
            string jsoncnt = await req.Content.ReadAsStringAsync();
            var myDetails = JsonConvert.DeserializeObject<UserDetails>(jsoncnt);
            log.LogInformation($"User {myDetails.UserId} received from {myDetails.UserEmail} for his {myDetails.UserId}");
            await outputQueue.AddAsync(myDetails);
           log.LogInformation("C# HTTP trigger function processed a request.");

            string name = req.Query["name"];

            string requestBody = await new StreamReader(req.Body).ReadToEndAsync();
            dynamic data = JsonConvert.DeserializeObject(requestBody);
            name = name ?? data?.name;

            return name != null
                ? (ActionResult)new OkObjectResult($"Hello, {name}")
                : new BadRequestObjectResult("Please pass a name on the query string or in the request body");
        }
    }
}

While trying to run the project, i got the error Queue is not an attribute class at the below line

[HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req,
            ILogger log, [Queue("myDetails", Connection = "AzureWebJobsStorage")] IAsyncCollector<UserDetails> outputQueue)

You can see below the exact error

'Queue' is not an attribute class

Queue is not an attribute class [Solved]

Now to fix this we need to follow the below steps

Right click on the Project and click on the Manage NuGet Packages.

'Queue' is not an attribute class [Solved]

Search for the Microsoft.Azure.WebJobs.Extensions.Storage as shown below and then click on the Install button to install it.

Queue attribute error

Now click on the I Accept button on the License Acceptance pop up to accept the Licence terms. Then after the dll will successfully installed on your machine.

Queue is not an attribute class

Now if you will see the code the error is not there. Refer to the below screenshot.

Queue is not an attribute class error

You may also like to follow the below articles

Conclusion

Well, In this article, we discussed how to fix the error Queue is not an attribute class or ‘Queue’ is not an attribute class that I got while creating an Azure function using Visual Studio 2019 with C#. Hope it will help you to fix your issue !!!.