DevOps - Implementation Of CI/CD In Microsoft Dynamics CRM

DevOps - Implementation Of CI/CD In Microsoft Dynamics CRM
 

Introduction

 
DevOps has evolved through the collaboration of two important aspects of Software Development, Development and Operations, ensuring that what is developed by the team is deployed to the  respective servers with minimal or no issues in an automated manner.
 

Problem Implementation

 
I had been working as deployment lead for a project wherein we has two different Office 365 tenants with almost 50+ instances of Dynamics CRM and 4+ Teams working over different aspects of the project including:
  • Bug Fixes
  • Sprint Development
  • UAT Issue resolution
  • Solution Upgrade
In this type of setup, as a deployment lead it was next to impossible to manage each and every deployment manually, given that the responsibilities included:
  • Creating a patch for team
  • Adding the components post validation with work items
  • Exporting the solution and importing manually to different environments
  • And multiple validation activities to ensure 100% success
The above process was error prone due to multiple reasons and a one was no proper tracking of code which had been pushed by developers in multiple releases.
 
After multiple discussions and brain storming it was decided to implement DevOps to automate this entire process.
 
Pre-requisite
  • Account of Azure DevOps
  • Visual Studio
  • Basic knowledge of Dynamics CRM
  • Solution Packager
  • PowerShell scripts

Implementation Steps

  • Create a class library project in Visual studio, will be using the same for Plugins in Dynamics CRM
  • Adding an Existing Website – CRM Solutions folder, which will be holding the different solutions exported out from Dynamics CRM
  • Created a sub folder – Scripts to hold and perform actions over the exported solutions

    DevOps - Implementation Of CI/CD In Microsoft Dynamics CRM

  • Along the same lines create another folder which will be used for holding – Web Resources from Dynamics CRM
  • And another Class Library project for Custom Workflow activities if you have any

    DevOps - Implementation Of CI/CD In Microsoft Dynamics CRM

Approach

  • First we need to download the core tools from Nuget and place it in a folder. For the same we can write PowerShell Script, in my project I have added a script which first checks whether the core tools are available or not, if it's available it's not downloaded at all. Here I am directly sharing the command which you can modify as per your need and requirement.

    DevOps - Implementation Of CI/CD In Microsoft Dynamics CRM

  • Once the core tools have been downloaded and are available, the next step is to export the solution using the WebAPI in another PowerShell script from instance of Dynamics CRM where I am passing the following parameters

    • User Credentials
    • Instance Name
    • Solution Name

  • Once the solution has been exported out, the script is creating a TEMP folder where the exported solution is kept temporarily and then components are EXTRACTED using the solution packager.
  • Command used in Solution packager is as below

    • \SolutionPackager.exe /action: Extract /zip file:"*name of folder* " /folder "*folder to store"
    • /action: {Extract Pack}

  • exe will extract all the components from solution exported out from Dynamics CRM and will create a new folder which will be visible to you in folder structure.
  • You can use /map as one of parameters, to link your extracted files including the dll file from plugins : custom workflows : web resources to physical folder path of your project
  • Once the solution is extracted you may then commit the changes to Azure DevOps project

    DevOps - Implementation Of CI/CD In Microsoft Dynamics CRM
    DevOps - Implementation Of CI/CD In Microsoft Dynamics CRM

Creating a Continuous Integration Pipeline

  • Go to your Azure DevOps project and click on Pipelines to create a New Pipeline
  • In the pipeline we need to add the following tasks to create a build:

    • Use NuGet – this will install the NuGet Tool
    • NuGet Restore – This will restore the nuget version as per the need and requirement of project
    • Build Solution – This will be used to build the solution for Plugin :Custom Workflows which would be referred in the solution
    • PowerShell Scripts – To pack the extracted components into a single solution and create an artifact
    • Publish Artifact Drop – This will be used to drop the artifact created by pipeline and place into a folder which can be later referred by release pipeline for deployment
DevOps - Implementation Of CI/CD In Microsoft Dynamics CRM 
 
As per the need and requirement of the project you can configure and code commit to branch as an auto trigger point for creation of build after the successful code commit.
 

Creating a Continuous Deployment Pipeline

  • Go to Azure DevOps project and click on Releases to create a New Release
  • In the pipeline we need to add the  following tasks to create a release
    • Trigger point for release pipeline will be successful creation of ARTIFACT from the repository in which we have committed the code
    • Need to add tasks to release task
      • Power DevOps Tool Installer
      • Import Solution
      • Publish Customization
    • For connection to the required instance of Dynamics CRM we need to create a variable
      • Connection – will be sharing all the required information including
        • User Credentials
        • Instance URL

          DevOps - Implementation Of CI/CD In Microsoft Dynamics CRM

          DevOps - Implementation Of CI/CD In Microsoft Dynamics CRM


Similar Articles