Want to leverage Azure storage for your documents in PowerApps/ Dynamics 365 portals instead of Notes? Check this out

Storing documents from portal is fairly important task in all Portal implementations. And Powerapps portals are well equipped to provide you the flexibility to integrate with SharePoint, CDS and now Azure storage accounts as well for your documents. While SharePoint and notes integrations are quite common, integrating with azure storage account requires quite a few steps to accomplish.

In am going to divide this series into couple of blog. In this one, I am going to quickly walkthrough the Azure set-up and portal set-up. In the next blog I am going to walk over the steps needed to be completed in Dynamics 365/ CDS. Read through both the blogs for complete solution. There is a nice document right up there in Microsoft Docs but every now and then while configuring you miss some steps.

I have tried to get it working for myself and then mentioned the steps that I followed.

Step 1 – Set up Azure Blob storage account

You might already have this but for the sake of completion I am going to quickly walkthrough these steps.

We create an Azure blob storage account – “x4ustoragedemo” and inside it a container named  “blobstoragecontainer”.

image

Next under settings, I click on Access Keys and copy one of the access keys connection string. Either Key1 or Key2 is fine

image

Store the connection string we will use it later.

Under settings section, select the CORS option

  • Allowed origins: Specify your CRM domain. For me it is – https://xrm20206.crm.dynamics.com. Make sure you don’t have any trailing slash at the end. It won’t work
  • Allowed verbs: GET, PUT, DELETE, HEAD, POST
  • Allowed headers: Specify the request headers that the origin domain may specify on the CORS request. For example, x-ms-meta-data*, x-ms-meta-target*, or * to allow all.
  • Exposed headers: Specify the response headers that may be sent in the response to the CORS request and exposed by the browser to the request issuer. For example, x-ms-meta-*, or * to allow all.
  • Maximum age (seconds): Specify the maximum amount time that a browser should cache the preflight OPTIONS request. For example, 200.
image

We are done with all the settings from azure storage account perspective.

Step 2 – Configure the portal settings and site settings

Go to your portal management app and create the below settings. Thinking why the word settings is highlighted? Well we are so accustomed to create site settings, that unknowingly you may create a site setting instead of setting and then spend quite a few hours finding out why azure storage integration is not working. So it is Portal Management –> Settings

Setting 1

Name: FileStorage/CloudStorageAccount

Value: The connection string we copied in our earlier step

Setting 2

Name: FileStorage/CloudStorageContainerName

Value: You azure blog storage container name

Our settings are done. Now the below are site settings. Go to Portal Management –> Site Settings

Site Setting 1

Name: WebFiles/CloudStorageAccount

Value: Put the same value specified for FileStorage/CloudStorageAccount

Site Setting 2

Name: WebFiles/StorageLocation

Value: AzureBlobStorage

Site Setting 3

Name: HTTP/Access-Control-Allow-Credentials

Value: true

Site Setting 4

Name: HTTP/Access-Control-Allow-Headers

Value: *

Site Setting 5

Name: HTTP/Access-Control-Allow-Methods

Value: GET, PUT, DELETE, HEAD, POST

Site Setting 6

Name: HTTP/Access-Control-Allow-Origin

Value: <your crm url without any trailing slash>

Site Setting 7

Name: HTTP/Access-Control-Expose-Headers

Value: *

Site Setting 8

Name: HTTP/Access-Control-Max-Age

Value: 300 (it’s value in seconds, you can specify 200/ 100 as well)

Step 3 – Configure portal to enable Azure storage.

You can do this in couple of ways. You can enable Attach files of your entity form with Azure storage enabled or you can configure notes integration with the Azure storage account. I will show you both

To enable attach files feature of the entity, go to your entity form –> additional settings tab

image

You can also configure the Notes form metadata. Go to entity forms –> Entity form metadata. And create a notes form metadata. Your notes for metadata configuration as shown below.

image

To verify whether this configuration is working or not, I just open up a record and upload a file in the note section. As you can see the image file got uploaded.

image

The document is uploaded in Azure storage as well.

image

We are all done from portal side and azure storage side. We will not modify the settings the in CDS/ Dynamics 365 to complete the process. Please follow the next blog for the same.

Hope this helps!

Debajit Dutta

(Business solutions MVP)

For training and consulting please reach out to us  at info@xrmforyou.com