0

It appears that I cannot have an activity function which uses a Blob binding. The following gives runtime errors:

[StorageAccount("AzureWebJobsStorage")]
[FunctionName("LoadBlobFromBlobStorage")]
public static async Task<string> Run([ActivityTrigger] string blobName,
[Blob("containerName/directoryName/{blobName}", FileAccess.ReadWrite, Connection = AzureWebJobsStorage")] CloudBlockBlob blob,
ILogger log)
{
    ...
}

I get multiple failed binding error messages. Do Durable Functions not resolve bindings?

EDIT: add error messages (with reduced verbosity ...):

Azure Functions Core Tools (2.4.379 Commit hash: ab2c4db3b43f9662b82494800dd770698788bf2d)
Function Runtime Version: 2.0.12285.0
2019-02-21T18:25:32.165 [Error] Error indexing method 'LoadBlobFromBlobStorage'
Microsoft.Azure.WebJobs.Host.Indexers.FunctionIndexingException : Error indexing method 'LoadBlobFromBlobStorage' ---> System.InvalidOperationException : Can't bind Blob to type 'Microsoft.WindowsAzure.Storage.Blob.CloudBlockBlob'.
Possible causes:
1) Tried binding to 'Microsoft.WindowsAzure.Storage.Blob.CloudBlobDirectory...' but user type assembly was 'Microsoft.WindowsAzure.Storage.Blob.CloudBlobDirectory... .
2) Tried binding to 'Microsoft.WindowsAzure.Storage.Blob.CloudBlobContainer...' but user type assembly was 'Microsoft.WindowsAzure.Storage.Blob.CloudBlobDirectory... .
3) Tried binding to 'Microsoft.Azure.WebJobs.Host.Blobs.Bindings.BlobsExtensionConfigProvider+MultiBlobContext, Microsoft.Azure.WebJobs.Extensions.Storage, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' but user type assembly was 'Microsoft.WindowsAzure.Storage.Blob.CloudBlobDirectory... .
4) Tried binding to 'System.IO.Stream, System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' but user type assembly was 'Microsoft.WindowsAzure.Storage.Blob.CloudBlobDirectory... .
5) Tried binding to 'Microsoft.WindowsAzure.Storage.Blob.CloudBlockBlob...' but user type assembly was 'Microsoft.WindowsAzure.Storage.Blob.CloudBlobDirectory... .
6) Tried binding to 'Microsoft.WindowsAzure.Storage.Blob.CloudPageBlob...' but user type assembly was 'Microsoft.WindowsAzure.Storage.Blob.CloudBlobDirectory... .
7) Tried binding to 'Microsoft.WindowsAzure.Storage.Blob.CloudAppendBlob...' but user type assembly was 'Microsoft.WindowsAzure.Storage.Blob.CloudBlobDirectory... .
8) Tried binding to 'Microsoft.WindowsAzure.Storage.Blob.ICloudBlob...' but user type assembly was 'Microsoft.WindowsAzure.Storage.Blob.CloudBlobDirectory... .

   at async Microsoft.Azure.WebJobs.Host.Bindings.GenericCompositeBindingProvider`1.TryCreateAsync[TAttribute](BindingProviderContext context) at C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Bindings\BindingProviders\GenericCompositeBindingProvider.cs : 89
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
Jerry Liu
  • 17,282
  • 4
  • 40
  • 61
phil
  • 1,938
  • 4
  • 23
  • 33
  • 1
    Durable Functions' activities do resolve bindings; the functionality was added in [this PR](https://github.com/Azure/azure-functions-durable-extension/pull/172). What binding error messages are you seeing? – Katy Shimizu Feb 21 '19 at 21:56
  • @KatyShimizu, I added the error messages. – phil Feb 22 '19 at 09:52
  • @KatyShimizu, hmm, oddly I coded up Chris' example 1 from the PR you refer to and I get no indexing errors. – phil Feb 22 '19 at 19:56
  • So to reduce verbosity I removed some of the 5) message. In full it says: `5) Tried binding to 'Microsoft.WindowsAzure.Storage.Blob.CloudBlockBlob, Microsoft.WindowsAzure.Storage, Version=9.3.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' but user type assembly was 'Microsoft.WindowsAzure.Storage.Blob.CloudBlockBlob, Microsoft.WindowsAzure.Storage, Version=9.3.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35.` basically trying to bind to the same type but different point release. Not sure how to resolve which version of the enclosing library I need. – phil Feb 22 '19 at 20:47
  • Maybe [related](https://stackoverflow.com/questions/54823793/azure-durable-function-microsoft-azure-webjobs-host-error-indexing-method). – phil Feb 22 '19 at 20:57

1 Answers1

1

Make sure the package required are installed e.g.

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

And in the blob input binding, for binding type CloudBlobDirectory, the path should be in the format of containerName/directoryName. See container in your sample which is suspicious.

We could also put the incoming parameter blobName in blob path to get CloudBlockBlob directly.

[Blob("containerName/directoryName/{blobName}", FileAccess.ReadWrite, Connection = "AzureWebJobsStorage")] CloudBlockBlob blob 

Update

Make sure we don't install WindowsAzure.Storage >= v9.3.2, there seems a bug when binding to Storage related data type like CloudBlockBlob. See the issue tracked.

When we create a v2 Function Project, Microsoft.NET.SDK.Functions references WindowsAzure.Storage 9.3.1 by default. This version works well, no need to install the package separately.

Or we could use datatype like Stream or string with new version Storage SDK.

Jerry Liu
  • 17,282
  • 4
  • 40
  • 61
  • I updated my `Microsoft.Azure.WebJobs.Extensions.Storage` to version `3.0.3` from `3.0.0` and changed my `BlobAttribute` signature to match yours but I still get the error messages. Removing the topmost `StorageAccountAttribute` also doesn't help. – phil Feb 22 '19 at 09:56