Design a site like this with WordPress.com
Get started

Saving a note attachment to Azure Blob storage and Viewing it on PowerApps Portals

I have been Exploring with Olena (https://msolenacrm.blog/) how to enable the azure storage on PowerApps portals and she has figure out and detailed on her article how to enable azure blob storage on PowerApps portal so when a note is uploaded from portal it is saved to Azure blob storage and that’s worked perfectly fine and was shown very nice on the DataVerse model driven app !

https://msolenacrm.blog/2021/07/20/azure-storage-integration-for-power-apps-portals/

But in our case we generate the documents internally on specific system action triggers and we want to save it as a Note and save this note to Azure Blob Storage and get this Note to be displayed in the Portal as well so let’s get started!

So what we need to be done to get the note created in the same format created by the portal and to do so I did a bit of reverse engineering to what was happening and it is explained in the below simple steps.

  1. Note uploaded from PowerApps Portal saved to azure and a URL was returned.
  2. A new text file has been created in the below JSON format and saved as a normal DataVerse note.
{
  "Name": "Document.pdf",
  "Type": "application/pdf",
  "Size": 113881,
  "Url": "https://portallogs.blob.core.windows.net/portaldocs/58d6964234e5eb11bacb00224814f2af/Document.pdf"
}

3. The new note file name was filename.pdf.azure

4. The new note title and description was prefixed by *WEB*

5. Observed how this note was actually saved in azure container.

So Let’s get started with how this was achieved using Power Automate.

  1. Trigger was on a note creation and of course you can add whatever filtration criteria to which notes should be uploaded to azure and displayed on portal.

2. Second step we are going to create a new note and give the title and description the Prefix *WEB*, Also you need to set the regarding to the regarding of the originating note.

3. Then we need to get the GUID of the newly created note and replace the – with ” to be able to construct the path where the file will be saved in the Azure container to mimic the way the note is saved in azure by the portal.

replace(outputs('Create_New_Note')?['body/annotationid'],'-','')

4. Use the Create Blob(V2) to save the file to azure blob

Blob Name: /Note GUID/File Name of the originating Note

/@{outputs('NoteGUID')}/@{triggerOutputs()?['body/filename']}

Blob Content:

base64ToBinary(triggerOutputs()?['body/documentbody'])

5. Using a compose data operation we generate the File path of the created azure blob storage by a simple concatenation.

concat('https://','portallogs.blob.core.windows.net',outputs('Create_blob_(V2)')?['body/Path'])

6. Using a compose data operation to generate JSON format of the file that will be attached to the newly generated note in step 2.

Name: File Name from originating note from Trigger.

Size: from the outputs of the Create Azure blob step

URL: from the outputs of the File Path compose operation in step 5

7. Save this file content to the newly created note in step 2 by an Update a row action

8. Final Step: Delete the originating note !

This is how the new note appears In DataVerse.

Hope this is useful!

References:

https://docs.microsoft.com/en-us/connectors/azureblob/?WT.mc_id=DX-MVP-5004221

https://docs.microsoft.com/en-us/powerapps/maker/portals/configure-notes?WT.mc_id=BA-MVP-5003463

Advertisement

One thought on “Saving a note attachment to Azure Blob storage and Viewing it on PowerApps Portals

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: