cancel
Showing results for 
Search instead for 
Did you mean: 

Sync a Document Library to Azure Blob Storage Using Metadata Value Triggers

This is a follow up article, there are more details and information on my last post-

Using Metadata Values Triggers for Actions via Flow

 

For many organizations, it is difficult to share out  information to external users. Though you can externally share sites and documents in Office 365, sometimes, users need to send out documents to many external contacts, and would like an easier way to do this than having to attach said documents to an email. Also, many times Marketing, HR and other departments need the ability to publish documents and have them linked from key pages either on their own website or via social media or other means.

 

Blob storage in Azure is a cheap and easy way to publicly publish documents to access via a URL without having to worry about any method of authentication for access. Frequently, however it is not optional for an organization's IT department to give even trusted end users the necessary access to Azure or billable services that may give them more power than intended- let alone taking the time to train end users on how to make this possible.

 

A simple solution is to setup a triggered sync between Azure Blob Storage and a SharePoint Document Library via Flow.

 

Have a Security Plan Before Implementation!!

Any location that is publishing documents that are publicly viewable should be regularly monitored with as limited access as possible for security, legal and compliance reasons. Be sure and have a governance plan or solution in place before any such publishing is accessible to end users.  There are access and permissions features from both the Azure and SharePoint sides of this solution which you may use to control access to the location in question.

 

Regarding Teams

 

 It is possible to sync storage locations in Teams via the Team Document Library through the SharePoint Connection in the Teams Channel Tab. This must be via a Document Library that has been imbedded via a webpart in the connected SharePoint Page.

 

Connecting to SharePoint through the Teams web app or desktop app can require a separate authentication so for connecting such a storage sync in Teams I recommend a process not dissimilar from the one below, but utilizing two Flows, one for when a File is created and one for when a File is deleted. You could potentially add another trigger to accomplish this- but the Teams use case will be touched upon in my next blog post.

 

How to set up the publishing Document Library:

 

The first steps are to provision the Azure BLOB for this location ( you can keep track of the sync at the blob folder level if desired), and set the metadata triggers accordingly.

 

For this example I'm using the vales of New, Published and Unpublished, where New designates no action on a newly uploaded document, Published will copy the file to an Azure Blob location, and Unpublished will delete the Azure Blob.

 

Image 001.png

 

My BLOB container is "msendusertest."

 

Image 002.png

Now, go to the Flow application and select the "When a file is created or modified (properties only) option.The next step is to add the action "Get file content" so that we can create the BLOB (this is not a dynamic content option for this action, but is for "When a file is created" in SharePoint if you would rather start with that action to create a BLOB for any file uploaded to the location).

 

Image 57.png

 

For the Column I created above, I'll choose the Dynamic Content that corresponds to the forma of "Column Name Value" so Pub to Azure Blob Value is equal to Published.

 

Image 58.png

 

OK! Now we're building some momentum…

 

Then for the YES condition we'll create the BLOB. To make this super easy for the end user, we're also going to send them an email with the URL to link to the newly created file for easy download.

 

Choose the Azure BLOB Storage: Create A Blob action via the list, and establish your connection to Azure Blob Storage using the security key and access information.

 

The next step is to enter in the path, where the root folder is the blob storage, and the first subfolder is the Blob Container Name. For this example (as suggested) the BLOB Name will be the file name and the Blob Content is the File Content (you may not see the file extensions in the path initially but the file types will be retained and show when they are downloaded).

 

 Image 005.png

 

 

Next, add another action in the same "Yes" conditional area to send an email with the URL to the BLOB that has been created. To do this, you'll need to add the root URL for your BLOB storage, then Dynamic Content Path to the blob in question immediately after, with no spaces (the Path value will start with a forward slash, so you may leave that out of the root).

 

Image 61.png

 

Now, in the "No" conditional box, I'm going to add the ability to "Unpublish" the document in question. I'll do this by adding another contition: Pub to Azure BLOB is qual to "Unpublished".

 

Then I'll add in the sub "If Yes" field the action to Delete the blob, with the folder root path, and the name of the file from the dynamic content.

 

Image 006.png

 

 

So the bulk of the Flow conditions appear as follows: 

 

Image 59.png

 

 

All set! Ready to Go! 

Now, save and name your flow!

 

For this example, mine ran on the first attempt in under 13 seconds:

 

Image 007.pngImage 008.pngImage 009.png

 

You should also receive an email with a link to the file which should trigger an immediate download when clicked.

 

Image 64.png

 

Final Note! If you do this with a Basic HTML file and add referenced image files within it, you can use the BLOB storage as a simple web server, and embed your files and images via the .html document. This way, your power end users could build a simple web page and format how your links and content can be seen by external users, without having to leave SharePoint as the upload medium.

Comments

How to set up the publishing Document Library:

there is a screenshot about Editing the column but you dont mention what you are in (Sharepoint, Azure? Or how you get to this screenshot.

 

Could you possibly add those details? 

 

 

Sorry for the confusion. 

The screenshot under the "How to set up the publishing Document Library:" is of the Edit Column->Choice option of a SharePoint Document Library. 

 

Thanks

How can I recreate the subfolder structure from the linked sharepoint storage.

Meet Our Blog Authors
  • Working daily with Microsoft Cloud to deliver the needs of my company, my customers and various Microsoft communities and forums. | Office 365 | Flow | PowerShell | PowerApps | SharePoint |
  • Co-founder of https://plumsail.com, Office 365 and SharePoint expert. Passionate about design and development of easy to use, convenient and flexible products.
  • Microsoft Business Apps MVP. Owner of ThriveFast, an Office 365 consulting company.
  • 7x Microsoft Business Solutions MVP (CRM)
  • Solution Architect with Slalom, and organizer of the Boston Office 365 User Group, and long term SharePoint/Office 365 veteren. Find more at http://www.davidlozzi.com. Follow @DavidLozzi
  • I'm keen in MS technologies, SharePoint, Office 365 and development for them
  • Daniel is a Business Productivity Consultant & Microsoft Business Solutions MVP who is very enthusiastic about all things Office 365, Microsoft Flow, PowerApps, Azure & SharePoint (Online). Since the preview, Daniel has been working with Microsoft Flow and later on with Microsoft PowerApps. That led to him being awarded an MVP Award for Business Solutions. He loves to blog, present and evangelize about improving productivity in the modern workspace with these amazing tools!
  • Michelle is an Office 365 solution architect in Twin Cities, MN. She has been delivering business collaboration solutions for years with her focus on SharePoint and Office 365. Michelle is a recent board member of the Minnesota Office 365 User Group and has been a member of the SharePoint community since 2009. She is a frequent speaker at MNSPUG and SharePoint Saturday and co-chaired the Legal SharePoint User Group for 4 years. Her most frequent projects have involved rolling out a large deployment of Office 365, SharePoint Online intranet, build of a "CHAMPS" Office 365 user adoption program and most recently, SharePoint On-Premise to Online Migration. Michelle is very excited about cloud technology as it is shifting her IT Pro focus to collaboration strategy and technical adoption.
  • I'm a Microsoft Office Servers and Services MVP with a special interest in SharePoint, Office 365, Microsoft Flow, Microsoft Teams and PowerApps. I work at Triad Group Plc ( https://triad.co.uk)
>