Tag: Tips & Tricks

Step-by-step install Sitecore XP 10.1 to developer workstation using Sitecore Containers with Docker

To know more about containers here is the official documentation from Sitecore on Containers

Lets get started to create a Sitecore XP 10.1 development environment using docker.

Before getting started please see Installation Guide for Developer Workstation with Containers

Topology user here will XP0 or per guide XP Workstation (XP Single)

Hardware and Networking Requirements-

Sitecore instance needs below ports, avoid using these ports other than Sitecore.

Required portRoleDescription
443TraefikHTTPS proxy
8079TraefikTraefik dashboard
8984SolrSolr API and dashboard
14330SQLSQL Server

Prepare/prerequisite for Sitecore XP workstation

  • [Optional] OS- Windows 10 1809 or later or Windows Server 1809 or later

Login to Azure portal to create a VM

Image – Select Image to Windows 10 Pro, Version 1809- Gen 1

Size – Standard_D8s_v3- * vcpus, 32GiB memory

Inbound ports– Select RDP, dont select HTTPS 443 as this will be used by Traefik as mentioned in previous section

  • Download and Install Docker Desktop for Windows

Download and install Docker Desktop for Windows. You can get Stable version from here

After installation Restart the machine, this should enable the Hyper-V feature

This should also have Docker running and should see the same in system tray

  • Switch to Windows containers

Right click on Docker icon and switch to Windows Container. See this link for more details as per guide

Download and Prepare for installation

  • Download and extract the Sitecore Container Deployment Package from the Sitecore Developer Portal and store it on your local workstation or check releases here
  • Copy and extract SitecoreContainerDeployment.10.1.0.005207.309.zip for e.g:- C:/sc101_install

Navigate to C:\sc101_install\compose\ltsc2019\xp0

  • Open .env file, we need to fill in this parameters before starting installation. You can find more details in guide for each option.
  • Download PowerShell script to initialize (init.ps1) the parameters from docker-examples. Parameter values in .env can be populated manually by individually executing the commands for required for each parameter in guide(see Appendices) but I would recommend to use init.ps1 as this is provided by Sitecore and hence tried and tested.

Folder structure should look like this-

  • Change parameter values in init.ps1 file.

Change the SitecoreAdminPassword, SqlSaPassword and host entries as per requirement. If you are changing host entries also ensure the same is updated in .env file for CM_HOST and ID_HOST parameters. Lets keep the default values.

  • Populate .env file using init command

Open PowerShell as a Administrator, navigate to the folder having init.ps1 file.

Execute init.ps1 script. You may have to set the execution rights to current user to execute the script-

Set-ExecutionPolicy -Scope CurrentUser Unrestricted
.init.ps1

Provide the path of license file

This should Install and Import SitecoreDockerTools and Populate the environment file.

Ensure to Switch to Windows Container before executing below command

Install

Execute docker compose command

docker-compose.exe up --detach

Installation complete-

Once command execution is complete, should see all the checks done and Sitecore dev. instance ready in 20 minutes

Open Docker Dashboard and should see Sitecore-XP0 running

Site listening to address- https://xp0cm.localhost/

Cleanup the workstation

To cleanup/stop workstation use following commands. You can find these in instllation guide

To stop a Docker Compose environment without removing its contents:

docker-compose.exe stop

To resume a previously stopped Docker Compose environment:

docker-compose.exe start

To remove a Docker Compose environment and all the non-mounted volumes

docker-compose.exe down

Hope this helps to install Sitecore XP 10.1 using Docker!!!

Setup development environment for Sitecore Commerce Engine 10 and 10.2

Update: Below is applicable for Sitecore Commerce 10.2. Change the SDK version accordingly. Ignore the step mention for Content Hub

Sitecore Experience Commerce 10 has come up with great new features like Dynamic Bundles, Free gift with Purchase promotion and a sample Sitecore DAM to Commerce connector.

Before you start looking into this, it is important to setup the development environment to debug and test the changes you are making to engine.

Main changes I could see compared to previous versions are integration with Content Hub and Configuring the Commerce Engine using environment variables which not only helps for on-premise installation of Commerce Instance but also helps setup the Docker technology where XC solution is running in containers.

In this post I will walk you through on how to setup the development environment. This post assumes you have Sitecore Commerce Engine along with Visual Studio 2019 installed on developer workstation. If Commerce not installed no worries see this post on how to install Sitecore XC 10 step-by-step.

Step-by-step install Sitecore Commerce (XC) 10

For previous version of XC you may follow this blog post

Step-by-step – Setup development environment for Sitecore Commerce 9.3 Engine

Step 1- Extract Commerce Engine SDK

  • Copy the downloaded SDK Sitecore.Commerce.Engine.SDK.6.0.130.zip on your development folder. e.g: c:\development. Note– there is an update on 19th August where the external dependencies are removed. Download the package again if you have a version before this date.
  • If not available you may download Packages for On Premise WDP 2020.08-6.0.238. Login before you download the file.
  • Extract the commerce package and then extract Sitecore.Commerce.Engine.SDK.6.0.130.zip in your development folder

Step 2 – Setup Visual Studio Solution

  • Open the Solution, by default this is Customer.Sample.Solution.sln
  • Ensure Package Source is configured for Commerce- https://sitecore.myget.org/F/sc-commerce-packages/api/v3/index.json
  • Whilst opening solution login from slpartners.myget.org will be prompted
  • Create an account on https://slpartner.myget.org/ and login here. You may unload Plugin.Sample.ContentHub project if you dont want to integrate ContentHub and the login should not require. Also note myget account has a trial for 14 days.
  • Build the Solution. It should restore the package and build successfully.
  • (optional)Rename the Solution name. In this case I have renamed to Retail.Commerce
  • (Optional) Create Foundation and Feature projects. Build the solution again.

Step 3- Important – Commerce Engine configuration

Sitecore.Commerce.Engine project should have a config.json file in wwwroot folder. Open this file you will see the placeholders that needs to be filled in.

Instead updating config file, you should update the launchSettings.json and the placeholders in config.json will be updated on launch on commerce engine.

Similarly Global.json you can find this in wwwroot/bootstrap folder of your Sitecore.Commerce.Engine project. Again this file has the Placeholders that will be populated from launchSettings.json,

You need to update mainly following variables in launchSettings.json file for both config and global json. There are other variables apart from listed below, you may need to update those based on your site instance name etc.-

  1. COMMERCEENGINE_Caching__Redis__Options__Configuration
  2. COMMERCEENGINE_GlobalDatabaseServer
  3. COMMERCEENGINE_GlobalDatabaseUserName
  4. COMMERCEENGINE_GlobalDatabasePassword
  5. COMMERCEENGINE_SharedDatabaseServer
  6. COMMERCEENGINE_SharedDatabaseUserName
  7. COMMERCEENGINE_SharedDatabasePassword
  8. COMMERCEENGINE_AppSettings__SitecoreIdentityServerUrl
  9. COMMERCEENGINE_EngineAuthoringUrl
  10. COMMERCEENGINE_EngineShopsUrl
  11. COMMERCEENGINE_EngineMinionsUrl
  12. COMMERCEENGINE_EngineHealthCheckUrl
  13. COMMERCEENGINE_AppSettings__AllowedOrigins

Step 4 – Generate Development Certificate

Generate development certificate using script “New-DevelopmentCertificate”, so the localhost runs on SSL(https)

  1. Create a folder named “dev” in the root directory of SDK
  2. Create a folder named “Sitecore.Commerce.Engine_Dev” under “dev” folder
  3. Create a folder named “wwwroot” under “Sitecore.Commerce.Engine_Dev” folder
  4. Open powershell script and navigate to scripts folder.
  5. Change the Path($certificateOutputDirectory) if required. Certificate should be copied to \src\Project\Engine\code\wwwroot
  6. Execute New-DevelopmentCertificate script. This script should be available in script folder in SDK folder.

Step 5 – Update EngineUri in BizFx Site

  • Open config.json file. Should be in assets folder of your BizFx instance
  • Change EngineUri to https://localhost:5000
  • Change BizFxUri to https://localhost:4200
  • Restart BizFx site

Step 6- Run the Commerce Engine from Visual Studio

  • Set the Sitecore.Commerce.Engine project as Startup Project
  • Change the emulator to Engine
  • Stop the CommerceAuthoring_SC site hosted in IIS
  • Run the solution

Hope there should be nothing that should block to run the Business Tools requesting a call to Engine running from Visual Studio

Note: some places you may have to restart IIS also clear the browser cache before you start checking Business Tools is highly recommended.

Hope this post helps you setting your XC 10 development environment.

ISSUES

Request origin https://bizfx.sc.com does not have permission to access the resource

Resolution- Follow Step 5

Step-by-step install Sitecore XP 10 to developer workstation using Sitecore Containers with Docker Compose

One of the highlights of newly released Sitecore Experience Platform (10.0) is that it brings support to rapid deployment and more efficient solution and team onboarding with modern Docker technology i.e. Sitecore Containers.

To know more about containers here is the official documentation from Sitecore on Containers

Lets get started to create a Sitecore XP 10 development environment using docker.

Before getting started please see Installation Guide for Developer Workstation with Containers

Topology user here will XP0 or per guide XP Workstation (XP Single)

Hardware and Networking Requirements-

Developer workstation requires 32GB RAM and 25 GB Free space with quad core or higher CPU

Required portRoleDescription
433 443TraefikHTTPS proxy
8079TraefikTraefik dashboard
8080TraefikHTTP proxy
8984SolrSolr API and dashboard
14330SQLSQL Server

IMPORTANT-

HTTPS proxy port for Traefik in guide is incorrect. As per the docker-compose.yml the Traefik is set to listen on 443 port and not 433.

Prepare/prerequisite for Sitecore XP workstation-

  • OS- Windows 10 1809 or later or Windows Server 1809 or later

Login to Azure portal to create a VM

Image – Select Image to Windows 10 Pro, Version 1809- Gen 1

Size – Standard_D8s_v3- * vcpus, 32GiB memory

Inbound ports– Select RDP, dont select HTTPS 443 as this will be used by Traefik as mentioned in previous section

  • Download and Install Docker Desktop for Windows

Download and install Docker Desktop for Windows. You can get Stable version from here

Setup should enable Hyper-V Windows Features

After installation Restart the machine, this should enable the Hyper-V feature

This should also have Docker running and should see the same in system tray

  • Switch to Windows containers

Right click on Docker icon and switch to Windows Container. See this link for more details as per guide

Download and Prepare for installation

  • Download and extract the Sitecore Container Deployment Package from the Sitecore Developer Portal and store it on your local workstation

Login to Sitecore portal before download

  • Copy and extract SitecoreContainerDeployment 10.0.0 rev. 004346-027.zip for e.g:- C:/SitecoreXPDocker

Navigate to C:/SitecoreXPDocker/ltsc2019/sitecore-xp0

  • Open .env file, we need to fill in this parameters before starting installation. You can find more details in guide for each option.
  • Download PowerShell script to initialize (init.ps1) the parameters from docker-examples. Parameter values in .env can be populated manually by individually executing the commands for required for each parameter in guide(see Appendices) but I would recommend to use init.ps1 as this is provided by Sitecore and hence tried and tested.

Folder structure should look like this-

  • Change parameter values in init.ps1 file.

Change the SitecoreAdminPassword, SqlSaPassword and host entries as per requirement. If you are changing host entries also ensure the same is updated in .env file for CM_HOST and ID_HOST parameters. Lets keep the default values.

  • Populate .env file using init command

Open PowerShell as a Administrator, navigate to the folder having init.ps1 file.

Execute init.ps1 script. You may have to set the execution rights to current user to execute the script-

Set-ExecutionPolicy -Scope CurrentUser Unrestricted
.init.ps1

Provide the path of license file

This should Install and Import SitecoreDockerTools and Populate the environment file.

Ensure to Switch to Windows Container before executing below command

Install

Execute docker compose command

docker-compose.exe up --detach

Installation complete-

Once command execution is complete, should see all the checks done and Sitecore dev. instance ready in 20 minutes

Open Docker Dashboard and should see Sitecore-XP0 running

Site listening to address- https://xp0cm.localhost/

Cleanup the workstation

To cleanup/stop workstation use following commands. You can find these in instllation guide

To stop a Docker Compose environment without removing its contents:

docker-compose.exe stop

To resume a previously stopped Docker Compose environment:

docker-compose.exe start

To remove a Docker Compose environment and all the non-mounted volumes

docker-compose.exe down

Hope this helps to install Sitecore XP 10 using Docker!!!

Step-by-step – Setup development environment for Sitecore Commerce 9.3 Engine

On a XC installed instance you might want to customize the XC by adding your own Entities, Components, Entity Views etc. In this topic I will describe how to setup your development environment to add your custom plugin.

This topic assumes a Sitecore CMS and Commerce engine version 9.3 are running under IIS. I am using Visual Studio 2019.

Steps to setup-

Step 1- Extract Commerce Engine SDK

  1. Copy the downloaded SDK Sitecore.Commerce.Engine.SDK.5.0.76.zip on your development folder.
  2. If not available you may download Packages for On Premise WDP 2020.01-5.0.145
  3. Extract the commerce package and then extract Sitecore.Commerce.Engine.SDK.5.0.76.zip
Extracted files

Step 2 – Setup Visual Studio Solution

  1. Open the Solution, by default this is Customer.Sample.Solution.sln
  2. Ensure Package Source is configured for Commerce- https://sitecore.myget.org/F/sc-commerce-packages/api/v3/index.json
  3. Build the Solution. It should restore the package and build successfully.
  4. (optional)Rename the Solution name. In this case I have renamed to Retail.Commerce
  5. (Optional) Create a solution folder “Project” and move Sitecore.Commerce.Engine project
  6. (Optional) Rename “Sitecore.Commerce.Engine” project to “Retail.Commerce.Engine”. Re reference AdventureWorks, Habitat and BrainTree projects if required. Adjust/rename namespace in classes.
  7. (Optional) Create Foundation and Feature projects. Build the solution again.
CompileVS

Step 3 – Generate Development Certificate

Generate development certificate using script “New-DevelopmentCertificate”, so the localhost runs on SSL(https)

  1. Open powershell script and navigate to scripts folder.
  2. Execute New-DevelopmentCertificate script
  3. Change the Path($certificateOutputDirectory) if required. Certificate should be copied to \src\Project\Engine\code\wwwroot
generate_certificate
generate_certificate1

Step 4 – Update configuration

  1. Change environment in Engine project/wwwroot/config.json file to HabitatAuthoring
  2. Change “SitecoreIdentityServerUrl”: “https://storefront930.identityserver.local”,
  3. Add the site name in AllowedOrigins in config.json
  4. Open Global.json in  wwwroot/bootstrap folder in Engine project
  5. Update SQL Server, UserName and Password in EntityStoreSqlPolicy
  6. Check the database name
globalconfig1

7. Update Host to your site host name in SitecoreConnectionPolicy

globalconfig2

Note: You may copy the config.json and gloal.json file from Authoring Site hosted in IIS to your project, but to better understand the changes required I have noted the changes. 

Step 5 – Update allowed origins in Identity Site

  1. Open Sitecore.Commerce.IdentityServer.Host.xml file. Should be in /config/production/Sitecore.Commerce.IdentityServer.Host.xml
  2. Navigate to section <CommerceEngineConnectClient><AllowedCorsOrigins>
  3. Add https://localhost:5000 to the

Step 6 – Ready for running the Engine

  1. Set Engine as your Startup Project
  2. Change the debug profile to “Engine” instead of “IIS Express”
  3. In IIS stop Authoring site. i.e. for your default instance it might be CommerceAuthoring_sc930 site
  4. Run the Engine from Visual Studio. This will open the console.
  5. Once the plugins are instantiated, it should listen to 5000 port. At this point you have configured Engine to run/debug from Visual Studio. Any calls from the business tool should be received by engine and console should be able to show the request that’s been received.
RunVSComm1
RunVSComm3

And here we have business tool sending request to engine running on Visual Studio, see GetNavigationView() been called in console-

Bixfx
RunVSComm4

Sitecore project – Fix broken intellisense

IntelliSense provides code completions based on language semantics and an analysis of your source code.IntelliSense suggestions popup as you type. This might trouble you whilst setting up Sitecore new project. 

It comes with the following error-Error CS1061 ‘HtmlHelper<RenderingModel>’ does not contain a definition for ‘Sitecore’ and no extension method ‘Sitecore’ accepting a first argument of type ‘HtmlHelper<RenderingModel>’ could be found (are you missing a using directive or an assembly reference?)


Following can be checked if the Sitecore intellisense is not poping up-1. Check if Sitecore.Mvc namespace is added in web.config. Namespace should sit in  <pages pageBaseType=”System.Web.Mvc.WebViewPage”><namespaces>2. Check if web.config file is in View folder. If not, you might need to add this.3. Follow same as Point 1 for web.config file in View folder.4. Next you must have referenced Sitecore.Mvc dll in the project. Set the Copy Local to true.5. Rebuild solution and re-open the cshtml file(s).
The intellisense should now be working.