In this blog post, I’ll describe how to upload files to Azure Blob Storage using Power Pages, a powerful tool for building secure web applications. This walkthrough streamlines the process, walking you through the steps to successfully integrate Azure’s scalable storage with Power Pages for robust file management in your web solutions.
Why integrate Azure Blob Storage with Power Pages?
I could think of several reasons for someone to integrate Azure Blob Storage with Power Pages. Now, I’ll list a few of where this would benefit you.
- Security: Azure Blob Storage features, such as encryption, information privacy, secure transfer, data in transit encryption, anonymous access management, MS Entra ID integration, and SAS access, ensure your data is protected.
- Scalability: Blob Storage can manage massive volumes of data, making it ideal for applications with heavy data storage needs.
- Cost-effective: Azure Blob Storage has several available pricing tiers (Hot, Cool, Archive)
Prerequisites
- An active azure subscription
- An Azure Blob Storage container
- A Power Pages portal
- Configure security roles in Power Pages with Azure Storage
- Add new form to a page
- Configure the appropriate security roles to the storage account
Enough said! Let’s procced to the demo
I will begin the deployment by creating the Azure Storage Blob.
Create Azure Blob Storage with a container
This link in this section will lead you to an article that describes how you can spin up an Azure storage account with a blob container to upload and store your files.
Create a blank Power Pages Portal
Clicking the link below will take you to an article that walks you through how to build a new, blank Power Pages portal in minutes.
Configure the appropriate security roles to the storage account
In the next section, I will explain the security role configuration to allow the Power Pages portal to access the Azure blob container to upload the file.
A new application entry is added to the MS Entra ID during the Power Pages portal deployment, i.e. PowerPageBlobUploadDemo.
Add the Reader role at the resource group level
Open the Resource group, and on the left-hand side blade, tap on Access control (IAM) and then press + Add.
Choose the Role > Add role assignment and find and select the Reader role.
Now, choose to assign the role to the service principal, i.e. PowerPageBlobUploadDemo. To complete the role assignment, press the Review + assign button.
Add the Storage Blob Data Contributor role at the Storage account level
Open the Resource group, and on the left-hand side blade, tap on Access control (IAM) and then press + Add.
Choose the Role > Add role assignment and find and select the Storage Blob Data contributor role.
choose to assign the role to the service principal, i.e. PowerPageBlobUploadDemo, tap on Select.
To complete the role assignment, press the Review + assign button.
Configure the Upload form in Power Pages
In this section, I will create and configure a form in Power Pages.
Add new form to a page
Tap on the Form,
select + New form
On the Form section, choose a table, where you want to store the uploaded files, choose a form and type a name for the copied form.
Since I want to upload files when I create a new record, I choose from the Data from this form drop-down the “Creates a new record” option.
On submission, I will set a message to display
I will turn off CAPTCHA
On Attachments is where the “magic” is happening. I enable attachments and Allow multiple files, type a display label for the attachments form, and allow the file type to upload.
Type the name of the Azure storage account and the name of the container you have created in the previous steps and tap OK.
It’s time to test
That was it! I’m about to check the configuration to verify that it is working, and I can upload the file to the Azure Storage container via the Power Pages portal.
I have opened the blank Power Pages portal, and I’m uploading an image, as the picture below depicts.
The message is that I expect to be i.e., a successful upload
Finally, I’m verifying that the file has been uploaded and landed in the Azure storage blob container.