Plug & Play Portal Solution – Automate Backup of Portal Custom Code

Introduction:

Welcome everyone to the Power Guide Mentorship Program.


Today I am going to share PowerGuideTip#13 that will help developers to take the Backup of Portal Custom Code.

In PowerApps Portals or Dynamics CRM Portal, developers often use the following Components to write the Custom Code:
  • Webpage –   Copy/HTML Code, Custom JavaScript, Custom CSS.
  • Web Template – Liquid Template
  • Entity Form – Custom JavaScript
  • Entity List – Custom JavaScript
  • Web Form Steps – Custom JavaScript
  • Content Snippet – HTML Code
Currently, we have the following challenges with respect to PowerApps Portals Backup:
  • No OOB way to take custom code backup like javascript, HTML, and liquid template.
  • Developers have to take the custom code backup manually.
  • Developers need to put extra effort in order to take backup manually after development work.
  • No OOB way available to schedule the portal code backup.
  • Risk of loosing/accidentally removing or deleting the code.
  • As of now, to take the backup, we can only take the whole portal configuration export using the Configuration Migration Tool. We can also schedule the whole configuration backup also using Azure DevOps You can check my article here.
  • Developers have to manually identify the modified code and take the backup on a daily basis.
To overcome all the above challenges and make the every Portal Developer life easy, I have designed a Low Code No Code Solution using Power Automate. By using that, portal developers can Schedule and Automate the Portal Custom Code backup and store it in SharePoint/Local Machine/DropBox/One Drive/Azure Blob Storage, etc
Solution Architecture:







Pre-requisites:
  • Dynamics 365 Instance/Trial
  • PowerApps Portals Subscription/Trial
  • Power Automate Subscription/Trial
  • SharePoint Subscription/Trial
  • SharePoint Site
Steps to implement the solution

Step 1:  Create Portal Site Settings

Portal Backup Site Setting
Name: Portal Backup

Value: true
This site setting will decide, whether you want to automate the Portal custom code backup or not.
If the Site Setting Value is true – Portal Automate will automatically schedule the Portal Backup. 
If the Site Setting Value is false – Power Automate will not schedule the Portal Backup.

Portal Backup Entities Site Setting
Name: Portal Backup Entities

Value: { “BackupEntities” : [{ “WebPage”:”adx_webpage”, “WebTemplate”:”adx_webtemplate”, “EntityForm”:”adx_entityform”,”EntityList”:”adx_entitylist”,”ContentSnippet”:”adx_contentsnippet”,”WebForm”:”adx_webform”} ]}
This site setting decides, what all portal entities you want to include in order to take custom code backup. 
If you want to take the back up of a specific entity, then the site setting value should be changed accordingly. For Example Following site setting value will take the backup of web template code only.
{ “BackupEntities” : [{ “WebTemplate”:”adx_webtemplate”} ]}

For only WebPage Copy/HTML, Custom JavaScipt and Custom CSS code

{ “BackupEntities” : [{ “WebPage”:”adx_webpage”} ]}

For only Entity Form Custom JavaScript Backup:

{ “BackupEntities” : [{ “EntityForm”:”adx_entityform”} ]}

For only Entity List Custom JavaScript Backup:

{ “BackupEntities” : [{ “EntityList”:”adx_entitylist”} ]}

For only Web Form Steps Custom JavaScript Backup:

{ “BackupEntities” : [{ “WebForm”:”adx_webform”} ]}

For only Content Snippet Html Code Backup:

{ “BackupEntities” : [{ “ContentSnippet”:”adx_contentsnippet”} ]}
For all the above Entities
{ “BackupEntities” : [{ “WebPage”:”adx_webpage”, “WebTemplate”:”adx_webtemplate”, “EntityForm”:”adx_entityform”,”EntityList”:”adx_entitylist”,”ContentSnippet”:”adx_contentsnippet”,”WebForm”:”adx_webform”} ]}


Step 2:  Download the Power Automate Solution from GIT HUB

Please find my PortalBackupScheduler_1_0_0_0_managed.zip solution from GIT HUB Repository
Step 3: Import the Solution in your Dynamics 365 Instance

The imported solution has Power Automate, that:
  1. Runs every day at 10:00 PM.
  2. Retrieve all Webpages, Entity Forms, Entity Lists, Web Templates, Web Form Steps, and Content Snippets records, that either has been Created or Modified Today.
  3. Create Portal Backup Folder at given SharePoint Site Address.
  4. Create Today’s Date Folder inside Portal Backup Folder.
  5. Create a folder for each entity (specified in Site Setting) like Webpage, Entity Form, etc
  6. Store the Html/JavaScript/CSS/Liquid Template code in specific entity folder.
Step 4: Edit the Power Automate and Update as per your need/requirement/configurations

Open the imported solution (Portal Backup Scheduler) > Select Power Automate (Schedule Portal Backup) > Click Edit from Toolbar
Update Power Automate Schedule Date & Time:

Update the Recurrence Step to schedule the Power Automate as per your need.
For Example – I have scheduled the Power Automate- Every Day at 10:00 PM
Update SharePoint Site and Folder to store the backup files:

Find Create SharePoint Folder’ and Create SharePoint File’  Steps in Power Automate and change the SharePoint Site Address as per your SharePoint site configuration.
Update SharePoint Site Address in Create SharePoint Folder step
Update SharePoint Site Address in Create SharePoint File step
For Example, My SharePoint Site name is Power Guide and Site Address is:
https://365saturdaysdemo.sharepoint.com/sites/PowerGuide

Rest all the configuration in Power Automate will remain the same.
Step 5: Run and Test the Solution

You can manually trigger the Power Automate to test the flow.
Documents > Portal Backup
Documents > Portal Backup > Today’s Date Folder

Documents > Portal Backup > Today’s Date Folder > Web Pages 


Important Tip:
You can reuse this Power Automate solution to store the backup files in other places as well based upon your requirement/licensing model and configuration. You only need to replace the SharePoint Steps with your Storage Connector.
For Example: Instead of SharePoint, if you want to store the Portal Backup Files somewhere else, then you have the following other options as well:
  • Local Machine
  • Dropbox
  • One Drive
  • Azure Blob Storage
  • ….many more
I hope this article finds you interesting and helpful especially for Portal Developers.

Stay Tuned for more such Interesting Solutions and Tips

Cheers
- Advertisement -

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisement -

Latest News

Join Us! Power BI Dev Camp! Thursday 28 January, 2021

Learn how to get started designing and implementing custom visuals for Power BI. Attendees will learn how to define...
- Advertisement -

More Articles Like This

- Advertisement -