Add the SXA module to Managed Cloud Containers with Sitecore Hosted Solr


Description

This article describes how to add the Sitecore Experience Accelerator (SXA) module to the following environments that use Sitecore Hosted Solr (SHS):

SXA requires customized Content Management, Content Delivery, and Microsoft SQL initialization images. These images must be created, pushed to the appropriate Azure Container Registry (ACR), and configured in the Application repository. The mssql-init-sxa-spe job must then be run to deploy the SXA and Sitecore PowerShell Extensions (SPE) database resources.

Adding SXA to MCC with SHS

Note: Adjust the Sitecore topology and version references as required. The examples in the source procedure use an XM topology with Sitecore version 10.2.0.

  1. Prepare the Docker images

    Refer to the Sitecore documentation about adding Sitecore modules for information about creating customized SXA module.

    To work with SXA, create the following images:

    • cm-sxa-spe
    • cd-sxa-spe
    • mssql-init-sxa-spe
  2. Push the images to the Azure Container Registry

    In PowerShell, run the docker push command to push all images to the pre-provisioned Azure Container Registry (ACR):

    {infrastructure_id}acr
  3. Change the images in the Application repository

    In the Application repository, find the config/docker-images/docker-images.json file and update it:

    {
        "sitecore": {
            "cm": "<infrastructure_id>acr.azurecr.io/cm-sxa-spe:10.2-ltsc2022",
            "cd": "<infrastructure_id>acr.azurecr.io/cd-sxa-spe:10.2-ltsc2022",
            "id": "scr.sitecore.com/sxp/sitecore-id6:10.2-ltsc2022",
            "mssql_init_sxa_spe": "<infrastructure_id>acr.azurecr.io/mssql-init-sxa-spe:10.2-ltsc2022"
        },
        "external": {
            "windowsservercore": "mcr.microsoft.com/powershell:lts-windowsservercore-ltsc2022"
        }
    }
  4. Run the mssql-init-sxa-spe container in an MCC environment without disaster recovery

    To run the mssql-init-sxa-spe container:

    1. Navigate to roles\sitecore-{topology}\templates\* and add the mssql-init-sxa-spe job file under the name: mssql-init-sxa-spe.yaml. For example:
      ---
      apiVersion: batch/v1
      kind: Job
      metadata:
       name: sxa-spe-mssql-init
      spec:
        template:
          spec:
            nodeSelector:
              kubernetes.io/os: windows
            imagePullSecrets:
              - name: sitecore-docker-registry
            containers:
            - name: mssql-init
              image: "{{ docker_images.sitecore.mssql_init_sxa_spe }}"
              env:
              - name: sitecore_admin_password
                valueFrom:
                  secretKeyRef:
                    name: sitecore-admin
                    key: sitecore-adminpassword.txt
              - name: SQL_ADMIN_PASSWORD
                valueFrom:
                  secretKeyRef:
                    name: sitecore-database
                    key: sitecore-databasepassword.txt
              - name: SQL_ADMIN_LOGIN
                valueFrom:
                  secretKeyRef:
                    name: sitecore-database
                    key: sitecore-databaseusername.txt
              - name: SQL_SERVER
                valueFrom:
                  secretKeyRef:
                    name: sitecore-database
                    key: sitecore-databaseservername.txt
              - name: SQL_ELASTIC_POOL_NAME
                valueFrom:
                  secretKeyRef:
                    name: sitecore-database
                    key: sitecore-database-elastic-pool-name.txt
              - name: DATABASES_TO_DEPLOY
                value: spe,sxa
            restartPolicy: Never
        backoffLimit: 5
    2. To add the Ansible tasks to run the mssql-init-sxa-spe job, go to roles\sitecore-{topology}\tasks\init.yaml and add the following scripts at the end of the file:
      - name: Execute sxa-spe mssql-init jobs
        k8s:
          apply: true
          namespace: "{{ solution_id }}"
          state: present
          definition: "{{ lookup('template', 'mssql-init-sxa-spe.yaml') }}"
      
      - name: 'Wait - SXA-SPE Mssql-init job'
        k8s_info:
          kind: Job
          name: sxa-spe-mssql-init
          namespace: "{{ solution_id }}"
        register: sxa_spe_mssql_init_result
        until: sxa_spe_mssql_init_result.resources | length > 0 and sxa_spe_mssql_init_result.resources[0].status.conditions is defined and sxa_spe_mssql_init_result.resources[0].status.conditions | selectattr('type', 'equalto', 'Complete') | list | length > 0
        retries: 60
        delay: 60
      
      - name: Get all SXA-SPE Mssql completed pods
        k8s_info:
          kind: Pod
          namespace: "{{ solution_id }}"
          label_selectors:
            - job-name = sxa-spe-mssql-init
        no_log: true
        register: sxa_spe_mssql_pod_list
      
      - name: Remove SXA-SPE Mssql job's pods
        k8s:
          kind: Pod
          name: "{{ item.metadata.name }}"
          namespace: "{{ solution_id }}"
          state: absent
        no_log: true
        with_items: "{{ sxa_spe_mssql_pod_list.resources }}"
    3. Run the application pipeline.
  5. Run the mssql-init-sxa-spe container to MCC with disaster recovery

    To run the mssql-init-sxa-spe container:

    1. Navigate to roles\sitecore-{topology}\templates\* and add the mssql-init-sxa-spe job file under the name: mssql-init-sxa-spe.yaml. For example:
      ---
      apiVersion: batch/v1
      kind: Job
      metadata:
       name: sxa-spe-mssql-init
      spec:
        template:
          spec:
            nodeSelector:
              kubernetes.io/os: windows
            imagePullSecrets:
              - name: sitecore-docker-registry
            containers:
            - name: mssql-init
              image: "{{ docker_images.sitecore.mssql_init_sxa_spe }}"
              env:
              - name: sitecore_admin_password
                valueFrom:
                  secretKeyRef:
                    name: sitecore-admin
                    key: sitecore-adminpassword.txt
              - name: SQL_ADMIN_PASSWORD
                valueFrom:
                  secretKeyRef:
                    name: sitecore-database
                    key: sitecore-databasepassword.txt
              - name: SQL_ADMIN_LOGIN
                valueFrom:
                  secretKeyRef:
                    name: sitecore-database
                    key: sitecore-databaseusername.txt
              - name: SQL_SERVER
                valueFrom:
                  secretKeyRef:
                    name: sitecore-database
                    key: sitecore-databaseservername.txt
              - name: SQL_ELASTIC_POOL_NAME
                valueFrom:
                  secretKeyRef:
                    name: sitecore-database
                    key: sitecore-database-elastic-pool-name.txt
              - name: DATABASES_TO_DEPLOY
                value: spe,sxa
            restartPolicy: Never
        backoffLimit: 5
    2. Create a custom init.yaml file, for example custom-init.yaml, and put it under the /roles/sitecore-{topology}/tasks folder.
    3. To add the mssql-init-sxa-spe job to the file, add the following code:
      ---
      - name: Execute sxa-spe mssql-init jobs
        k8s:
          apply: true
          namespace: "{{ solution_id }}"
          state: present
          definition: "{{ lookup('template', 'mssql-init-sxa-spe.yaml') }}"
      
      - name: 'Wait - SXA-SPE Mssql-init job'
        k8s_info:
          kind: Job
          name: sxa-spe-mssql-init
          namespace: "{{ solution_id }}"
        register: sxa_spe_mssql_init_result
        until: sxa_spe_mssql_init_result.resources | length > 0 and sxa_spe_mssql_init_result.resources[0].status.conditions is defined and sxa_spe_mssql_init_result.resources[0].status.conditions | selectattr('type', 'equalto', 'Complete') | list | length > 0
        retries: 60
        delay: 60
      
      - name: Get all SXA-SPE Mssql completed pods
        k8s_info:
          kind: Pod
          namespace: "{{ solution_id }}"
          label_selectors:
            - job-name = sxa-spe-mssql-init
        no_log: true
        register: sxa_spe_mssql_pod_list
      
      - name: Remove SXA-SPE Mssql job's pods
        k8s:
          kind: Pod
          name: "{{ item.metadata.name }}"
          namespace: "{{ solution_id }}"
          state: absent
        no_log: true
        with_items: "{{ sxa_spe_mssql_pod_list.resources }}"
    4. To call the custom init.yaml file, go to /roles/sitecore-{topology}/tasks/main.yaml and add the following role at the end of the file:
      - name: Execute custom init jobs
        include_tasks: custom-init.yaml
      init_yaml.png
    5. Run the application pipeline.
    6. After the custom initialization job completes successfully, comment out or remove the Execute custom init jobs role to prevent the job from running during subsequent deployments.
  6. Confirm SXA module is installed
    1. Login to https://<infrastructure_id>-cm.sitecoretest.com/sitecore with the sitecore-admin credentials found in the <infrastructure_id> resource group secret.
    2. Confirm the followings are added:
      sxa module installed a.png
    3. Navigate to the Content Editor > System > Settings > Feature and check the followings exist:
      sxa module installed b.png

Adding SXA to MCCP with SHS

  1. Prepare the Docker images

    Refer to the Sitecore documentation about adding Sitecore modules for information about creating customized SXA module.

    To work with SXA, create the following images:

    • cm-sxa-spe
    • cd-sxa-spe
    • mssql-init-sxa-spe
  2. Push the images to the Azure Container Registry

    In PowerShell, run the docker push command to push all images to the pre-provisioned Azure Container Registry (ACR):

    mcc<agreement_id_without_dashes>acr
  3. Change the images in the Application repository
    1. Find the config/docker-images/docker-images.json file and update it:
      {
        "sitecore": {
          "cm": "mcc<agreement_id_without_dashes>acr.azurecr.io/cm-sxa-spe:10.4-ltsc2022",
          "cd": "mcc<agreement_id_without_dashes>acr.azurecr.io/cd-sxa-spe:10.4-ltsc2022",
          "id": "scr.sitecore.com/sxp/sitecore-identity:8.0-ltsc2022",
          "prc": "scr.sitecore.com/sxp/sitecore-xp1-prc:10.4-ltsc2022",
          "cortexprocessing": "scr.sitecore.com/sxp/sitecore-xp1-cortexprocessing:10.4-ltsc2022",
          "cortexprocessingworker": "scr.sitecore.com/sxp/sitecore-xp1-cortexprocessingworker:10.4-ltsc2022",
          "cortexreporting": "scr.sitecore.com/sxp/sitecore-xp1-cortexreporting:10.4-ltsc2022",
          "xdbautomation": "scr.sitecore.com/sxp/sitecore-xp1-xdbautomation:10.4-ltsc2022",
          "xdbautomationrpt": "scr.sitecore.com/sxp/sitecore-xp1-xdbautomationrpt:10.4-ltsc2022",
          "xdbautomationworker": "scr.sitecore.com/sxp/sitecore-xp1-xdbautomationworker:10.4-ltsc2022",
          "xdbcollection": "scr.sitecore.com/sxp/sitecore-xp1-xdbcollection:10.4-ltsc2022",
          "xdbrefdata": "scr.sitecore.com/sxp/sitecore-xp1-xdbrefdata:10.4-ltsc2022",
          "xdbsearch": "scr.sitecore.com/sxp/sitecore-xp1-xdbsearch:10.4-ltsc2022",
          "xdbsearchworker": "scr.sitecore.com/sxp/sitecore-xp1-xdbsearchworker:10.4-ltsc2022",
          "mssql_init_sxa_spe": "mcc<agreement_id_without_dashes>acr.azurecr.io/mssql-init-sxa-spe:10.4-ltsc2022"
        },
        "external": {
          "windowsservercore": "mcc<agreement_id_without_dashes>acr.azurecr.io/powershell:lts-windowsservercore-ltsc2022",
          "redis": "mcc<agreement_id_without_dashes>acr.azurecr.io/library/redis:8.4.0"
        }
      }
  4. Run the mssql-init-sxa-spe container

    To run the mssql-init-sxa-spe container:

    1. Navigate to roles\sitecore-{topology}\templates\* and add the mssql-init-sxa-spe job file under the name: mssql-init-sxa-spe.yaml. For example:
      ---
      apiVersion: batch/v1
      kind: Job
      metadata:
       name: sxa-spe-mssql-init
      spec:
        template:
          spec:
            nodeSelector:
              kubernetes.io/os: windows
            imagePullSecrets:
              - name: sitecore-docker-registry
            containers:
            - name: mssql-init
              image: "{{ docker_images.sitecore.mssql_init_sxa_spe }}"
              env:
              - name: Sql_Database_Prefix
                valueFrom:
                  secretKeyRef:
                    name: sitecore-database
                    key: sitecore-databaseprefix.txt
              - name: sitecore_admin_password
                valueFrom:
                  secretKeyRef:
                    name: sitecore-admin
                    key: sitecore-adminpassword.txt
              - name: SQL_ADMIN_PASSWORD
                valueFrom:
                  secretKeyRef:
                    name: sitecore-database
                    key: sitecore-databasepassword.txt
              - name: SQL_ADMIN_LOGIN
                valueFrom:
                  secretKeyRef:
                    name: sitecore-database
                    key: sitecore-databaseusername.txt
              - name: SQL_SERVER
                valueFrom:
                  secretKeyRef:
                    name: sitecore-database
                    key: sitecore-databaseservername.txt
              - name: SQL_ELASTIC_POOL_NAME
                valueFrom:
                  secretKeyRef:
                    name: sitecore-database
                    key: sitecore-database-elastic-pool-name.txt
              - name: DATABASES_TO_DEPLOY
                value: spe,sxa
            restartPolicy: Never
        backoffLimit: 5
    2. To add the Ansible tasks to run the mssql-init-sxa-spe job, go to roles\sitecore-{topology}\tasks\init.yaml and add the following scripts at the end of the file:
      - name: Execute sxa-spe mssql-init jobs
        k8s:
          apply: true
          namespace: "{{ solution_id }}"
          state: present
          definition: "{{ lookup('template', 'mssql-init-sxa-spe.yaml') }}"
      
      - name: 'Wait - SXA-SPE Mssql-init job'
        k8s_info:
          kind: Job
          name: sxa-spe-mssql-init
          namespace: "{{ solution_id }}"
        register: sxa_spe_mssql_init_result
        until: sxa_spe_mssql_init_result.resources | length > 0 and sxa_spe_mssql_init_result.resources[0].status.conditions is defined and sxa_spe_mssql_init_result.resources[0].status.conditions | selectattr('type', 'equalto', 'Complete') | list | length > 0
        retries: 60
        delay: 60
      
      - name: Get all SXA-SPE Mssql completed pods
        k8s_info:
          kind: Pod
          namespace: "{{ solution_id }}"
          label_selectors:
            - job-name = sxa-spe-mssql-init
        no_log: true
        register: sxa_spe_mssql_pod_list
      
      - name: Remove SXA-SPE Mssql job's pods
        k8s:
          kind: Pod
          name: "{{ item.metadata.name }}"
          namespace: "{{ solution_id }}"
          state: absent
        no_log: true
        with_items: "{{ sxa_spe_mssql_pod_list.resources }}"
    3. Run the application pipeline.
  5. Confirm SXA module is installed
    1. Login to https://<infrastructure_id>-cm.sitecoretest.com/sitecore with the sitecore-admin credentials found in the <infrastructure_id> resource group secret.
    2. Confirm the followings are added:
      sxa module installed c.png
      Navigate to the Content Editor > System > Settings > Feature and check the followings exist:
      sxa module installed d.png