• 3 Responses

    How to upload a file to Azure Blob Storage using MS Flow?

    Introduction

    In this blog I have explained how to upload any file to Azure Blob Storage using Microsoft Power Automate (Flow).

    Solution

    We will use Base64 string as file content. To trigger this flow, I have created HTTP POST request so that, we can call it in any programming language. You can use any other trigger as per your requirement.

    Step by Step

    1. Go to https://flow.microsoft.com and login with your credentials.
    2. Click on My Flows > New > Instant–from Blank.
    3. SAS URI to access file from Azure Blob Storage using MS Flow
    4. If you are shown list of triggers, click on Skip.
    5. SAS URI to access file from Azure Blob Storage using MS Flow
    6. Search “HTTP request” in search box and select “When an HTTP request is received”
    7. SAS URI to access file from Azure Blob Storage using MS Flow
    8. Then write a JSON object which will contain 3 variables for path, file name and file content. Here path is the “container” of the Azure Blob Storage.
    9. Upload to ABS
    10. In flow you will find lot of azure blob storage action. Here we are uploading a file to azure blob storage, then you must add next step as a “Create blob” action.
    11. SAS URI to access file from Azure Blob Storage using MS Flow
    12. Upload to ABS
    13. But to add this action you need to create a connection with “Azure Blob Storage” by providing necessary credentials.
    14. SAS URI to access file from Azure Blob Storage using MS Flow
    15. Set “Folder path” and “Blob name” fields as below.
    16. Upload to ABS
    17. Here is the main issue. We cannot pass base64 string directly to “Blob content” field as content. This field required binary datatype value. So, we must convert base64 string to binary. Here MS Flow provide us a function to convert base64 string to binary without any code. To use it, follow below steps.
    18. Upload to ABS
    19. Add opening and closing brackets after expression then you will a notification text to inform you about variable to pass this expression.
    20. Upload to ABS
    21. Click on “Dynamic content” tab and select appropriate variable.
    22. Upload to ABS
    23. You will see final expression as “base64ToBinary(triggerBody()?[‘blobcontent’])”
    24. Click on “OK”.
    25. You will see “Blob Content” field is now populated.
    26. Upload to ABS
    27. Now you must add new step to send response. To do that, click on new step, search for “Request”, click on “Request” and select “Response” action.
    28. SAS URI to access file from Azure Blob Storage using MS Flow
    29. In response action, in Body filed select “path” variable which is an output variable of “Create Blob” step. Please search for “Path” in dynamic content if you don’t see path variable directly.
    30. Upload to ABS
    31. Here path is the link location of the file uploaded on Azure Blob Storage.
    32. In addition, when you are updating the same file with different file content, then you must use “Update Blob” action which take file location link start from container as path and file content.
    33. Example for the path : if file location is this ”https://azureblob.windows.net/xyz/files/filename.png“ then path is like this “xyz/files/filename.png”.
    34. Upload to ABS
  • Subscribe
    Notify of
    guest
    3 Comments
    Oldest
    Newest Most Voted
    Inline Feedbacks
    View all comments
    Juan
    Juan
    2 years ago

    You’re awesome!

    Thanks a lot, this post saved me hours.

    Julien
    Julien
    1 year ago

    Hello, can the flow handle large files? example: If I want to upload a video 3GB with high quality do the flow will be capable to create it in Azure Blob with a short time?

    Nebulaa Blogger
    Editor
    1 year ago
    Reply to  Julien

WANT QUICK D365 IMPLEMENTATION?

Let started with our D365 Quickstart package and get onboard within 7 days!

I'M INTERESTED!
LATEST POSTS
© Copyright 2024 Nebulaa IT Solutions LLP. All Rights Reserved.
Download
Brochure