Breaking news from around the world
Get the Bing + MSN extension
Now Available in Community - MBAS 2019 Presentation Videos
Catch the most popular sessions on demand and learn how Dynamics 365, Power BI, PowerApps, Microsoft Flow, and Excel are powering major transformations around the globe. | View Gallery
2019 release wave 2 Discover the latest updates to Dynamics 365Release overview guides and videos Release Plan | Early Access Availability
Ace your Dynamics 365 deployment with packaged services delivered by expert consultants. | Explore service offerings
Connect with the ISV success team on the latest roadmap, developer tool for AppSource certification, and ISV community engagements | ISV self-service portal
The FastTrack program is designed to help you accelerate your Dynamics 365 deployment with confidence.
FastTrack Program | Finance TechTalks | Customer Engagement TechTalks | Talent TechTalks | Upcoming TechTalks
In this blog article, we will see how to access Azure Blob storage and create document in CRM by reading a specific blob document in Azure.
Since we cannot use external DLL in CRM online plugins, we are going to use the Web request to access the Azure blob storage. The HTTP web request has a bunch of headers along the above details to successfully access Azure blob storage.
For this, I have used a RestHelper and BlobHelper utility code files, which have all the operations of (a) making a web request and (b) performing blob operations.
The Helper files and the CRM plugin sample can be found in the below GitHub link: GitHub: CRM Online Integration with Azure Blob
Using this we can get the document and create Annotation in CRM using the below code:
#region Connect and fetch the data from Blob storage
// Replace the below values with actual details from your Azure Blob storage
string storageAccount = "blobstorageaccountname";
string filename = "filenamehere"; // testdocument.pdf
string containerName = "containernameHere"; //documents
string storageKey = "primaryaccesskiyeofazureblobstorageaccount";
BlobHelper blobHelper = new BlobHelper(storageAccount, storageKey);
KeyValuePair<byte, string> data = blobHelper.GetBlobResponse(containerName, filename);
byte body = data.Key;
string contentType = data.Value;
#region Create Annotation in CRM
string encodedData = System.Convert.ToBase64String(body);
Entity Annotation = new Entity("annotation");
Annotation.Attributes["objectid"] = new EntityReference(workOrder.LogicalName, workOrder.Id);
Annotation.Attributes["objecttypecode"] = workOrder.LogicalName;
Annotation.Attributes["subject"] = "Document from AX Integration";
Annotation.Attributes["documentbody"] = encodedData;
Annotation.Attributes["mimetype"] = contentType;
Annotation.Attributes["notetext"] = "REST API - Sample document from AX.";
Annotation.Attributes["filename"] = entity.GetAttributeValue<string>("cf_name");
Guid annotation = service.Create(Annotation);
The post Accessing Azure Blob storage from CRM Online Plugin appeared first on CloudFronts - Microsoft CRM | AX | BI | Azure.
Business Applications communities