Going with the Flow: Part 3 - Saving attachments to Azure Blob Storage

Going with the Flow: Part 3 - Saving attachments to Azure Blob Storage

In this step we're going to save the attachment from our email into Azure Blob Storage. This will serve as a central place where other services will be able to access files that we place there. In this series, we will be accessing these files within Powershell by means of Azure Runbooks, so we can extract the pertinent information about the bill.

Steps

Login to your Azure portal

Create a new storage account. This is where we'll store our attachments.

Fill out all the details and create the storage group. Make note of the storage account name you picked, because we'll need it later in our Flow.

Open up your newly created storage account, and add a new container called attachments and set the access type to private.

Back in Microsoft Flow, edit the flow we had created before, and add a new step.
Click more and select Add an apply to each. This is going to be a loop that will iterate through all of the email attachments, and save them to Azure Blob Storage.

For output from previous steps, we want the attachments.

Click Add an action within our Apply to Each loop

Select Azure Blob Storage - Create Blob

It'll now prompt you to create a new connection to your blob storage. Give the connection a name, and enter the Azure Storage Account Name you picked in Step 3.

The Azure Storage Access Key can be found in the Azure Portal under Storage Account -> Access Keys
Your flow connection should now look something like this:

Specify the folder path to upload the attachment. If you click the folder icon to the right, it will show a drop down of all the containers you have created in the storage group. In our case there should only be one called attachments.

Give the blob a name, and set the blob content to be the dynamic property "content" which is equal to the content of the attachment we're looping through.

Lastly, drag the Apply to each step we just created to be under the email trigger.

And there we have it! When the email comes through that has a new bill attached as a PDF, it'll save it to Azure Blob Storage, and send us a push notification.

What we learned

In this step we learned:

  • How to use a for-each loop within a Flow.
  • How to connect a Flow to external services, such as Azure Blob Storage.

Next steps

In the next step we'll use Azure Runbooks and Powershell to parse the email PDF attachments, and extract key bits of information about our bill.

Continue to Part 4: Working with Azure Runbooks.

Related Article