1
ATTACHMENT MANAGEMENT
USING AZURE BLOB STORAGE
A Solution to help optimize Dynamics 365 CRM storage by automatically saving file attachments to Azure Blob Storage - MICROSOFT LABS
2
Contents 1. Overview --------------------------------------------------------------------------------------------------------------------- 3
2. Attachment Management Configuration ---------------------------------------------------------------------------- 3
2.1 UI Configuration -------------------------------------------------------------------------------------------------------- 4
2.2 Notes Attachment Entity Settings ---------------------------------------------------------------------------------- 5
2.3 Optional Configuration ------------------------------------------------------------------------------------------------ 6
3. End User Experience ------------------------------------------------------------------------------------------------------ 9
4. Reports and Admin ------------------------------------------------------------------------------------------------------- 10
5. How to confirm files are getting stored in Blob ------------------------------------------------------------------- 12
6. Custom entity (Azure Blob Storage Settings) access, by other Roles (apart from SYSTEM ADMIN) -- 15
6.1 Least Permissions required for users ----------------------------------------------------------------------------- 17
7. How to Generate SAS Key ---------------------------------------------------------------------------------------------- 17
8. Troubleshooting Steps --------------------------------------------------------------------------------------------------- 20
3
1. Overview
The Attachment Management Solution is an add-on feature to dynamics 365 CRM to manage
note and email attachments using Azure Blob storage. It enables users to create and maintain
files stored on Azure Blob through the D365 CRM application. This solution benefits
organizations with large amounts of file attachments by storing the files in Azure Storage
rather than the CRM database. This reduces the cost of storage since Azure Storage is
significantly less expensive than additional Dynamics 365 Storage.
Attachment Management benefits:
All attachments stored in Azure Blob • Optimizes the use of Dynamics 365 storage. • Attachment retrieval on demand.
Multi attachment upload/Download Control (Optional) • Drag/Drop. • One-click download of multiple selected attachments. • Preview of attachments.
This solution is built on Dynamics 365 and seamlessly works on Dynamics CRM 2016 and above.
2. Attachment Management Configuration
The Attachment Management solution can be used for any Dynamics 365 system or custom
entity, which is enabled for Notes and attachments.
The below diagram summarizes the configuration and usage of Attachment Management
solution and the processes that runs in the backend.
This section outlines the steps to be performed by a System Administrator to make Solution
available to the end users. Pre-requisites:
1. Valid Windows Azure Subscription and Storage Account (Blob) created
2. Attachment Management solution installed in the Dynamics 365 organization
4
2.1 UI Configuration
1. Open Microsoft Dynamics 365 2. Navigate to Azure Attachment Storage -> Azure Attachment Storage Configuration
3. Click on Azure Attachment Storage Configuration to provide azure storage configuration information
5
Name: Azure Storage Account Name SAS token: SAS token available in the Storage Account. (How to Generate SAS)
Note: Please make sure the Start Time and End Times are chosen correctly while
generating the SAS token. Please refer “Best practices when using SAS” section here
for more information on Start Time. Notes attachment Container Name: Container name created for Notes Email Attachment Container Name: Name of the container created for the email attachment.
2.2 Notes Attachment Entity Settings
Navigation: Azure Attachment Storage -> Setup -> Notes Attachment Entity Setting
This section provides information on, the purpose of Notes Attachment Settings.
Notes Attachment Setting Page, is to provide the System Admin a complete choice of
choosing the entities (annotations attached) along with its respective container, to move
only notes attachment to Azure Blob Storage from CRM, which are associated with
Annotations entity.
System Admin, can select the required entities in the list (Entities available in the list are
with Schema Names. For Eg: If it’s the Case entity that Admin wants to select, it’s available
as incident in the list) available on the Notes Attachment Setting Page with created
container name with respective to that entity, as shown below. Once the System Admin
selects entities and containers and clicks on save button, the notes attachments which are
available in the selected entities will only be moved to Azure Blob.
6
Note:
1. If none of the entities have been selected from the available entities in the Notes
Attachment Setting Entity list, notes attachments won’t be moved to Azure Blob Storage.
2. If only entity has been selected and container name is not provided, then notes container
name will be taken by default from Azure Blob Storage Settings page.
3. Whenever we are applying container name in front of respective entity then make sure
that container is correct and proper, and we must keep as it is for forever, we should not
change the container name once notes attachments are moving to blob. We must keep
entity’s container name as it is because if we will change then it cannot retrieve the older
attachment data which are moved to blob.
4. CRM Portal: To reflect the UI changes done on CRM Portals, the CSS and Image files to be stored in CRM only. So, while selecting the entities from the Notes Attachment Setting Entity list, please un-select the entity called adx_webfile to maintain the UI changes implemented on portals.
2.3 Optional Configuration
This section provides information on optional functionality of uploading multiple Notes and
attachments at one go offered by Attachment Management solution by using web
resources into the Entity form. Here we have provided example of tab created on business
entity case main form.
Below are the required web resources for attachment functionality.
7
msdyn_filesandattachments.html:
This web resource will list all the Notes and email attachments in grid format on the form.
User, would able to delete and download single /multiple files from the grid.
msdyn_multiple_uploads.html:
This web resource contains the code to upload multiple files. Also, contains the code to
show only the email attachments when it is used in Email form.
Steps to configure web resources for multiple file upload functionality
1. Edit Entity form to create new tab and insert “msdyn_multiple_uploads.html” web-
resource for the multiple upload functionality for Notes and attachment.
2. Publish all changes made and navigate to case entity and open case form. User should
be able to see the tab created for the Notes and attachment uploading.
8
3. Create another Tab and name it “Attachments” to download and delete uploaded files
in one go. Insert html web resource “msdyn_filesandattachments.html” in newly
created tab.
4. Publish all changes made and navigate to Case main form. The User should then be
able to see below tab on the form.
9
3. End User Experience
Once the solution is imported and configured in the Dynamics 365 organization, a user can
upload and create Notes and store the attachments in Azure Blob Storage. The steps
outlined below illustrate creating a note with attachment and verifying the attachment is
stored in Bob Storage.
1. Navigate to a Business Entity (e.g. Case)
2. Open a Case record
3. Create a note against the case with an attachment.
10
4. Verify the Notes attachment is stored in Azure Blob storage. The file name is formed
by concatenating the parent entity record ID (here Case GUID) and attachment file
name (Agreement_Details.docx):
5b40dd-34c6-e611-80ee-346bac894c_Agreement_Details.docx
5. If a user deletes a Notes record, any related attachment will be deleted from the
Azure Blob Storage.
4. Reports and Admin
This section provides information on Reports and Admin Dashboard. Reports and Admin, is a useful tracker for CRM system Admins to track the available
attachments in CRM and number of attachments moved from CRM to blob and displays
the Notes Attachment and Email Attachments count available in CRM and moved to blob
from CRM as shown below. System Admin, now can easily move existing attachments
stored in CRM, after installing the Azure Attachment Management.
Note: MoveToBlob button will only process 140 attachments at a time. As CRM is limited
by duration that any Plugin/Custom Action can run.
11
Move To Blob:
When user clicks on Move To Blob button, it will start processing all the attachments data
stored in CRM to Azure blob storage at one go. (Once, user clicks the button, it will take
care of the all the attachments processing of moving them from CRM to Azure Blob.)
Stop Processing:
After clicking of Move To Blob button, in case if the user/system admin wants to stop the
process of moving the attachments from CRM to Azure Blob storage, yes, they can do that
any point of time once by clicking Stop Processing button. It will Stop Processing of moving
the attachments data from CRM to Azure Storage blob.
Below is the screen shot for how Reports and Admin page looks…
12
5. How to confirm files are getting stored in Blob
This section provides information on, how to confirm the files are the getting stored in
blob.
For Notes (Annotation):
Approach 1:
a. Attach a file to a case record
b. Checking the file size with the help of Advanced Find query: Where File Size = 0
c. From the above result, it’s confirmed that, the file size is ZERO in CRM DB.
Approach 2:
d. Checking the file size with the help of Advanced Find query: Where File Size > 0
13
e. The result we get is “No Note records are available in this view“.
f. So, the second query (approach) is also confirming that the file is not getting stored in
CRM.
Email Attachments:
Approach 1:
g. Attaching a file to an email record
h. Checking the file size with the help of Advanced Find query: Where File Size = 0
14
From the above result, it’s confirmed that, the file size is ZERO in CRM DB.
Approach 2:
Checking the file size with the help of Advanced Find query: Where File Size > 0
The result we get is “No Email records are available in this view“. So, the second
query also confirmed that the file is not getting stored in CRM.
Note: The File Size field value in the Advanced Find query, gets populated dynamically
from the related Blob information of that attachment, which is being handling thru a
plugin in the back-end.
15
6. Custom entity (Azure Blob Storage Settings) access, by other Roles
(apart from SYSTEM ADMIN)
This section helps on how to provide custom entity access (Custom Audit History), to other roles (apart from System Admin).
Scenario: System Admin, wants to provide Audit related info access to Sales Manager
role.
1. Login to the CRM and Go to Settings > Security.
1. Click Security Roles and click on Sales Manager role, as shown in the below screenshot.
16
2. Go to Custom Entities tab and provide all these read/write/update/assign/assigned permissions for Sales Manager, as shown below
17
6.1 Least Permissions required for users
This section helps with the information on minimal security settings permissions required
for a user to be able to store their attachments on the AZURE blob.
User should be having Read Permissions (Least Permissions) on Azure Blob Storage
Settings and Notes Attachment Setting Entities to move attachments from CRM to Blob.
How to provide the minimal security settings needed on the custom entities?
Login to CRM -> Settings -> Security Roles -> Select A Role -> Go to “Custom Entities” tab -
> Select Azure Blob Storage Settings and Notes Attachment Setting Entities and provide
Read Permissions.
7. How to Generate SAS Key
This section, helps with the steps to generate the SAS Key
1. Go to https://ms.portal.azure.com 2. Click on the Storage Account, created for Emails and Notes Attachment Containers. 3. You can find, Shared Access Signature, below to Add Azure Search, as shown below
19
Before, clicking on Generate SAS, please make sure the Start and End times for
SAS key, because by default it would be in UTC time zone, which varies with
local time zone.
Best Approach is to take your local Previous Date as Start Date and any Future
Date as End Date while Generating SAS KEY, in order to avoid access related
issues.
20
8. Troubleshooting Steps
System Administrators can use the quick tips below for troubleshooting in case of any issues:
1. Ensure Azure Storage account details have been entered correctly. 2. Ensure the plugin steps have been registered for the event e.g. Post Create of
Entity. 3. Navigate to ‘Customize the System’ and ensure you click ‘Publish all
Customizations’. 4. Make sure the Azure Blob Settings configuration information is correct e.g. The
“Name” in the Container properties pane should match the name of the Container.
Please make sure the Start Time and End Times are chosen correctly while generating the SAS token.
5. To get the custom entity (Azure Blob Storage Settings) in the Settings module,
please follow the below steps.
a. Click Settings, click Customizations and click Customize the System. b. Under Components, expand Entities and select Azure Blob Storage Settings
entity. c. Under the Areas that display this entity, select the areas to display the custom
entity. 6. Make sure user is having Read Permissions (Least Permissions) on Azure Blob
Storage Settings and Notes Attachment Setting Entities to move attachments from
CRM to Blob.
Top Related