I've got an Azure Function defined that uses an Azure Storage Queue Trigger and Blob input bindings. I've got a POCO for the queue trigger but how can I use that POCO with a binding expression in the blob input binding?
Architecuture:
- Azure Functions 2.x
- Precompiled C# library (.NET Core 2.1)
POCO:
public class ImageToProcess
{
public int CompanyId { get; set; }
public string FullImagePath { get; set; }
}
Azure Function:
public static void Run(
[QueueTrigger("profile-image-queue", Connection = "ProfileImageQueue")]ImageToProcess myQueueItem,
[Blob("profileimages/{queueTrigger.FullImagePath}", FileAccess.Read, Connection = "ProfileImageBlobConnectionString")] Stream originalImage,
ILogger log)
{
log.LogInformation($"Started Processing profile image: myQueueItem");
}
Queue Message:
{
"CompanyId": 123,
"FullImagePath": "CompanyA/profileImage-original.png"
}
Error Message:
System.Private.CoreLib: Exception while executing function: ProfileImageUploaded. Microsoft.Azure.WebJobs.Host: Exception binding parameter 'originalImage'. Microsoft.Azure.WebJobs.Host: Error while accessing 'FullImagePath': property doesn't exist.
Resources Used to Create this Solution
- http://dontcodetired.com/blog/post/Improving-Azure-Functions-Blob-Trigger-Performance-and-Reliability-Part-2-Processing-Delays-and-Missed-Blobs
- https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-storage-queue#trigger
- https://learn.microsoft.com/en-us/sandbox/functions-recipes/queue-storage#azure-storage-queue-trigger-using-a-poco
Other Potential Solution: The only other option I see is to use imperative bindings but I'm pretty sure I can use declarative. https://learn.microsoft.com/en-us/azure/azure-functions/functions-dotnet-class-library#binding-at-runtime