Microsoft Dynamics 365 Storage Pitfalls – Here is the Cost Effective Solution

In Microsoft Dynamics 365, by default, database is optimized for database record storage and not for files or attachment storage. Hence, cost effective storage management of huge sized data files becomes one of the most critical aspects for the organizational users. This blog narrating the process of optimizing storage capabilities of Microsoft Dynamics 365 CRM using Azure Blob and SharePoint.

Azure Blob is much known for storing large amounts of unstructured object data including images, audios and multimedia. Whereas apart of its document storage, management and other offerings, SharePoint also allows the record wise sorting of the documents. Hence, optimizing the Microsoft Dynamics 365 CRM storage using both Azure Blob and SharePoint could be an easy, efficient and viable solution.

Azure Blob Storage Configuration

Let’s be clear with our basic requirements:

  • The Web Resources to create custom UI to add and view the data files
  • Azure Blob configuration into the CRM in order access the information of the blob storage. We will create a setting entity to add azure account name and key there

Following the process described below to configure Azure Blob storage

[1] Setup the Environment

Use the URL https://portal.azure.com and search for ‘storage’ in search panel. Select the Storage accounts (Blob) from the displayed search results.

Once you are navigated to ‘Storage accounts’ dashboard, click ‘Add’ in order to create a new account.

Either key in or select from dropdown options the relevant details for to each field.

  • Name
  • Account kind: Blob Storage – Must be Blob Storage
  • Replication: Keep Default
  • Subscription: Usage-Based
  • Resource Group: Select the Resource Group

Assure that the created storage is available in the list of storage account.

Create an Image Blob to store the image contents

  • Name: Key in the Blob name
  • Public access level: Select Blob

Accumulate the relevant Access Key details from the storage account and store into the CRM.

  • Storage account name
  • Key1
  • Key2

Once we done with the above configuration we need to create JavaScript or .Net plugin to integrate Azure API.

[2] Upload the File to Azure

[3] Delete the File from Azure

SharePoint Configuration

[1] Enable server-based integration from CRM

To Integrate SharePoint with the CRM, we need to enable the server-based integration from CRM Setting.

Follow the path: CRM Instance >> Setting >> Document Management >> Enabled Server Based SharePoint Integration

(a) Define Deployment

(b) Prepare Sites

(c) Validate Sites

(d) Finish Sever Based integration

[2] Power Attachment Integration

There are several methods to configure SharePoint. Here is the one with Power Attachment integration. In order to upload documents to SharePoint, you can use Power Attachment, the add-on from PowerObjects. You need to add relevant information to the Power Attachment solution. Follow the described steps for the same.

  • Enable SharePoint Integration
    • Go to Setting Document Management >> Document Management Setting
    • Select Entities
    • SharePoint Site : https://<instance>.sharepoint.com/sites/documents
    • Click Next and allow CRM to Create Folder Structure
    • Finish the document creation
  • Go to Setting Solutions >> PowerAttachment Solution
  • Configure Profile Tab and check with “Test CRM Credentials”
  • Configure Setup Tab and check with “Test SharePoint Credentials”
    • Location Type: Share Point
    • URL : https://<instance>.sharepoint.com
    • Username: Enter CRM Admin User
    • Password: Enter Password
    • Document Liabrary: Create Sharepoint Document Library
    • SharePoint Type: Online
    • Attachment Types: “doc,docx,xls,xlsx,ppt,pptx,zip,rar,pdf”
    • Overwrite File: No
    • Service Provider: Central
    • Save To Regarding Folder: Yes

Once the Power Attachment configuration is completed successfully, we can attach any document of the selected entities and the document will automatically be uploaded to SharePoint

[If you find any difficulties with configuration of Power Attachment, you can find the help at https://www.powerobjects.com/guides/powerattachment/]

[3] Facilitate to read Documents from SharePoint using Customized/Coding Flow

In order to facilitate the reading of documents from the SharePoint, we need to integrate an API that can access the data. Hence, the relevant setup and authentication process is required. Follow the described steps for the same.

[a] Register Add-In

It is necessary to register the Add-In in SharePoint where you want to access the information. Follow the steps described below to register the Add-In in SharePoint site.

  • Login to SharePoint online site
  • Use the URL https://<sitename>.SharePoint.com/_layouts/15/appregnew.aspx to Register Add-In page
  • Visit App Information section, click the Generate button displayed next to Client Id and Client Secret textboxes to generate the respective values
  • Title: Enter Add-In Title
  • App Domain: as a localhost
  • Redirect URL: as https://localhost (Need to keep as localhost)

Click on Create button. The Add-In will be registered followed by the success message pop up. Carefully note down the displayed information.

[b] Grant Permissions to Add-In

Once you are done with registration Add-In, you need to set the permissions for that Add-In to access the SharePoint data. We will set the Read permission level to the web scope, so that we will be able to read the web information.

Navigate to the SharePoint site and enter the URL: “https ://< sitename>.sharepoint.com/_layouts/15/appinv.aspx” in the browser to get redirected to Grant permission page.

Enter the Client ID noted from Add-In registration success message in AppId textbox and click Lookup button. That will populate the value to other textboxes in Title, App Domain and URL

Enter the below permission request in XML format

Then click on Create button. This will redirect to you to the page displayed below as image. Here, you need to authorize the add-in as trusted to read items from website.

[c] Retrieve the Tenant Id and Resource Id

Once you are done with registration of the Client Id along with relevant the permissions, you are ready to access the SharePoint information from the external system or tools.

As a process, first you need to know the Tenant Id. Follow the steps described below to obtain that information from postman.

  • Launch Postman Or other REST Client (chrome extension)
  • Select Get Method, enter the URL given below in Request URL textbox “https://<sitename>/sharepoint.com/_vti_bin/client.svc/”
  • Configure the below information in the header section to send along with the url requestMethod = Get Headers

Key

Value

Authorization

Bearer

  • Collect the relevant information required for the configuration such as
    • Client Id: 45df14e8-1948-4ac2-aa01-8bb87b90862f
    • Client Key: 9q+5iXvdExjoDFxmSKUy2EooSz9auxk8hXbh3u72v+0=
    • Tenant Id: cf29bdef-c7f8-4b5f-9dad-d088ea24a441
    • Resource Id: 00000003-0000-0ff1-ce00-000000000000
    • We have to add this information under the Setting, same as below image.

Once we done with the above configuration we need to create JavaScript or .Net plugin to integrate SharePoint API.

Sample Code to Read File

Conclusion

In this blog I have narrated the entire process of optimizing the storage capabilities of Microsoft Dynamics 365 using Azure Blob Storage and SharePoint Storage along with detailed configuration process. This integrated solution can optimize the storage capabilities of Microsoft Dynamics 365 largely.