Automate Document Creation using Microsoft Word Connector
Azure Logic Apps has traditionally been used to collect data and integrate systems that require this information. These systems may reside in the same organization or organizations spread out across the globe. However, a new capability has been recently released that allows documents to be created through Azure Logic Apps using the new Microsoft Word Connector.
In this tip, we will take data from Azure SQL and use it to populate a Word Document using the following steps:
Create all the necessary content for your document
Enable Developer tools in Microsoft Word by clicking on File – Options – Customize Ribbon and then check-on Developer.
For each field that you want to populate add a Plain Text Content Control from the Developer menu.
Also, ensure that you edit the Properties for each text control so that you can provide a descriptive name which will help when mapping data attributes in the Logic Apps designer.
Repeat these steps for remaining fields and save to One Drive for Business.
With our Word document in place, let’s now shift gears over to the Azure Portal where we will build our Logic App. Our Logic App consists of a Recurrence trigger followed by an Execute SQL query action that will retrieve customer records from our database. We now need to add the Microsoft Word connector and use the Populate a Microsoft Word template action. Within this action, we need to configure where our Microsoft Word document exists within our One Drive for Business folders. We can now map all of the fields that we previously created within our Word Document.
The output of the Populate a Microsoft Word template action is a word document. But we need to write this content out, in order to use it. We will use the Create file action found in the One Drive for Business connector to accomplish this.
We are now ready to test our logic app by invoking our trigger. When our logic app completes running, we need to check our One Drive for Business folder to find our newly created file. When we open it, we will discover our template has been populated.
In this post, we discussed a new feature available in Azure Logic Apps that allows you to use a Microsoft Word document as a template and then send data from Logic Apps. Considering that Azure Logic Apps has access to more than 230 connectors, this becomes a very powerful scenario as you can now merge data to many data sources, or a combination of data sources, that Microsoft Word previously never had access to.