Search code examples
azure-storageazure-blob-storageazure-logic-appsblazor-webassembly

Azure Logic App - Save ImageDataURI as image in Azure Storage


I'm trying to save an image from a web app as a jpeg in Azure Blob Storage with an Azure Logic App. My web app allows the user select an image from their device and then sends it as an imageDataUri to an HTTP Trigger Logic App that uses the Create Blob Action.

Here is how the Image Data URI is created:

imageDataUri = $"data:{format};base64,{Convert.ToBase64String(memoryStream.ToArray())}";

The file will save successfully but not as a proper image.

How do I work with imageDataUri in the Azure Logic App to save it as a properly formatted jpeg in blob storage?


Solution

  • Figured it out, Logic App code view below:

    "Create_blob": {
                "inputs": {
                    "body": "@dataUriToBinary(triggerBody()?['imagedatauri'])",
                    "headers": {
                        "Content-Type": "image/jpeg"
                    },