Skip to main content

Uploading a file from a SharePoint document library into an Azure Blob Storage with Microsoft Flow (or Logic App)

The Problem

One of the things that I've been experimenting with lately is Microsoft Flow. The service allows you to build process automation to facilitate transfer of information from one system to another easily.

One scenario I wanted to try out is to be able to copy/move a file from SharePoint to an Azure Blob Storage. There are a number of reasons that you may want to do this:

  • Archive files that are no longer needed
  • Upload a copy of a file (usually an image) into a Blob Storage so that images can be hosted in a CDN to optimize page load performance
In the past doing something like this would have required some form of custom development e.g. a remote event receiver. However the introduction of Microsoft Flow and Logic Apps has created another alternative that is worth exploring....

Update 30/09/16: If you are looking to put your assets into a CDN to make it load faster, then it's worth checking out the new Preview Release Office 365 Public Content Delivery Network (CDN) capability in the Office 365. However this will only work if the files are used within SharePoint, and according to the content cannot be used externally

Difference between Microsoft Flow and Logic Apps

Microsoft Flow is a service that is built on top of the Logic Apps platform and as such the functionalities offered in Microsoft Flow is similar to Logic Apps. The difference between both in my own opinion are:
  • Microsoft Flow: is a user friendly version of Logic Apps that makes it easy for business users to create solutions that automate information transfer between different systems. If you have used IFTTT (If This Then That), then Flow seems to be a business version of that service.
  • Logic Apps: is a pro version of Microsoft Flow that provides developers more functionality for developers (e.g. allows developers to build and deploy their solution in Visual Studio in addition to the graphic browser based designer) as well as more controls for IT (more advanced monitoring tools)

The Solution

High Level Steps

The high level steps involved in creating this solution are:
  1. Create an Azure Blob Storage Account
  2. Add a container (otherwise known as folder) inside your Azure Blob Storage Account
  3. Create your Microsoft Flow or Logic App Solution
Disclaimer: It is worth noting that Microsoft Flow is still in preview. In addition, though initial testing looks promising it is recommended that you perform load testing on such a solution to ensure it is robust enough for your needs. 

1. Create an Azure Blob Account

  1. Go to the Azure Portal
  2. Click on the New Button, and search for "Storage Account"
  3. Click on the Storage Account and confirm that you want to create one
  4. Fill out the form and choose the option that applies best to your circumstance and click Submit
    (Tip: whilst tempting to choose "premium options" consider whether they are required for your circumstance e.g. if you are just testing the scenario, then it's probably good enough to use the standard performance, locally redundant storage etc.)
  5. Your storage account should start provisioning and will be ready in a short while

2. Add a container inside your blob storage account

The container acts as a "folder" which will hold the files that you send over from the SharePoint Document Library

  1. Once the storage account has been created, open it (it can be found in the All Resources page)
  2. In the overview section, click on the add container button
  3. Fill out the form as appropriate to your circumstance and click Create
  4. This folder is where you will see your files once you get your solution working

3. Create your Microsoft App or Logic App solution

For the purpose of this blog post, the screenshot will be taken from Microsoft Flow. However the configuration between both products are similar (if not the same).

  1. Go to and sign in using your Office 365 account
  2. Click on My Flows > Create from blank
  3. Add the action: SharePoint - When a file is created
  4. Sign in using your Office 365 account (if you have previously not done so)
  5. Paste the URL of the site where the document library you want to use lives (you may also be asked to sign in with your office 365 account if you have not previously done so)
  6. Click the folder icon to select the document library you would like to monitor for new uploaded files
  7. Add the action: AzureBlobStorage - Create file
  8. Configure your connection in the AzureBlobStorage and submit your changes

    Connection Name: Copy this value from the property called "Primary blob service endpoint" (accessed in the Azure Portal by going to Storage Account > Overview)

    Azure Storage Account Name: Copy this value from the property called "Storage account name" (accessed in the Azure Portal by going to Storage Account > Access keys)

    Azure Storage Account Access Key: Copy this value from the property called "key 1" (accessed in the Azure Portal by going to Storage Account > Access keys)

  9. Click the folder icon to select the container that you created earlier in this blog post
  10. Fill out the remaining fields in the form:

    File name: Choose File name from the outputs returned from the SharePoint action
    File content: Choose File content from the outputs returned from the SharePoint action

  11. Add the action: Mail - Send Email (this step and the remaining steps in this section is optional)

    This will help us with our testing by getting the flow to email us the link to the file in Azure blob storage.
  12. Accept the terms and conditions (if you have not previously done so)
  13. Fill out the fields in the form:

    To: Enter your email
    Subject: Enter any value
    Body: Copy and paste the URL from the property "Primary blob service endpoint", and then choose the Path from the outputs returned from the create file in Azure Blob Storage action
  14. Save your flow

Testing the flow

Your flow should now be ready to test, so let's upload a file and wait for the email to come to us with a link to the file stored in the Azure Blob Storage.

It's also worth noting that Microsoft Flow (and Logic Apps) provides us with the ability to monitor the flow to see if any runs have failed. 

List of successful and failed runs in the flow solution we created

Detailed level for each individual run that shows things like that passed through the actions

Next Steps

  • Have you used Microsoft Flow or Logic Apps to move or copy a file from SharePoint to Azure Blob Storage? Share your experience in the comments below
  • Check out the documentation in the flow website for some useful getting started content

Popular posts from this blog

Only show a control to an employee's manager in PowerApps (using SharePoint as a data source)

The Problem In my previous blog post , I wrote a basic tutorial on configuring PowerApps to conditionally show/hide and make mandatory/optional a control based on the answer provided in a previous control. In this blog post we will expand on that scenario to create a form that only shows a control called approval status to a user if that logged in user is the manager of the user specified in the employee control. This means when the manager is using the application, they can change the status to approved. Meanwhile, a user that is not a manager of the person specified in the employee cannot change the status to approved. The Solution Aside from containing a variety of native functions, PowerApps also allow us to add connections to add functionalities into our app. In this case we will add the Office 365 Users connection so that we can get information on: The user that is logged on The manager of the user specified in the employee control Note: Whilst this soluti

An intro to conditional validation and formatting in PowerApps (using SharePoint as a data source)

The Problem What if we need to create a form that changes it's behaviour based on the answer entered by the user. For example, we need to build a leave request form that: Shows the comment field if applying for a sick leave, but hides the comment field if applying for a annual leave Requires the requestor to write a comment if their sick leave is more than 1 day, but is optional if sick for just 1 day.  The default form interface for custom lists in SharePoint Online can be used for basic scenarios, but doesn't provide an easy way to add business logic described above ( unless you want to write some javascript ) In the past InfoPath would have been the tool of choice for many, however this tool is now in maintenance mode and whilst it will still be supported for a wee while  there will be no improvements or enhancements to the platform. The Solution This is where PowerApps come in. PowerApps is now the platform that is recommended by Microsoft as a way fo

SharePoint | Set default value of date field to last day of the month

One of the things, that I needed to do recently is find a way to set the default value of a date field to the last day of the month. Though some content were really helpful in getting me on the way to solving the problem, I thought I'd post the formula required to make it easier for others looking to do the same in the future. What I wanted to do  The steps below describe what I wanted to achieve: User uploads a file into a document library A date column will automatically be populated with the date representing the end of the month (calculated based on the date the file was uploaded) How do we do this? Open your column settings for your date field Under the Additional Column Settings, set the default value option to Calculated Value Enter the the formula below: =(DATE(YEAR(TODAY()),MONTH(TODAY())+1,DAY("1-Apr-2008"))) - (1) Click save and that's all you need to do What does the formula above do? The formula above is quite simple.