Set Up CI/CD of Microsoft Dynamics CRM Solutions

Introduction

In this blog, we will explore how to set up CI/CD for Microsoft Dynamics, providing you with the tools and insights needed to optimize your deployment workflows and stay ahead in the digital transformation journey.

The integration of Continuous Integration and Continuous Deployment (CI/CD) practices has become essential for organizations aiming to enhance efficiency and accelerate software delivery. Notably, the global CI tools market is projected to grow from USD 970.52 million in 2022 to approximately USD 4.38 billion by 2031, reflecting a compound annual growth rate (CAGR) of 18.22%.

Combining CI/CD methodologies with Microsoft Dynamics enables organizations to automate and streamline their deployment processes, resulting in faster time-to-market and improved product quality. This integration is particularly beneficial in today’s competitive environment, where agility and efficiency are paramount.

Types of CRM Solutions

MS Dynamics Solution:

An MS CRM solution is a package that is customized or developed by customers to extend the CRM. Any update that needs to be done on a Microsoft CRM can be packaged in a solution and then deployed on the target organization. 

Managed Solution:

A solution that is finalized and planned to be distributed is known as a managed solution. Once deployed on a target organization, it cannot be modified on the target organization, and when uninstalled, all the customizations done would be rolled back.  

Unmanaged Solution:

A solution that is still under development and not aimed to be delivered is called an unmanaged solution. It can be modified even on the target organizations. It contains all the components that were customized or updated in the development organization. Once installed on an organization, the customization done by the unmanaged solution cannot be rolled back, even if the solution is uninstalled.  

Read More: Automate Microsoft CRM Solutions Merge Using Azure CI/CD Pipelines.

Prerequisites to Set Up CI/CD of Microsoft Dynamics CRM

Implementing Continuous Integration and Continuous Deployment (CI/CD) for Microsoft Dynamics requires a well-planned setup to ensure seamless automation and efficient workflows. Below are the essential prerequisites, tools, and configurations necessary for establishing a robust CI/CD pipeline:

1. Azure DevOps Environment

Azure DevOps Account: Set up an Azure DevOps account to manage repositories, pipelines, and artifacts.

Power Platform Build Tools Extension: Install the Power Platform Build Tools extension in Azure DevOps to access tasks for building, testing, and deploying Power Platform solutions.

2. Dynamics 365 Instances

Source and Target Environments: Prepare at least two Dynamics 365 instances—one as the source (development) environment and another as the target (testing or production) environment.

Application Users: Ensure that application users in both environments have the System Administrator or System Customizer roles to facilitate solution management.

3. Solution Management Tools

Solution Packager Tool: Utilize the Microsoft Solution Packager to unpack and pack Dynamics 365 solutions, enabling version control and collaborative development.

PowerShell Scripts: Develop PowerShell scripts to automate tasks such as exporting and importing solutions, applying configurations, and managing deployments.

4. Source Control Management (SCM)

Version Control System: Use Azure Repos or another Git-based repository to maintain version control of your unpacked solution files, plugins, and custom workflows.

Branching Strategy: Implement a branching strategy (e.g., GitFlow) to manage development, testing, and release cycles effectively.

5. Build and Release Pipelines

Build Pipeline: Configure Azure Pipelines to automate the building of solutions, including compiling plugins and workflows, and exporting solutions from the source environment.

Release Pipeline: Set up release pipelines to automate the deployment of solutions to target environments, incorporating approval gates and automated testing as needed.

6. Authentication and Security

Service Connections: Establish secure service connections between Azure DevOps and Dynamics 365 environments using service principals or OAuth authentication methods.

Credential Management: Store sensitive information, such as client secrets and passwords, securely within Azure DevOps using pipeline secrets or Azure Key Vault.

7. Testing Frameworks

Automated Testing Tools: Incorporate automated testing frameworks, such as the Regression Suite Automation Tool (RSAT), to validate solution functionality during the CI/CD process.

By ensuring these prerequisites are in place, organizations can establish a robust CI/CD pipeline for Microsoft Dynamics, leading to more efficient development cycles, reduced manual errors, and faster delivery of high-quality solutions.

Continuous Integration and Continuous Deployment Using Azure Pipelines: Set Up CI/CD of Microsoft Dynamics

Azure DevOps allows us to use its build and release pipelines to set up CI/CD of Microsoft Dynamics CRM Solutions effectively.

Continuous Integration:

Azure DevOps Build Pipelines are used for continuous integration. CI triggers when there is a commit in a specified branch and repo. In the case of Pipeline for Microsoft Dynamics CRM, the build pipeline will be used to export our CRM solution from the specified source organization. Using Azure DevOps, you have plenty of tasks for exporting a CRM solution. You can also use a PowerShell Script for this purpose. 

Read More: How to Delpoy PowerApps Solutions Using Azure DevOps

Continuous Deployment:

Continuous Deployment is, whenever a build pipeline is completed successfully, the artifacts published by that build pipeline should be deployed to the destination organization. Microsoft Azure DevOps Release Pipelines can be used for Continuous Deployment of Dynamics CRM Solution. To streamline this process, organizations can rely on Azure Pipelines to set up CI/CD of Microsoft Dynamics solutions.

Elevate Your Dynamics 365 Integration

Ready to set up CI/CD of Microsoft Dynamics 365 CRM solutions? Consult with AlphaBOLD for expert insights and seamless integration strategies. Let's optimize together!

Request a Demo

Setting up a Build Pipeline (Continuous Integration):

  • Navigate to the project you want to create a pipeline for. 
  • Click on the pipelines, select pipelines, and Create a new pipeline using the New Pipeline Button. 
Infographic that show how to create a new pipeline using the New Pipeline Button. CI/CD of Microsoft Dynamics
  • Click on the Use Classic Editor.  
Infographic that show the Use Classic Editor - CI/CD of Microsoft Dynamics
  • Specify the Repo where your code resides and to which you want to Enable CI and create the pipeline with Empty Task.
Infographic that show how to create the pipeline with Empty Task
  • Enable Continuous Integration of Azure Pipelines. Click on the trigger button and check the box “Enable Continuous Integration.
Infographic that show Click on the trigger button and check the box “Enable Continuous Integration - CI/CD of Microsoft Dynamics
  • Add the Task for Power DevOps Tool Installer.
Infographic that show Add the Task for Power DevOps Tool Installer - CI/CD of Microsoft Dynamics
  • Now add the task for Solution Export. You can use the task that you want to;, we will be using the following one. 
Infographic that show add the task for Solution Export - CI/CD of Microsoft Dynamics
  • Now provide the connection string and the name of the solution to the task. The connection string would be like this:  

“AuthType=Office365; Url=<url to CRM Server>; UserName=<[email protected]>;Password=<*******>”.  

You can also specify the task whether you want to export the solution as Managed or Unmanaged. Keep in mind or copy the Output Path it would be needed in the next step. 

Infographic that show connection string and the name of the solution to the task.
  • Once the Microsoft Dynamics CRM solution is exported, you need to publish it as an Artifact. Publish Build Artifact is an Azure DevOps Build Pipeline task that can be used to do so. 
Infographic that show Publish Build Artifact is an Azure DevOps Build Pipeline task - CI/CD of Microsoft Dynamics
  • Paste the output path in the “Path to Publish” you copied in the previous task to Publish the CRM Solution an artifact. You can also rename the artifact’s name. This name would be used in the release while importing the CRM solution.  
Infographic that show Path to Publish

Setting up a Release Pipeline (Continuous Deployment):

  • Navigate to the project where you want to set up the Continuous Deployment. Click on the Pipelines, Select Releases and Create New Release Pipeline. Start with the Empty Job. 
Infographic that show Select Releases and Create New Release Pipeline - CI/CD of Microsoft Dynamics
  • Link the build pipeline to the Continuous Deployment pipeline by using the Add an Artifact button.
Infographic that show build pipeline to the Continuous Deployment
  • Enable CD by using the Continuous Deployment Trigger Button. 
Infographic that show Continuous Deployment Trigger Button
  • Now add the steps to the release pipeline by clicking on the Job, Task button under the Stage name. 
Infographic that show add the steps to the release pipeline by clicking on the Job - CI/CD of Microsoft Dynamics
  • Add the Power DevOps Tool Installer task. 
Infographic that show add the Power DevOps Tool Installer task.
  • Add the Import Solution task. 
Infographic that show add the Import Solution task.
  • Add the connection string for the Destination org where you want to Deploy Microsoft Dynamics 365 solution. Also, link the solution file that was published as a build artifact in the linked pipeline. The path name would be like

$(System.DefaultWorkingDirectory)/<BuildName>/<ArtifactName>/<SolutionFile>.zip 

Infographic that show add the connection string for the Destination
  • Now add the Publish Customization task to your Release.  
Infographic that show add the Publish Customization task to your Release

Drive Innovation in Dynamics 365 - AlphaBOLD’s CI/CD Expertise

Ready to innovate your Dynamics 365 solutions? Partner with AlphaBOLD to set up CI/CD of Microsoft Dynamics solutions. Let's drive innovation and efficiency in your Dynamics 365 ecosystem.

Request a Demo

Controlling Deployment Pipelines through PowerShell Script:

You can control the Continuous Integration and Continuous Deployment of MS Dynamics Solution by adding a PowerShell script in your source. Add a PS with the information like the Source organization from where the solution would be exported, Solution Name, Username, and the Destination organization where you want to deploy. You can also add a switch “Deploy CRM” to control either the CRM should be deployed on commit or not. Copy the PowerShell Script to control the Continuous Integration and Continuous Deployment of MS Dynamics Solution and commit this as a .ps1 file in your repo.

$global:config = @{    

#SourcE 

    Username = ”[email protected]” 

    URL = ”https://xyz.crm.dynamics.com/org012evc9″ 

    DeployCRM = ”Yes” 

    SolutionName = ”fordemo” 

    runtest      = ”Yes” 

#Dest 

    DestUsername =  ”[email protected]” 

    DestURL = ”https://alphaboldai0.crm.dynamics.com/org6b7177f6″ 

$CRMDeployment = $Global:config.DeployCRM 

$SolutionName = $Global:config.SolutionName 

$Username = $Global:config.Username 

$URL = $Global:config.URL 

$runtest = $Global:config.runtest 

$DestUsername = $Global:config.DestUsername 

$DestURL = $Global:config.DestURL 

Write-Output (“##vso[task.setvariable variable=DeployCRM;]$CRMDeployment”) 

Write-Output (“##vso[task.setvariable variable=SolutionName;]$SolutionName”) 

Write-Output (“##vso[task.setvariable variable=URL;]$URL”) 

Write-Output (“##vso[task.setvariable variable=Username;]$Username”) 

Write-Output (“##vso[task.setvariable variable=runtest;]$runtest”) 

Write-Output (“##vso[task.setvariable variable=DestUsername;]$DestUsername”) 

Write-Output (“##vso[task.setvariable variable=DestURL;]$DestURL”)

  • Copy this PS and commit in your repo as a PowerShell Script file. 
  • In your build pipeline, Publish this file as a build artifact.
Infographic that show Controlling Deployment Pipelines through PowerShell Script
  • Now in the Release pipeline, run this PowerShell Script on top of each task. It will set the Global Variables on the agent reading the information you provided. Then you can replace the username, solution name, and the organization name with the global variables.  
Infographic that show Release pipeline, run this PowerShell Script on top of each task - CI/CD of Microsoft Dynamics
Infographic that show run this PowerShell Script on top of each task
  • To use the “Deploy CRM” switch, you can find “Control Options” under each task. Use Custom Conditions and Specify the Condition as “eq(variables[‘DeployCRM’], ‘Yes’)”.
Infographic that show the “Deploy CRM” switch, you can find “Control Options” under each task

Final Thoughts

Microsoft Azure is the best option to use when you want to set up CI/CD of a Microsoft Dynamics Solution because it provides flexible Build and Release Pipelines. MS Azure has a vast marketplace loaded with bundle of tasks to choose within your pipelines, when comes to the Continuous Integration and Continuous Deployment of any application. It also allows you to control your deployment via PowerShell Scripts, you can supply the solution name, source and destination organizations name, credentials along with a switch that will determine if you want to trigger the build or release pipeline on commit. Whether you’re managing on-premise or cloud-based solutions, setting up CI/CD of Microsoft Dynamics with Azure ensures optimized workflows and reduced manual errors.  

Explore Recent Blog Posts

Infographics show the 2021 MSUS Partner Award winner

Related Posts

Receive Updates on Youtube