0

I get this error:

Microsoft.Azure.WebJobs.Host: Only the 'Read' FileAccess mode is supported for blob container bindings.

And according to docs, the out should be supported?

I initially tried it with Attributes added in the method definition. However, I get the same error, so I removed all the attributes in my method definition, so the new method definition is:

public static async Task RunAsync(CloudBlockBlob myBlob,  string name, 
IAsyncCollector<ProfilePictureUrl> client, CloudBlockBlob resizedBlob, TraceWriter log)

Here's my function.json

{
  "bindings": [
    {
      "type": "blobTrigger",
      "path": "profile-pictures/{name}",
      "direction": "in",
      "name": "myBlob"
    },
    {
      "type": "documentDB",
      "databaseName": "TestDB",
      "collectionName": "ResizedProfilePictures",
      "createIfNotExists": true,
      "direction": "out",
      "name": "client"
    },
    {
      "type": "blob",
      "path": "resized-profile-pictures",
      "direction": "out",
      "name": "resizedBlob"
    }
  ],
  "disabled": false,
  "scriptFile": "..\\Test.Functions.dll",
  "entryPoint": "Test.Functions.ResizeImage.RunAsync"
}

I'm using Azure CLI beta 100. If I removed resizedBlob from method definition and function.json, then it works fine.

123 456 789 0
  • 10,565
  • 4
  • 43
  • 72

4 Answers4

2

CloudBlobContainer must be bound to as an input binding. Here's a working example:

#r "Microsoft.WindowsAzure.Storage"

using Microsoft.WindowsAzure.Storage.Blob;

public static void Run(Stream input, Stream output, 
                       CloudBlobContainer container, TraceWriter log)
{
    var blobs = container.ListBlobs();
    log.Info($"{blobs.Count()} blobs in container.");
}

And the corresponding function.json:

{
  "bindings": [
    {
      "name": "input",
      "type": "blobTrigger",
      "direction": "in",
      "path": "input/{name}",
      "connection": "test_STORAGE"
    },
    {
      "name": "container",
      "type": "blob",
      "direction": "in",
      "path": "input",
      "connection": "test_STORAGE"
    }
  ]
}
mathewc
  • 13,312
  • 2
  • 45
  • 53
0

CloudBlobContainer is not listed as supported type for output binding. So, you need to use one of the listed types.

I guess, you are trying to dynamically set the name of the output file. To accomplish this, you either need to bind the name to trigger parameters (e.g. {name}), or to use imperative binding (as you already do for the output binding).

If you have another use case, please extend your question with code example.

If you really need CloudBlobContainer parameter, list it as another in binding.

Mikhail Shilkov
  • 34,128
  • 3
  • 68
  • 107
  • I really do need the `CloudBlobContainer` and I tried modifying it as `in` binding, but it won't work either and would throw a different error. – 123 456 789 0 Jul 02 '17 at 18:40
  • I also modified this to be just CloudBlockBlob which is supported as type for output binding but I get `ResizeImage: Microsoft.Azure.WebJobs.Host: Error indexing method 'Functions.ResizeImage'. Microsoft.Azure.WebJobs.Host: Can't bind Blob to type 'Microsoft.WindowsAzure.Storage.Blob.CloudBlockBlob&'.` – 123 456 789 0 Jul 02 '17 at 19:22
0

This should work in the newly released Functions VS tooling (non-preview). Can you update to the latest bits?

For VS tooling, Functions now directly loads the DLL in the same way as webjobs, so all the webjobs bindings will work as is. The only thing in Function.json then is the trigger binding and a "configurationSource": "attributes" property. That property is what tells it to use the attributes instead of the function.json. [1]

[1] See https://github.com/Azure/azure-webjobs-sdk-script/issues/1508

Mike S
  • 3,058
  • 1
  • 22
  • 12
0

The issue was a bug and is now fixed in the latest version of the function.

https://github.com/Azure/azure-webjobs-sdk-script/issues/1783

123 456 789 0
  • 10,565
  • 4
  • 43
  • 72