Hire Dynamics Developers

Hire Dynamics Developers » Dynamics 365 Blog » Implementing Simple CI/CD Solutions – Step-by-Step Guide

Implementing Simple CI/CD Solutions - Step-by-Step Guide

Updated: November 10th, 2024 by Ivan Farafonov

When dealing with multiple instances of Dynamics 365, it becomes paramount to incorporate source control for the unmanaged solutions under development, along with implementing simple CI/CD solutions for smooth transfers. Failing to do so could result in version and content discrepancies across environments, the emergence of undesirable active customizations, and potential future complications with customizations and data import.

Fortunately, Microsoft has taken significant strides by providing all the necessary tools and comprehensive documentation to delegate the CI/CD process of Azure DevOps Dynamics 365 CI/CD. This effectively mitigates the aforementioned issues, while offering a more controlled and convenient migration process. These features allow you to stay in sync, reduce risks, and foster a smoother workflow in your Dynamics 365 endeavors.  Need help with all features? Meet Kyrylo, a talented developer working on a large project for a leading telecommunications company in the USA.

Get Help from Our Experienced Developer

Kyrylo is part of a skilled team of Microsoft Dynamics 365 developers who work closely with Product Managers, Business Analysts, and other specialists. They use a Waterfall methodology to control projects efficiently from requirement analysis to deployment. The team uses technologies like C#, .NET, JavaScript, TypeScript, React.js, Next.js, and Kendo UI to create a smooth user experience. 

He works with the leading USA company. It specializes in global telecom integration and has an award-winning platform that combines CRM, ERP, and IoT elements. Serving over 7 million subscribers worldwide, the company is dedicated to reducing operating costs and improving service quality for telecom providers.

Kyrylo is happy to share his knowledge and reveal insights into the CI/CD process. Let’s dive into a minimal example that will serve as your launchpad. To get started, you’ll require the following essentials:

  • Two Dynamics instances: one is the source of customizations, and the other is the target.
  • Application users have either the System Administrator or System Customizer role.
  • An Azure DevOps environment that will house the control. This platform will also host the creation and release pipelines for your CI/CD workflow.
  • Microsoft Solution Packager (which can be found here).

Workflow

The CI CD pipeline for Dynamics 365 unfolds as follows:

  • Changes: The developer starts by making changes to a feature.
  • Export and Unpack: After finalizing the changes, we export and unpack them using the Solution Packager Tool.
  • Source Control Management: At this stage, a specialist thoroughly reviews the changes made to the code. If any undesired alterations are identified, they are promptly removed. The developer then commits the changes to Azure DevOps, ensuring well-maintained and organized version control.
  • Automatic Build Pipeline: This is where the automation comes into play. The automatic build channel is triggered, harnessing the power of Microsoft’s provided Power Platform tools to create the code.
  • Publishing the Artifact: As a result, the solution is published as an Artifact. This serves as a neatly packaged and deployable unit, ensuring consistency and reliability.
  • Automatic Release Pipeline: As the final step, the automatic channel springs into action. It imports the file into the target area, bringing your latest customizations and improvements to life.

In a nutshell, the developer does the first three manual parts of the Dnamics 365 continuous integration: making changes and committing them to Azure DevOps. On the other hand, Azure DevOps automates the following tasks.

Source Control

The next step is to export and unpack it. While this process can be done manually, you can take it a step further and achieve automation using PowerShell and CMD scripts. In fact, I have created a .NET console application that handles the export and unpacking processes. 

Let’s begin by using a PowerShell script to download the desired option. To get started, make sure you have the Microsoft.Xrm.Data.Powershell package installed, as it plays a crucial role in authenticating and interacting with Dynamics:

Install-Module -Name Microsoft.Xrm.Data.Powershell

Next, we will download the solution:

Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass Import-Module Microsoft.Xrm.Data.Powershell $CRMConn = Get-CrmConnection -ConnectionString “AuthType=’ClientSecret’; ServiceUri=’https://dynamicsurl.dynamics.com’; ClientId=’clientId’; ClientSecret=’clientSecret’;” Export-CrmSolution solutionName solutionPath -SolutionZipFileName solutionZipFileName -conn $CRMConn

Finally, unpack the solution into the source control folder using the Solution Packager Tool:

SolutionPackager.exe /action:Extract /zipfile:mysolution_1_1_0_0_managed.zip /folder:source /allowDelete:Yes

I recommend using the following structure for your source solution:

1 1

In this exemplary setup, the project structure is organized into various components to streamline the CI/CD process for Dynamics solutions. Here’s a breakdown of the different components and their roles:

Plugins:

This project houses the plugins developed and intended for publishing to the Dynamics instance.

Infrastructure:

  • The Infrastructure project holds all the essential resources to facilitate automation and the CI/CD workflow.
  • It contains PowerShell and CMD scripts that are utilized in different stages of the process, such as exporting and unpacking.
  • YAML files are present, defining the construction and release processes to be followed during CI/CD.
  • The Solution Packager application.

Retriever:

  • The Retriever application acts as a central feature, orchestrating the downloading using the scripts provided in the Infrastructure project.
  • It simplifies the process for developers, allowing them to interact with the functionality.
  •  

Solutions folder:

  • This folder is a repository for all files, encompassing both managed and unmanaged features.
  • Developers can find and control their features within this folder.
  • All solutions here are readily available for publishing to the target space.
  •  
B6F5 tmp

Automation

  • Once the source code for the solution has been published, the Build pipeline on Azure DevOps plays a crucial role in ensuring the integrity of the solution. This pipeline is responsible for building the solution from the source code and pushing it to Artifacts, where it can be easily managed and deployed. To leverage this functionality in your DevOps instance, you’ll first need to install the Power Platform Build Tools from the Azure Marketplace.

    You have the option to utilize snippets for creating and pushing the features, and for more extensive customization, custom YAML scripts can be employed. The simplest example involves three essential steps:

    1. Install Power Tools: This critical step imports the Power Platform Build into your CI CD pipeline for Dynamics 365.
    2. Pack Solution: Here, the folder is built into tools to ensure it is valid and prepared for publishing. Remember that the agent for your pipeline must be Windows for the Packager Tools to work!
    3. Publish Artifact: In this step, the final managed function is pushed into the pipeline of artifacts, making it import-ready.

    By following these three steps, your line is well-equipped to handle the publishing process.

3 (1)

Enable Automatic Import

Now, you need to create a network. Go to Azure DevOps and navigate to the “Releases” section, then create a new channel. In the editor, click on “Add an artifact” to specify the source from which the release will be triggered. Choose the appropriate pipeline that you previously created as the source of your artifact. This ensures that whenever a new build is available, it triggers the system. After adding the artifact, go to the “Continuous Deployment Trigger” section for the artifact. Enable the trigger on the specific system you want to use. This means that whenever a new build is available, the line will automatically start.

5 1024x270

In Stage 1, you will create a new job and add four tasks to achieve the following:

  • Install Power Tools: This task will import the Power Platform Build Tools into the network, similar to what was done in the Build pipeline.
  • Solution Checker: Use this task to validate the components for their correctness. It will analyze various elements, such as custom workflow activities, web resources, SDK message steps, Power Automate Flows, Power Fx expressions, and more
  • Import Solution: In this step, the verified option willattemptd to be imported into the target space. Before this, ensure you have set up the Service Connection. Use an application user and provide its Client ID and Client Secret to Azure DevOps.
  • Publish Customizations: As a best practice, after importing a function, it is essential to publish active customizations.

Testing

After setting up your CI/CD pipelines, it’s time to put them to the test. In your Dynamics 365, make some changes to features that you want to test. Export the unmanaged solution either using the script you previously set up or manually through the Dynamics 365 interface. Use the Solution Packager to unpack the exported file into the code. Commit the changes to the code to your Azure DevOps repository.

The option will be built using the Power Platform Build Tools and published as an Artifact. The network should be automatically triggered after the pipeline successfully creates the Artifact. The line will import the item into the space using the configured service connection and credentials. Keep an eye on the line as they execute. Check the logs and outputs to ensure that there are no errors or issues.

Once the release is complete, check your target Dynamics 365 environment to confirm that the feature has been imported successfully and that any customizations are correctly published.

If all the steps are executed without errors and the environment reflects the changes you made, congratulations! Your CI/CD setup is working as expected. Now you can enjoy a streamlined and automated deployment process with minimal manual intervention.

Feeling Stuck? Our Dynamics 365 Developers Are Here to Help!

Our developers are the best assistants if you need help in implementing simple CI/CD solutions. We provide reliable assistance and configure the required functionality quickly and efficiently. With this approach, you avoid lengthy coding and just enjoy the result. At the same time, you can be calm about the quality of execution, because our specialists adjust everything according to your requests. Just contact us to choose suitable services and get a fast and smooth implementation.

Click on a star to rate it!

Average rating 4.9 / 5. Vote count: 25

No votes so far! Be the first to rate this post.

Share:
Ivan Farafonov
I'm passionate about sharing my extensive experience in Microsoft and Dynamics 365 technologies. Beyond the technical realm, I excel in recruiting and building high-performing teams, ensuring every project is executed with precision and collaboration. As a contributor to HireDynamicsDevelopers, I share my insights on maximizing Dynamics 365’s potential, blending technical expertise with strategic team development. My passion lies in both technology and fostering talented professionals to achieve outstanding results.

Are You Looking for Implementing Simple CI/CD Solutions? Don’t Hesitate to Ask for Help and Start with Our Developers!

Your Partner Recognized in Dynamics Community

awward 4
awward 10
awward 7
awward 8
awward 11
awward 9
awward 12
awward 13