locked
Can't bind BlobTrigger to CloudBlockBlob RRS feed

  • Question

  • After updating my azure function to version 2 (updated visual studio extension, sdk, all my emulators and other nuget packages), I am currently getting an error "Can't bind BlobTrigger" for my function on my local machine. As far as I know, my packages are all updated to the latest. This was working before the update. I do have the Storage nuget package installed as seen in other articles.

    This happens locally

    My Azure function host:

    Azure Functions Core Tools (2.0.3)
    Function Runtime Version: 2.0.12115.0
    .......
    [2018/10/04 9:57:55 AM] Starting Host (HostId=baudine-1170217836, InstanceId=4d3aff5f-60a3-40cd-898e-0fcd1a16815a, Version=2.0.12115.0, ProcessId=9464, AppDomainId=1, Debug=False, FunctionsExtensionVersion=)
    [2018/10/04 9:57:55 AM] Generating 1 job function(s)
    [2018/10/04 9:57:55 AM] Error indexing method 'Function.Run'
    [2018/10/04 9:57:55 AM] Microsoft.Azure.WebJobs.Host: Error indexing method 'Function.Run'. Microsoft.Azure.WebJobs.Host: Can't bind BlobTrigger to type 'Microsoft.WindowsAzure.Storage.Blob.CloudBlockBlob'.


    My function:

        public static class Function
        {
            [FunctionName("Function")]
            public static async Task Run([BlobTrigger("imports/{name}", Connection = "BlobStorageAccount")]CloudBlockBlob myBlob, string name, ILogger log)
            {
    			log.LogInformation($"C# Blob trigger function Processed blob\n Name:{name} \n Size: {myBlob} Bytes");
            }
        }


    Nuget packages:

    <PackageReference Include="Microsoft.Azure.WebJobs" Version="3.0.0" />
    <PackageReference Include="Microsoft.Azure.WebJobs.Extensions.CosmosDB" Version="3.0.1" />
    <PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Storage" Version="3.0.0" />
    <PackageReference Include="Microsoft.NET.Sdk.Functions" Version="1.0.22" />
    <PackageReference Include="NodaTime" Version="2.4.0" />
    <PackageReference Include="Serilog" Version="2.7.1" />
    <PackageReference Include="Serilog.Sinks.Stackify" Version="2.0.2" />
    <PackageReference Include="StackifyLib" Version="2.1.3" />

    Are any of the packages wrong?

    Thursday, October 4, 2018 10:13 AM

Answers

  • Hi all,

    Thank you for the help. I was able to fix the problem.

    I was referencing another project (that referenced another and another) that had WindowsAzure.Storage 9.3.2 as it's nuget package. Once I removed the reference to the project, my trigger worked. I replaced WindowsAzure.Storage in that project with the Extensions.Storage nuget package as in my functions app so that they will use the same libraries. It now works.

    Thank you for the help!

    • Marked as answer by Baudine Monday, October 15, 2018 1:52 PM
    Monday, October 15, 2018 7:40 AM

All replies

  • Thursday, October 4, 2018 10:42 AM
  • I have version 3.0.0 of  Microsoft.Azure.WebJobs.Extensions.Storage installed according to the articles. 

    My application compiles but doesn't want to bind to the CloudBlockBlob. When I change the property type to Stream instead of CloudBlockBlob then it binds but throws an internal error in webjobs when triggered. I would prefer working with CloudBlockBlob


    • Edited by Baudine Thursday, October 4, 2018 12:41 PM
    Thursday, October 4, 2018 12:40 PM
  • After you have updated your function.json file to include all the bindings that your function needs, run the following command in the project folder.

    func extensions install
    Thursday, October 4, 2018 3:46 PM
  • The command reads the function.json file to see which packages you need, installs them, and rebuilds the extensions project. It adds any new bindings at the current version but does not update existing bindings. Use the --force option to update existing bindings to the latest version when installing new ones.
    Thursday, October 4, 2018 3:47 PM
  • I have the following bindings in my function.json file: 

    "bindings": [
        {
          "type": "blobTrigger",
          "connection": "BlobStorageAccount",
          "path": "imports/{name}",
          "name": "myBlob"
        }
      ],

    I didn't add these to the file - they were there

    Friday, October 5, 2018 7:40 AM
  • function.json file is generated.

    Here are the package references you need for CosmosDB and Storage. 

    <ItemGroup>
        <PackageReference Include="Microsoft.Azure.WebJobs.Extensions.CosmosDB" Version="3.0.1" />
        <PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Storage" Version="3.0.0" />
        <PackageReference Include="Microsoft.NET.Sdk.Functions" Version="1.0.22" />
      </ItemGroup>

    Can you please share a simple repro project?

    Friday, October 5, 2018 3:08 PM
  • Hi all,

    Thank you for the help. I was able to fix the problem.

    I was referencing another project (that referenced another and another) that had WindowsAzure.Storage 9.3.2 as it's nuget package. Once I removed the reference to the project, my trigger worked. I replaced WindowsAzure.Storage in that project with the Extensions.Storage nuget package as in my functions app so that they will use the same libraries. It now works.

    Thank you for the help!

    • Marked as answer by Baudine Monday, October 15, 2018 1:52 PM
    Monday, October 15, 2018 7:40 AM
  • I am facing this problem. I tried above option but my CloudBockBlob is not compiling once I removed reference of WindowsAzure.Storage. Please suggest. If I use WindowsAzure then I am getting binding issue.
    Friday, February 28, 2020 1:50 PM