cancel
Showing results for 
Search instead for 
Did you mean: 
themsenduser

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.

This is ignoring the folders structure. What if I wanted to Sync the whole library regardless of the folder structure not only files but also folders?

Thanks for this article @themsenduser 
Is it possible to use a similar approach to sync a Sharepoint Library or files to an Azure File Share on an Azure Storage account, rather than a blob?
Any hints on how to do this?

About the Author
  • Experienced Consultant with a demonstrated history of working in the information technology and services industry. Skilled in Office 365, Azure, SharePoint Online, PowerShell, Nintex, K2, SharePoint Designer workflow automation, PowerApps, Microsoft Flow, PowerShell, Active Directory, Operating Systems, Networking, and JavaScript. Strong consulting professional with a Bachelor of Engineering (B.E.) focused in Information Technology from Mumbai University.
  • I am a Microsoft Business Applications MVP and a Senior Manager at EY. I am a technology enthusiast and problem solver. I work/speak/blog/Vlog on Microsoft technology, including Office 365, Power Apps, Power Automate, SharePoint, and Teams Etc. I am helping global clients on Power Platform adoption and empowering them with Power Platform possibilities, capabilities, and easiness. I am a leader of the Houston Power Platform User Group and Power Automate community superuser. I love traveling , exploring new places, and meeting people from different cultures.
  • Read more about me and my achievements at: https://ganeshsanapblogs.wordpress.com/about MCT | SharePoint, Microsoft 365 and Power Platform Consultant | Contributor on SharePoint StackExchange, MSFT Techcommunity
  • Encodian Owner / Founder - Ex Microsoft Consulting Services - Architect / Developer - 20 years in SharePoint - PowerPlatform Fan
  • Founder of SKILLFUL SARDINE, a company focused on productivity and the Power Platform. You can find me on LinkedIn: https://linkedin.com/in/manueltgomes and twitter http://twitter.com/manueltgomes. I also write at https://www.manueltgomes.com, so if you want some Power Automate, SharePoint or Power Apps content I'm your guy 🙂
  • I am the Owner/Principal Architect at Don't Pa..Panic Consulting. I've been working in the information technology industry for over 30 years, and have played key roles in several enterprise SharePoint architectural design review, Intranet deployment, application development, and migration projects. I've been a Microsoft Most Valuable Professional (MVP) 15 consecutive years and am also a Microsoft Certified SharePoint Masters (MCSM) since 2013.
  • Big fan of Power Platform technologies and implemented many solutions.
  • Passionate #Programmer #SharePoint #SPFx #M365 #Power Platform| Microsoft MVP | SharePoint StackOverflow, Github, PnP contributor
  • Web site – https://kamdaryash.wordpress.com Youtube channel - https://www.youtube.com/channel/UCM149rFkLNgerSvgDVeYTZQ/