Redact sensitive information in a document
Solution Overview
Components:
- SharePoint document libraries hold original and redacted documents.
- PowerApps provides a friendly user interface to review and select the text to be redacted.
- PowerAutomate calls an Azure function that redacts the selected text and saves it back to SharePoint.
Get the solution
- Download the Power Platform solution from GitHub.
- Update the environment variables to reflect the configuration in your tenant.
- Deploy the Azure function to a resource group.
Easy to use interface with PowerApps
PowerApps makes the process of viewing and selecting text to redact easy for the user:
- A list box on the left is populated with documents from a library.
- The metadata extracted using Microsoft Syntex is displayed on the right.
- Using the PDF Viewer, users can find text in the document to redact. Since there isn’t a method to capture highlighted text in the PDF Viewer, a simple right mouse click and copy allows you to paste it in a text box.
- Clicking the Redact button will send the document and selected text to PowerAutomate where an Azure function is called to redact and return the document.
- The newly redacted document is added to a document library.
Once the document is redacted, PowerApps displays it to the user.
Azure Function Setup
In your Azure subscription you’ll need to create a new resource group (or use an existing one) that will hold the Azure function. This will set up all the necessary components you need, specifically the Endpoint to invoke the service and key to authenticate properly. I created a new resource group on Azure to contain all the components we’ll need.
The URL will be needed in the Power Automate environment parameters as the endpoint for the Azure function.
Power Automate
The core of the solution resides in Power Automate. Activities can be configured to send the document and selected text to be extracted to the Azure function and then add the redacted document back to the document library, all initiated by the Redact button in PowerApps by the user.
Power Automate core activities
Step by step
Let’s break down each activity in Power Automate to understand what’s going on.
Get the file.
The FileContentID variable is passed from PowerApps and represents the ID of the document the user wants to redact information from. We’ll use this later in the process.
Initialize and set a variable representing the phrase to redact. This will be passed from PowerApps representing the text selected by the user.
Using the compose activity in PowerAutomate, it’s critical to convert the content of the file to a base64 binary format. The Azure function needs this format to process the PDF properly.
A few things to consider when calling the Azure function:
- The URI is derived from the Azure function endpoint created in the resource group.
- The selected text that will be redacted in the document needs to have the “redact” name in the body.
Create a new file in SharePoint using the redacted file returned by the Azure Function.
Deploy the Azure function
As part of this solution, I have created an Azure function that will need to be deployed to the resource group created earlier. Download the Visual Studio solution from GitHub and deploy it to a resource group in Azure.
Comments
-
Redact sensitive information in a document
You can also automate redaction of sensitive information using Encodian’s Redact PDF action. Example solution here:
https://www.encodian.com/resources/flowr/redact-sensitive-data-from-pdf-documents-in-power-automate/
-
Redact sensitive information in a document
This is a fantastic solution, thanks for sharing!
The Power Platform solution on your GitHub unfortunately doesn't include the Power Automate workflow(s).
It only appears to have the canvas app and environment variables. Perhaps it wasn't part of the solution when you exported?
Looking in the ZIP file I don't see the any flow(s) in there.
-
Redact sensitive information in a document
Is that something I am supposed to do AFTER importing? When importing, I get an error about "missing dependencies". The error says:
You'll need to import the following items to this environment in order to import DocumentRedaction
Display name: dev_RedactionSiteCollection
Type: EnvironmentVariableDefinition
Required by: dev_RedactedLibrary
Type: EnvironmentVariableDefinition
-
Redact sensitive information in a document
When you import the solution into your Power Platform environment, it will contain all the components used within Power Automate. Select the environment variables and update them with your credentials, site, library etc.
Alternatively you can go into the Power Automate flows and remove the environment variables reference and put in your list/library/site information.
-
Redact sensitive information in a document
What do we need to edit to get this working in our environment? You just say to update the environment variables, but I don't know what I should be updating.
*This post is locked for comments