Upload Files to Azure Blob Storage using Power Automate Desktop

Published May 05 2021 01:22 AM 17.7K Views
Microsoft

In this blog post, we are going to have a look at how you can automatically upload files to an Azure Blob storage account using Power Automate Desktop. Power Automate Desktop is a great tool to build automation on your desktop. You can create flows, interact with everyday tools such as email and excel and work with modern and legacy applications.

 

For example, you can automate tasks like:

  • Quickly organize your documents using dedicated files and folders actions
  • Accurately extract data from websites and store them in excel files using Web and Excel automation
  • Apply desktop automation capabilities to put your work on autopilot.

Now want tasks I want to build some automation is to upload files to an Azure Blob Storage account for long-term storage. These can be small and large files, in my cases I wanted to backup all my large video files to an Azure blob Storage account.

To learn more about Power Automate check out Microsoft Docs.

 

Preparation

 

Install Power Automate Desktop (it is free)

You can download Power Automate Desktop from here.

Sign in to the Power Automate Desktop Windows application using one of the following accounts and automate your tedious tasks.

A full comparison of the features included in each account can be found here.

 

Create an Azure Storage account

Secondly you create a Storage account in Azure. An Azure storage account provides you to host all of your Azure Storage data objects: blobs, files, queues, and tables. For more information about Azure storage accounts, see Storage account overview.

To create an Azure storage account just follow these steps on Microsoft Docs: Create a storage account.

 

Download AzCopy

Since I am dealing with large files, I decided to use the AzCopy utility. AzCopy is a command-line utility that you can use to copy blobs or files to or from a storage account. Get started with AzCopy.

 

Create Power Automate Desktop Flow

After we prepared everything, we can now start to create the flow in Power Automate Desktop.

Power Automate Desktop Flow - Upload to Azure Blob Storage using AzCopyPower Automate Desktop Flow - Upload to Azure Blob Storage using AzCopy

 

First, I create the following variables within the flow.

  • UploadFolder - This is the folder where I place my files, which I want to be uploaded
  • UploadedFolder - This is the folder where the file gets moved after it has been uploaded
  • AzCopy - This is the path where I saved the azcopy.exe
  • AzureBlobSAS - This is the URI for the Azure Blob Storage account including the Shared access signature (SAS) token

 

To generate the URI with the SAS (Shared access signature) token, go to the Azure Portal to your Azure storage account. Go to containers and create a new container. Open the container and on the and navigate to Shared access signature. Select add, create, and write permission, change the time if needed, and press Generate SAS token and URL. Copy the Blob SAS URL and save it as the variable in the flow.

 

Azure Storage Account SAS TokenAzure Storage Account SAS Token

 

IMPORTANT: When you add the SAS URL to the variable you will need to make all the % to %% because of how Power Automate Desktops names variables.

 

Since we want to use the AzCopy utility to copy the files to the Azure Blob storage, you can now add the “Run PowerSheel script” action with the following PowerShell code:

 

 

%AzCopy% copy "%UploadFolder%" "%AzureBlobSAS%" --recursive=true

 

 

Run PowerShell scriptRun PowerShell script

 

With the last step, we are going to move the uploaded files to another folder.

Move FilesMove Files

 

Conclusion

I hope this blog post provides you with a quick overview of how you can upload files to an Azure Blob storage account using Power Automate. There are of course other ways on how to do this but the great thing here is that you can easily upload large files and add more actions to your Power Automate Desktop Flow. If you have any questions, feel free to leave a comment below.

1 Comment
Co-Authors
Version history
Last update:
‎May 05 2021 01:21 AM
Updated by: