I am trying to create a Azure Function that uses a BlobTrigger to manipulate some files and then save them back into the blob.
To do this I want to be able to access the BlobProperties object to check the Content-Type of the file, to ensure it is supported by my manipulation routine.
It is my understanding from this article that I should simply be able to add a parameter on method called Properties which is of type BlobProperties and I can confirm this works for the other Metadata types listed.
However whenever I add the properties, my app does not work and reports the following error:
The 'Function1' function is in error: Microsoft.Azure.WebJobs.Host: Error indexing method 'Function1'. Microsoft.Azure.WebJobs.Host: Can't bind parameter 'Properties' to type 'Microsoft.WindowsAzure.Storage.Blob.BlobProperties'.
What am I doing wrong? Below is my method:
public static void Run([BlobTrigger("TestContainer/{name}", Connection = "AzureWebJobsStorage")] Stream inputFile,
string name, string BlobTrigger, IDictionary<string, string> Metadata, ILogger log, BlobProperties Properties)
My target framework is .NET Core 3.1 and the Azure Functions Version is v3. I have the following NuGet packages:
- Microsoft.Azure.WebJobs.Extensions.Storage 4.0.3
- Microsoft.NET.Sdk.Functions 3.0.11
I saw a similar post which suggested removing the reference to Extensions.Storage component, but doing so removes the [BlobTrigger] attribute and other types, so does not work. Related questions seem to date back to 2018 and are for older versions of Azure Function, surely this should just work out the box?
Appreciate any suggestions, thank you in advance.
Just do like below:
I can successfully get the content-type of blob:
And the reference package: