Reputation: 10865
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.
Upvotes: 0
Views: 4727
Reputation: 10865
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
Upvotes: 0
Reputation: 3169
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
Upvotes: 0
Reputation: 13558
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"
}
]
}
Upvotes: 2
Reputation: 35124
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.
Upvotes: 0