---
title: "Walkthrough: Preparing to install the DCRM connector in a container environment"
slug: "walkthrough--preparing-to-install-the-dcrm-connector-in-a-container-environment"
abstract: "How to prepare Sitecore for installing the Sitecore Connect for Microsoft Dynamics 365 for Sales connector in a container environment on Docker or Azure Kubernetes Service"
---
# Walkthrough: Preparing to install the DCRM connector in a container environment

To prepare for adding Sitecore Connect for Microsoft Dynamics 365 for Sales (DCRM) to your container installation, regardless of whether you are deploying to Docker or Azure Kubernetes Service, follow the steps in this walkthrough.

This walkthrough describes how to:

- Prepare the installation files.
- Build the Docker images.

<details>
<summary><h2>Prepare the installation files</h2></summary>

To prepare the files you need for the installation:

1. Download the DCRM container deployment package from the [Sitecore download page](https://dev.sitecore.net/Downloads/Dynamics_CRM_Connect.aspx). Extract it to your local workstation with the folder structure intact.
2. Go to the folder that you extracted the DCRM container deployment package to. Go to the folder for the Windows version and topology you are using, for example, `dcrm\compose\ltsc2019\xp1`.
3. Open the `.env-example` file in an editor. Copy all the variables to the clipboard.
4. Go to the Sitecore Experience Platform (SXP) container deployment folder on your local machine. Go to the folder for the Windows version and topology you are using, for example, `compose\ltsc2019\xp1`.
5. Open the `.env` file in an editor, and paste in the variables from the DCRM `.env-example` file.
6. Fill in the parameters for the following variables:
    - `ConnectionString_DCRM`
    - `ConnectionString_StagingDB`
7. Add the following variables to the `.env` file:

    ```

    DEF_IMAGE=scr.sitecore.com/sxp/modules/sitecore-def-xp1-assets:8.0.0-1497
    DCRMCNN_IMAGE=scr.sitecore.com/sxp/modules/sitecore-dcrm-xp1-assets:8.0.0-1497
    TOOLING_IMAGE=scr.sitecore.com/tools/sitecore-docker-tools-assets:10.3.0-1809
    ```

8. Save the `.env` file.
9. From the DCRM `compose\<version>\<topology>` folder, copy the `docker-compose.override.yml` file to the SXP container deployment `compose\<version>\<topology>` folder (where the `docker-compose.yml` file is).

</details>

<details>
<summary><h2>Build the Docker images</h2></summary>

When you have prepared the installation files, you must create Docker files for each role, and build the Docker images.

> [!note]
> For more information on image assets, see the documentation on how to [Add Sitecore Modules](https://doc.sitecore.com/developers/102/developer-tools/en/add-sitecore-modules.html).

To build the images:

1. Go to the SXP container deployment folder on your local machine. Go to the folder for the Windows version and topology you are using, for example, `compose/ltsc2019/xp1`. Create a subfolder and name it `module`.
2. In the `module` folder, create these subfolders:
    - `cm`
    - `xconnect`
    - `xdbsearchworker`
    - `mssql-init`
3. In each subfolder, create a new file and name it `Dockerfile`.
4. In the `cm` folder, in the `Dockerfile` file, enter the following instructions:

    ```

    # escape=`
    ARG BASE_IMAGE
    ARG DCRMCNN_IMAGE
    ARG DEF_IMAGE
    ARG TOOLING_IMAGE

    FROM ${DEF_IMAGE} as def
    FROM ${DCRMCNN_IMAGE} as dcrm
    FROM ${TOOLING_IMAGE} as tooling
    FROM ${BASE_IMAGE} as baseImage

    SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]

    WORKDIR C:\inetpub\wwwroot

    # Add DEF module
    COPY --from=def \module\cm\content

    # Add DCRM module
    COPY --from=dcrm  \module\cm\content

    #Copy transformation files
    COPY --from=dcrm  \module\xdttransform\cm\transforms\ C:\transforms\

    #Add tools from sitecore-docker-tools-assets
    COPY --from=tooling \tools\ C:\tools\

    RUN C:\tools\scripts\Invoke-XdtTransform.ps1 -Path C:\inetpub\wwwroot -XdtPath \transforms\cm
    ```

5. In the `xconnect` folder, in the `Dockerfile` file, enter the following instructions:

    ```

    # escape=`
    ARG BASE_IMAGE
    ARG DCRMCNN_IMAGE
    ARG TOOLING_IMAGE

    FROM ${DCRMCNN_IMAGE} as dcrm
    FROM ${TOOLING_IMAGE} as tooling
    FROM ${BASE_IMAGE} as baseImage

    SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]

    #Add tools from sitecore-docker-tools-assets
    COPY --from=tooling \tools\ C:\tools\

    # Copy models file into index worker
    COPY --from=dcrm  \module\models C:\inetpub\wwwroot\App_Data\Models\

    #Copy transformation files
    COPY --from=dcrm  \module\transforms\ C:\transforms\

    # Update value for IndexPIISensitive and IndexAnonymousContactData in IndexerSetting
    RUN C:\tools\scripts\Invoke-XdtTransform.ps1 -Path C:\inetpub\wwwroot -XdtPath C:\transforms\xconnect
    ```

6. In the `xdbsearchworker` folder, in the `Dockerfile` file, enter the following instructions:

    ```

    # escape=`
    ARG BASE_IMAGE
    ARG DCRMCNN_IMAGE
    ARG TOOLING_IMAGE

    FROM ${DCRMCNN_IMAGE} as dcrm
    FROM ${TOOLING_IMAGE} as tooling
    FROM ${BASE_IMAGE} as baseImage

    SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]

    #Add tools from sitecore-docker-tools-assets
    COPY --from=tooling \tools\ C:\tools\

    #Copy transformation files
    COPY --from=dcrm  \module\transforms\ C:\transforms\

    # Update value for IndexPIISensitive and IndexAnonymousContactData in IndexerSetting
    RUN C:\tools\scripts\Invoke-XdtTransform.ps1 -Path C:\service -XdtPath C:\transforms\xdbsearchworker
    ```

7. In the `mssql-init` folder, in the `Dockerfile` file, enter the following instructions:

    ```

    # escape=`
    ARG BASE_IMAGE
    ARG DCRMCNN_IMAGE

    FROM ${DCRMCNN _IMAGE} as dcrm
    FROM ${BASE_IMAGE}

    SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]

    # Deploy DCRM Staging database file
    COPY --from=dcrm  C:\module\db C:\resources\dcrm
    ```

8. In the `compose\<version>\<topology>\docker-compose.override.yml` file, add build instructions for each role. For all topologies, start with these instructions:

    ```

    version: "2.4"
    services:
      cm:
        image: sitecore-dcrm-xp1-cm:${SITECORE_VERSION}
        build:
          context: ./module/cm
          args:
            BASE_IMAGE: ${SITECORE_DOCKER_REGISTRY}sitecore-xp1-cm:${SITECORE_VERSION}
            DEF_IMAGE: ${DEF_IMAGE}
            DCRMCNN_IMAGE: ${DCRMCNN_IMAGE}
            TOOLING_IMAGE: ${TOOLING_IMAGE}
      mssql:
        image: sitecore-dcrm-xp1-mssql:${SITECORE_VERSION}
        build:
          context: ./module/mssql
          args:
            BASE_IMAGE: ${SITECORE_DOCKER_REGISTRY}sitecore-xp1-mssql:${SITECORE_VERSION}
            DEF_IMAGE: ${DEF_IMAGE}
            DCRMCNN_IMAGE: ${DCRMCNN_IMAGE}
      xdbsearchworker:
        image: sitecore-dcrm-xp1-xdbsearchworker:${SITECORE_VERSION}
        build:
          context: ./module/xdbsearchworker
          args:
            BASE_IMAGE: ${SITECORE_DOCKER_REGISTRY}sitecore-xp1-xdbsearchworker:${SITECORE_VERSION}
            DCRMCNN_IMAGE: ${DCRMCNN_IMAGE}
            TOOLING_IMAGE: ${TOOLING_IMAGE}
    ```

    If you are deploying XP0, add instructions for `xconnect`:

    ```

    xconnect:
      image: sitecore-dcrm-xp0-xconnect:${SITECORE_VERSION}
      build:
        context: ./module/xconnect/
        args:
          BASE_IMAGE: ${SITECORE_DOCKER_REGISTRY}sitecore-xp0-xconnect:${SITECORE_VERSION}
          DCRMCNN_IMAGE: ${DCRMCNN_IMAGE}
          TOOLING_IMAGE: ${SITECORE_TOOLS_REGISTRY}sitecore-docker-tools-assets:${TOOLS_VERSION}
    ```

    If you are deploying XP1, add instructions for `xdbsearch` and `xdbcollection`:

    ```

    xdbsearch:
        image: sitecore-dcrm-xp1-xdbsearch:${SITECORE_VERSION}
        build:
          context: ./module/xconnect
          args:
            BASE_IMAGE: ${SITECORE_DOCKER_REGISTRY}sitecore-xp1-xdbsearch:${SITECORE_VERSION}
            DCRMCNN_IMAGE: ${DCRMCNN_IMAGE}
            TOOLING_IMAGE: ${TOOLING_IMAGE}
      xdbcollection:
        image: sitecore-dcrm-xp1-xdbcollection:${SITECORE_VERSION}
        build:
          context: ./module/xconnect
          args:
            BASE_IMAGE: ${SITECORE_DOCKER_REGISTRY}sitecore-xp1-xdbcollection:${SITECORE_VERSION}
            DCRMCNN_IMAGE: ${DCRMCNN_IMAGE}
            TOOLING_IMAGE: ${TOOLING_IMAGE}
    ```

9. In the Windows console, go to the folder containing the `docker-compose.override.yml` file. Run the command `docker-compose build`.
10. If you are deploying to Docker, continue with the instructions in [Add the DCRM connector module to Sitecore in Docker](https://doc.sitecore.com/xp/en/developers/dynamics-crm-connect/80/sitecore-connect-for-microsoft-dynamics-365-for-sales/add-the-dcrm-connector-module-to-sitecore-in-docker.html "Add the DCRM connector module to Sitecore in Docker").

    If you are deploying to Kubernetes, continue with the instructions in [Walkthrough: Adding the DCRM connector module to Sitecore in Azure Kubernetes Service](https://doc.sitecore.com/xp/en/developers/dynamics-crm-connect/80/sitecore-connect-for-microsoft-dynamics-365-for-sales/walkthrough--adding-the-dcrm-connector-module-to-sitecore-in-azure-kubernetes-service.html "Walkthrough: Adding the DCRM connector module to Sitecore in Azure Kubernetes Service").

> [!note]
> Some modifications to Sitecore deployments, such as adding connection strings or changing the web configuration files, require you to use configuration transforms to change the configuration files. For information on how to apply configuration transforms, see the Sitecore [container development documentation](https://doc.sitecore.com/developers/101/developer-tools/en/applying-configuration-transforms.html).

</details>