2

I am getting this error from a QueueTrigger function that also needs a CloudQueue binding.

Microsoft.Azure.WebJobs.Host.Indexers.FunctionIndexingException : Error indexing method 'QueueInstancesToImport.Run' ---> System.InvalidOperationException : Can't bind Queue to type 'Microsoft.WindowsAzure.Storage.Queue.CloudQueue'.

According to the docs CloudQueue should be valid.

https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-storage-queue

Other potential solutions I have found don't match exactly or don't help.

My code

public static class QueueFormInstancesToImport
{
    [FunctionName("QueueFormInstancesToImport")]
    public static async Task Run(
        [QueueTrigger("import-queue")]string message,
        [Queue("import-queue")]CloudQueue queue,
        TraceWriter traceWriter,
        ExecutionContext context)
    {
        // Body of function
        ...
    }
}
Andy T
  • 10,223
  • 5
  • 53
  • 95
Andrew Hawes
  • 386
  • 1
  • 5
  • 17
  • 2
    Not directly related to your issue but do you really intend to have the trigger and output be against the same Queue? That'll create an infinite loop of function invocations – Jesse Carter Oct 18 '17 at 15:53
  • Your code should work just fine. I smell some NuGet conflicts. Please check that the only package that you explicitly reference is `Microsoft.NET.Sdk.Functions`. – Mikhail Shilkov Oct 18 '17 at 21:06

1 Answers1

4

This is very likely a nuget package conflict. The assembly version that your 'CloudQueue' parameter is coming from is a different version of the stroage library than what's being used by the underlying Function runtime. You can F12 on the CloudQueue definition to see the full assembly version that it's binding against.

You very likely have add an extra reference to the Azure Storage SDK. Remove the extra reference and just use the reference from the Azure Functions template.

Mike S
  • 3,058
  • 1
  • 22
  • 12
  • I can confirm that this is still an issue when starting a new Azure Functions project using the Visual Studio template, and this answer resolves it. Going through MS docs, somewhere I was instructed to add a Nuget reference to Microsoft.Azure.Storage. However, the existing reference in the project to Microsoft.WindowsAzure.Storage contains slightly different APIs and work just fine for the scenario described in the original post. – K. Akins Mar 02 '20 at 01:26
  • 2
    In case this helps someone else - I changed from Microsoft.WindowsAzure.Storage.Queue to Microsoft.Azure.Storage.Queue and that did the trick. – technonaut Sep 17 '20 at 19:17