25 Apr 2017 | Octopus Deploy | Dynamics CRM | Dynamics CRM Online | generator-nullfactory-xrm | Visual Studio Team Services | ALM | Git
In this third and final installment I cover the steps involved in setting up the minimum release and deployment steps required for a successful Dynamics CRM/365 deployment. The steps and actions performed in the previous posts acts as prerequisites for this one.
Related posts from the series:
In the previous post, I setup the team build to automatically publish packages into the Octopus Deploy package repository.
We can verify that they have indeed been published by navigating to the Library > Packages tab for a list of available packages.
Environments are a logical grouping of targets / machines used by deployments. For the purpose of this post, I will create one environment - Testing and it would contain a single CRM deployment target - the CRM Server).
Environments from the main menu to navigate to the environment configuration page.Add environment in the resulting page.Set Testing as the name of the environment .

Save to confirm selection.Next, define the deployment target for this environment:
Add deployment target button.Select Cloud Region as the deployment target.

Set Test CRM Server as the Display name.
Testing as one of the Environments.Create a new role called crm instance.

Click on Save button to confirm.

I will be creating a variable set to host all settings required to connect to the CRM Server. It makes configuration easier and also provides us with the ability to reuse the same server in multiple projects.
Library > Variable SetsClick on Add variable set

Define three new variables:
#{TestCRM-servername}: The CRM Server Url. #{TestCRM-username}: The deployment username.#{TestCRM-password}: The deployment password. On this one, set the variable type as Sensitive.
Click the Save button.
Projects allow to define a proper release lifecyle by bringing together the different environments and deployment steps.
Let's define a new project:
Projects menu.Add project.Click on Save to confirm selection.

Now associate our previously created variable set as part of our project:
Variable > Library Variable Sets tab within the project.Include variable sets from the Library button.Choose the previously created variable set.

Click the Apply and then Save buttons to confirm selection.

The deployment steps are pretty simple and consists of two PowerShell scripts; the first one is an inline script that sets up the prerequisites while the second one does the actual deployment.
Process tab within the project.Add your first stepSelect a Run a Script template.

Update the following parameters while accepting the default selections for the others:
Step name: Setup PrerequisitesRun on : Deployment targetsRuns on targets in roles : crm instanceScript source : Source codeScript: PowershellProvide the following for the body of the script:
Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force -Scope CurrentUser

Click Save to apply changes.
The steps are very similar to the previous one, but this time we want to execute a script that is already part of the package.
Add step and select a Run a Script template:Update the following parameters while accepting the default selections for the others:
Step name: Deploy CRM SolutionRun on : Deployment targetsRuns on targets in roles : crm instanceScript source : Script file inside a packageKeep the Package Feed on Octopus Server (built-in) as we've already published our package into OD.
Package ID to gnxdemo.crm. This is the name that the build published.Set the Script file name value to:
Nullfactory.Xrm.Tooling\Scripts\Deploy-CrmSolution.ps1
Set the Script parameters value to by integrating the variables that we created earlier:
-serverUrl "#{TestCRM-servername}" -username "#{TestCRM-username}" -password "#{TestCRM-password}" -solutionName "gnxdemo.crm" -publishChanges -activatePlugins

Click the Save button.

Now that we have everything setup let's create a new release and then deploy the same to the Testing environment.
Create Release.0.0.1.Deploy CRM Solution step is referencing the latest version of the solution.Save button the confirm the release. The release page shows an overview of the release including the its lifecyle path and as well as the packages being deployed.Deploy to Testing in order to deploy the solution to the testing environment.Click the Deploy now button in the resulting page to kick off the deployment.

The page would redirect to a summary page showing the progress of the deployment.

Click on the Task Log to view a more verbose view of the solution being deployed.

While I think I have barely scratched the surface of the features provided by Octopus Deploy, the process of writing this series of posts made me appreciate the intuitive structure of key concepts as well as the myriad of options available to support even the most complex of release life cycles. This series also gave me the opportunity to validate the flexibility of the project structure generated using the generator-nullfactory-xrm - with its ability to work with different DevOps tools.