Sitecore Marketing Automation Engine not starting


When investigating on dynamic environment setup and configuration on Azure. I came across an issue when Marketing Automation Engine worker process was going back to Pending restart state.

The Issue

The Sitecore Marketing Automation engine is not starting up. In spite of manually start again it going back to PendingStart state.

The Solution

First thing is to check the logs. When I see the logs for marketing automation engine webjob. It was having below given error message.

[11/24/2022 05:20:10 > 701b8b: SYS INFO] Run script 'Sitecore.MAEngine.exe' with script host - 'WindowsScriptHost'
[11/24/2022 05:20:11 > 701b8b: SYS INFO] Status changed to Running
[11/24/2022 05:20:11 > 701b8b: INFO] 
[11/24/2022 05:20:11 > 701b8b: INFO] Starting Marketing Automation Engine...
[11/24/2022 05:20:12 > 701b8b: ERR ] ERROR
[11/24/2022 05:20:12 > 701b8b: ERR ] System.Xml.XmlException: Data at the root level is invalid. Line 1, position 1.
[11/24/2022 05:20:12 > 701b8b: INFO] 
[11/24/2022 05:20:12 > 701b8b: ERR ]    at System.Xml.XmlTextReaderImpl.Throw(Exception e)
[11/24/2022 05:20:12 > 701b8b: ERR ]    at System.Xml.XmlTextReaderImpl.ParseRootLevelWhitespace()
[11/24/2022 05:20:12 > 701b8b: ERR ]    at System.Xml.XmlTextReaderImpl.ParseDocumentContent()
[11/24/2022 05:20:12 > 701b8b: ERR ]    at System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader, Boolean preserveWhitespace)
[11/24/2022 05:20:12 > 701b8b: ERR ]    at System.Xml.XmlDocument.Load(XmlReader reader)
[11/24/2022 05:20:12 > 701b8b: ERR ]    at System.Xml.XmlDocument.LoadXml(String xml)
[11/24/2022 05:20:12 > 701b8b: ERR ]    at ?????????????????????????????????????????.?????????????????????????????????????????(????????????????????????????????????????? , String )
[11/24/2022 05:20:12 > 701b8b: ERR ]    at ?????????????????????????????????????????..ctor(String )
[11/24/2022 05:20:12 > 701b8b: ERR ]    at ?????????????????????????????????????????..ctor(String )
[11/24/2022 05:20:12 > 701b8b: ERR ]    at Sitecore.XConnect.Configuration.Extensions.InitializeLicenseCheck(IServiceCollection collection, String licenseFileOrXml)
[11/24/2022 05:20:12 > 701b8b: ERR ]    at Sitecore.XConnect.Configuration.Extensions.UseXConnectServiceInitializationConfiguration(IServiceCollection collection, IConfiguration configuration, String[] configurationSectionNames, String initializationSectionName, Boolean validateConfiguration)
[11/24/2022 05:20:12 > 701b8b: ERR ]    at Sitecore.Xdb.MarketingAutomation.Engine.App.ServiceConfiguration.ConfigureServices(IConfiguration configuration, Boolean useDecorators)
[11/24/2022 05:20:12 > 701b8b: ERR ]    at Sitecore.Xdb.MarketingAutomation.Engine.App.ServiceConfiguration.Reload()
[11/24/2022 05:20:12 > 701b8b: ERR ]    at Sitecore.Xdb.MarketingAutomation.Engine.App.Program.RunAsConsoleApp(Boolean interactive)
[11/24/2022 05:20:12 > 701b8b: SYS INFO] Status changed to Success
[11/24/2022 05:20:12 > 701b8b: SYS INFO] Process went down, waiting for 60 seconds
[11/24/2022 05:20:12 > 701b8b: SYS INFO] Status changed to PendingRestart

At a first glance, above error message does not provide any valuable clue. But when read it fully and after few reads, found out the issue is related to license file. The InitializeLicenseCheck method indicate it clearly. Checked the license file on the MA engine job directory and the file contains only the text “LicenseContent” which is obviously not a valid xml format and there is no root element…!!!

In this Marketing automation Operations web app, there are two license files. One for the web application under the path <website root directory>\App_Data\license.xml and another one for MA engine worker job for which the path of license file is <website root directory>\App_Data\jobs\continuous\AutomationEngine\App_Data\license.xml.

Replace the content of both the license files with the correct license xml content. Stop and start the webjob and web application and the happy days…!!!!

Posting this message as I could not found any blog providing any solution about this error message. Hope this helps my fellow Sitecorians!

Advertisement

Sitecore PowerShell – Find Duplicate value in item field


I come across this type of need so may time in my entire career of Sitecore Development. Where I need to find the duplicate value in item’s field. I am writing this as note to me for my own future reference. Hopping this will also help my Sitecore community.

$dictionaryItems = Get-Item -Path 'master:' -Query "/sitecore/system/Dictionary//*[@@templateid='{6D1CD897-1936-4A3A-A511-289A94C2A7B1}']" | Select-Object -Property ID, DisplayName, @{Label="DictionaryKey"; Expression= {$_['Key']}}
$uniqueCollection = $null
foreach ($item in $dictionaryItems){
    if($uniqueCollection -Contains $($item.DictionaryKey)){
        Write-Host "Duplicate Field Value found in item ID  $($item.ID)"
    }
    else{
        $uniqueCollection += $item.DictionaryKey
    }
}

Happy Sitecore PowerShelling…!!!

References

Sitecore Coveo Search Resource Component and Dictionary Items


Recently, I am working on a bug reported by one of our tester. The issue stating none of the Coveo pages on few of the SXA websites working post upgrade of Coveo SXA module.

The Issue

The website suddenly started showing error message “The component is not available at this moment. Please contact the site administrator.” under Coveo’s Search Resources Component on the website pages.

Strangely, the same functionality(or rather I say partial design) used by other SXA website are working like charm. But only 2 websites which has whole Coveo Search functionality has been broken.

The Finding

First obvious thing I did was open the Google and search for the error message. After some time spending on reading multiple blogs and articles, I come with this link on Coveo’s articles.

As Article suggested, I have verified both the conditions, firstly checked extranet/Anonymous(user and domain configure with Site Definition) has read access to both Sitecore/System/Dictionary items and additional dictionary item configured at the Coveo Search Resource Data source item. Secondly, checked we have correct dictionary item selected under the field Additional Dictionaries for Coveo Search Resources item configured as data source to respected UI component.

Now, I was trying to isolate the issue, to make sure the issue is due to either dictionary or its child items. So, I tried to remove the dictionary item form the additional dictionary field, publish the item and magically all the broken Coveo Pages started working…!!!

So now, I am sure there is something to do with the dictionary item for that SXA website.

The Solution

I started decoding the Coveo Search Resources SXA UI component and found the logic for getting the component properties have a validation which validates the unique dictionary keys under the selected dictionary.

This is a great lead…..!!!(it took me fair few hours of dotPeeking to find this out) That left me with great confidence that there are some dictionary entry item which has the duplicate value in the Field Key.

I did first obvious check of unique item name by turning validation rule on via Sitecore’s Content Editor’s left gutter.

But none of the dictionary entry items have duplicate name. So now, I need to relay on my Poweshell skills to find the duplicate value on Key field of item /sitecore/templates/System/Dictionary/Dictionary entry.

I did created and executed the script to find the duplicate value in the field and found there is one entry under the dictionary which has exact same value present in the Key Field.

I removed that unwanted entry item which is lately added by one of the content editor while copying dictionary entries from older SXA website to the new one.

Happy Coveo Sitecore search…!!!

References

https://connect.coveo.com/s/article/7419?

Sitecore Launchpad icons missing


Recently, I am working on an upgrade project (which you must have been knowing if you read few of my recent blogs) and we encountered one very weird issue on Sitecore CM.

The Issue

After successful login to CM, the Launchpad is not showing any icons.

The Solution

First obvious thing I did was open the developer toolbar and inspected the icon image requests under the network tab and it was looking like below image.

All the request to icon images were getting HTTP500 internal server errors. Also observed that .aspx extension is being added at the end of the image extension. For example, /-/icon/LaunchPadIcons/48×48/desktop.png.aspx.

Just dig around the issue, and it turned out, we recently updated the Nuget page reference for the SharpZipLib library to the latest version 1.3.3 for one of the project in customization solution.

The OOTB(vanilla) Sitecore 10.2 also uses the same library but with different version of it.

We matched the version of ICSharpCode.SharpZipLib.dll with the version number come as Vanilla Sitecore Version 1.3.2 and magically all the icons on launch page started appearing again.

Happy Sitecore upgrade…!!!

Configure .Net Remote Debugging Service in Sitecore 10.2 Docker


Hi Sitecorians,

It’s been very long since, I last blog. But the wait is over and I am here with some of my learning while upgrading our Siteore platform from 9.3 to 10.2( latest and greatest). With this project, there are lots of learning and I’ll try to share it with you community.

The Issue

After deploying the customisation on top of the vanilla Sitecore 10.2 (huge applaud to Developers of Sitecore and the vibrant community to create and maintain the Docker sample repository), the first obvious step is to do a quick sanity test to check whether or not anything is broken??…. and the unexpected happens, one of the custom written pipeline code was complaining and logging errors in the CM log file.

So the next best handy tool for a developer in Dot Net world is the .Net debugger( thank God). While, I was trying to attache to w3wp process of CM container the following error appeared.

Unable to connect to the Microsoft Visual Studio Remote Debugger named 'XXX.XXX.XXX.XXX'.  The Visual Studio 2022 Remote Debugger (MSVSMON.EXE) does not appear to be running on the remote computer. This may be because a firewall is preventing communication to the remote computer. Please see Help for assistance on configuring remote debugging.

The Solution

As per the error message above, it’s clear, there is something not right with the MSVSMON.EXE.

Immediately fire up following PowerShell commands to look into running processes under the CM container.

PS> Docker exec -it <<CM Container name/id>> powershell
PS> Get-Process

The output of the Get-Process command was not showing any currently running process with name msvsmon. uuhhhh… that is the issue, I guess…!!!

So to get the .Net remote debugging working on the CM container, I did checked how we had it working in our 9.3 sitecore Docker Environment. Found 3 different steps to get it working. I wanted to document is in my diary but did not got chance. It is never to late.

Lets have a look at those 3 steps one after another.

Step 1.

Open the docker-compose.override.yml file, add below line under the volumes

 cm:
    image: ${REGISTRY}${COMPOSE_PROJECT_NAME}-xp0-cm:${VERSION:-latest}
    build:
      context: ./docker/build/cm
      args:
        BASE_IMAGE: ${SITECORE_DOCKER_REGISTRY}sitecore-xp0-cm:${SITECORE_VERSION}
        SPE_IMAGE: ${SITECORE_MODULE_REGISTRY}sitecore-spe-assets:${SPE_VERSION}
        SXA_IMAGE: ${SITECORE_MODULE_REGISTRY}sitecore-sxa-xp1-assets:${SXA_VERSION}
        TOOLING_IMAGE: ${SITECORE_TOOLS_REGISTRY}sitecore-docker-tools-assets:${TOOLS_VERSION}
    volumes:
     - ${REMOTEDEBUGGER_PATH}:C:\remote_debugger:ro
Step 2.

Next step to add the REMOTEDEBUGGER_PATH variable to the .env file. To do so open your .env file in VS Code or your choice of text editor and add below line to it.

REMOTEDEBUGGER_PATH=C:\Program Files\Microsoft Visual Studio\2022\Professional\Common7\IDE\Remote Debugger\x64

Now, you need to change the path of debugger folder in above with the VS version you are using. For, now I am using VS 2022 Professional but we have some developers still using VS 2019 Professional for them the path will be C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\Common7\IDE\Remote Debugger\x64

Step 3.

Now, in the third and the final step, we will try to execute multiple processes at the entry point for CM container. To do so, I have added few commands to the existing Powershell entry point command.

 cm:
    image: ${REGISTRY}${COMPOSE_PROJECT_NAME}-xp0-cm:${VERSION:-latest}
    build:
      context: ./docker/build/cm
      args:
        BASE_IMAGE: ${SITECORE_DOCKER_REGISTRY}sitecore-xp0-cm:${SITECORE_VERSION}
        SPE_IMAGE: ${SITECORE_MODULE_REGISTRY}sitecore-spe-assets:${SPE_VERSION}
        SXA_IMAGE: ${SITECORE_MODULE_REGISTRY}sitecore-sxa-xp1-assets:${SXA_VERSION}
        TOOLING_IMAGE: ${SITECORE_TOOLS_REGISTRY}sitecore-docker-tools-assets:${TOOLS_VERSION}
    volumes:
      - ${REMOTEDEBUGGER_PATH}:C:\remote_debugger:ro
    networks:
      dev.local:
        aliases:
          - cm.dev.local
    entrypoint: powershell -Command "& Write-Host 'Starting Debugger Service...'; & Start-Process -FilePath 'C:\remote_debugger\msvsmon.exe' -ArgumentList '/nostatus', '/silent', '/noauth', '/anyuser', '/nosecuritywarn', '/wow64port 4026'; & C:\tools\entrypoints\iis\Development.ps1"

With the above alteration firstly, I am writing to host to get to know that it is trying to start debugger service and secondly executing MSVSMON.EXE file with few arguments as Start-Process powershell command.

With the argument wow64port mind that each Visual Studios have their own ports assigned as default debugging port for msvsmon.exe. See the references in section below.

Verification

As verification of both w3wp and msvsmon services running we need to check the output of Get-Process command on CM container

Note

Also make sure in the web.config of your CM container, the debug is set to true for compilation node. configuration/system.web/compilation[debug=’true’]

Note

Notice that I am using (;) semicolon as the command terminator for powershell command. If you are using CMD, use & (ampersand)

References

https://docs.microsoft.com/en-us/visualstudio/debugger/remote-debugger-port-assignments?view=vs-2022

https://ss64.com/ps/call.html

https://github.com/microsoft/DockerTools/issues/91

Sitecore Unicorn Exclude Fields


While you have a high functional developers team working on multiple Sitecore projects with same code base, it is very vital to keep the local development environment as stable and functional as possible and also keep PR short.

While achieving that stage, we came across one small issue which is intern made me to write a blog in my journal what you are reading now.

The Issue

While reviewing PRs, we observed, there is one Unicorn’s .yml file come as default to quite a few PRs. The change it has got was just few fields updated.

After quick initial investigation, found out that yml file is nothing but one of the Data Exchange Framework(DEF) batch processing item in Sitecore content tree under system node.

After bit more investigation, it turns out the sitecore’s schedule task is triggering that DEF batch process. But that raise another question, why that schduler task item is not coming as changed item list as it is also source controled using Unicorn.

The Resolution

Lets focus on the second question for now, as it has quite a quick and simple answer.

The \App_Config\Include\Unicorn\Unicorn.config has one section called <fieldFilter> which takes care of it. As few frequently value changing fields has already been excluded from being serialized (smart stuff Unicorn Developers).

That section is looking like below

<fieldFilter type="Rainbow.Filtering.ConfigurationFieldFilter, Rainbow" singleInstance="true">
					<exclude fieldID="{B1E16562-F3F9-4DDD-84CA-6E099950ECC0}" note="'Last run' field on Schedule template (used to register tasks)" />
					<exclude fieldID="{52807595-0F8F-4B20-8D2A-CB71D28C6103}" note="'__Owner' field on Standard Template" />
					<exclude fieldID="{8CDC337E-A112-42FB-BBB4-4143751E123F}" note="'__Revision' field on Standard Template" />
					<exclude fieldID="{D9CF14B1-FA16-4BA6-9288-E8A174D4D522}" note="'__Updated' field on Standard Template" />
					<exclude fieldID="{BADD9CF9-53E0-4D0C-BCC0-2D784C282F6A}" note="'__Updated by' field on Standard Template" />
					<exclude fieldID="{001DD393-96C5-490B-924A-B0F25CD9EFD8}" note="'__Lock' field on Standard Template" />
				</fieldFilter>

So now, for my initial issue to fix , I simply have to add a field I wanted to exclude form being serializedin to this fieldFilter section.

So, I created new patch configuration file (as best practice suggests) an try to patch my new exclude fields under the node <fieldFilter>. At first, I did add the config like following

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:role="http://www.sitecore.net/xmlconfig/role/" xmlns:environment="http://www.sitecore.net/xmlconfig/environment/">
	<sitecore role:require="Standalone or ContentManagement">
		<unicorn>
			<defaults>
				<!--
					The field filter can be used to ignore fields when comparing or serializing (i.e. don't write them to disk).
					Commonly, metadata fields such as Last Updated will be ignored to prevent SCM conflicts.
				-->
				<fieldFilter>
					<exclude patch:after="exclude[@fieldID='{001DD393-96C5-490B-924A-B0F25CD9EFD8}']" fieldID="{985BA535-0F3E-4DA8-A768-A469026DE9DB}" note="'RequestedAt' field of DEF's Pipeline Batch item" />
					<exclude patch:after="exclude[@fieldID='{001DD393-96C5-490B-924A-B0F25CD9EFD8}']" fieldID="{6A2B2CBB-4338-4814-A8A9-9FECBB90456A}" note="'LastRunFinished' field of DEF's Pipeline Batch item" />
					<exclude patch:after="exclude[@fieldID='{001DD393-96C5-490B-924A-B0F25CD9EFD8}']" fieldID="{2AA5C591-FF55-411D-96C0-978BB2C58B94}" note="'Log' field of DEF's Pipeline Batch item" />
				</fieldFilter>
			</defaults>
		</unicorn>
	</sitecore>
</configuration>

But this has weird patching when I see showconfig.appx. It actually replaces first three entries form the original xml…!!!???

I did ask God(google) and found that sitecore sometime does not patch correctly if proper attributes are not used. Someone suggest to use hint attribute to control the patching.

I did replace my patching config attribute note with the hint and eureka….!!!

This is the final configuration patch file looks like.

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:role="http://www.sitecore.net/xmlconfig/role/" xmlns:environment="http://www.sitecore.net/xmlconfig/environment/">
	<sitecore role:require="Standalone or ContentManagement">
		<unicorn>
			<defaults>
				<!--
					The field filter can be used to ignore fields when comparing or serializing (i.e. don't write them to disk).
					Commonly, metadata fields such as Last Updated will be ignored to prevent SCM conflicts.
				-->
				<fieldFilter>
					<exclude patch:after="exclude[@fieldID='{001DD393-96C5-490B-924A-B0F25CD9EFD8}']" fieldID="{985BA535-0F3E-4DA8-A768-A469026DE9DB}" hint="'RequestedAt' field of DEF's Pipeline Batch item" />
					<exclude patch:after="exclude[@fieldID='{001DD393-96C5-490B-924A-B0F25CD9EFD8}']" fieldID="{6A2B2CBB-4338-4814-A8A9-9FECBB90456A}" hint="'LastRunFinished' field of DEF's Pipeline Batch item" />
					<exclude patch:after="exclude[@fieldID='{001DD393-96C5-490B-924A-B0F25CD9EFD8}']" fieldID="{2AA5C591-FF55-411D-96C0-978BB2C58B94}" hint="'Log' field of DEF's Pipeline Batch item" />
				</fieldFilter>
			</defaults>
		</unicorn>
	</sitecore>
</configuration>

After this, Unicorn re-serialized the DEF pipeline batch items and happy days….!!!!

Note:

There is new feature “fieldTransforms” available in Unicorn 4.1 and later version but I have not able to get that working on my project setup. But, something worth exploring for next time.

References

Sitecore SXA – Way of adding Custom Front End Assets


The Sitecore has change the website development with launch of the SXA with their first release and now they have make their vision very clear about how to quickly ship the website to market via this very powerful tool.

The Issue

While working on one of the SXA website build project, I came across one strange finding. Even if you selected Bootstrap 4 as your grid system for website. There are may out of the box bootstrap css classes are missing. This leads to some investigation ad found of the Sitecore SXA has ported just grid related styles(bootstrap-grid.css) to Sitecore SXA but not the full bootstrap main css(bootstrap.css)

Now, I have two concerns, first how can we add this the Sitecore SXA way without touching existing MVC layout or creating new layout? and Secondly, how can you only enable/import this to selective websites?

The Fix

After some googleing and reading few of Sitecore documents, found following steps will help get the answers to both above mentioned concerns.

  1. Create new base theme item of type /sitecore/templates/Foundation/Experience Accelerator/Theming/Base Theme under path /sitecore/media library/Base Themes (one can use insert options too). In my example I have given name bootstrap 411.
  2. Create a Styles folder item of type /sitecore/templates/Foundation/Experience Accelerator/Theming/Folders/Styles (one can use insert option) under the newly created base theme item above.
  3. Upload the css file to this styles folder using media upload feature. In my example I have uploaded bootstrap.css
  4. Navigate to the site specific theme item under media library. For example, /sitecore/media library/Themes/Tenant1/Website1
  5. In the Base Themes multi-select link field select the newly created base theme item in step 1 above
  6. Publish all newly created items in step 1 and 2
  7. Publish altered website specific theme item

Verification

New styles should work if the newly added stylesheet render on the page. To verify style link is render on website page or not we need to turn The Asset Optimizer off for the site (by default this is on and if it is already turned off you can skip these steps)

  1. In the Content Editor, navigate to sitecore/content/<Tenant>/<Website>/Presentation/Page Designs.
  1. In the Asset Optimization section, in the Styles Optimizing Enabled and Scripts Optimizing Enabled fields, to override styles and scripts optimization settings, select:
    • Default – to inherit global settings.
    • Yes – to always enable optimization for this site.
    • No – to always disable optimization for this site.

3. Publish the Page Design Item

4. Navigate to the web application in the browser and open the page view source and look for the newly created item path in the head section. In my example, looking for bootstrap-411(don’t mind the hyphen as it is due to link manager options settings)

<link href="/-/media/base-themes/bootstrap-411/styles/bootstrap.css" rel="stylesheet" />

Further to verify, also check other website within the same CMS and check the page source view for absence of newly added stylesheet.

In above example, we have added Style Sheet asset but this same can be done for Scripts assets as well

Happy Sitecore SXA website development…!!!

References

Sitecore Docker – Run CM sites on HTTPS


While working on the integrating Sitecore’s CM’s functionality with third party Digital Asset Management(DAM) system, I came across one interesting issue where I wanted my container applications to run on https.

The Issue

After integrating the third party DAM with Sitecore CMS, it found out that, while using local website on developer machine, the developer is not able to load the SSO login page. While loading that page below error messages logged in browser’s console.

Access to the WebCrypto API is restricted to secure origins. Compact View requires HTTPS when used outside localhost (for development).

As clearly stated I am not using localhost as host to access my cm and seems like CM needs to be securely severed over https where as we, for local development, use non secure protocol http.

The Fix

The solution is simple looking form 35,000 feet. Needs CM urls to be serving content over the secure HTTPS protocol. But when actually started digging in details, it is fun and very learning experience.

Performed following steps to achieve this on our local docker development environment.

  1. Clone or download below repository

https://github.com/michaellwest/docker-https

  1. Open the startup/createcert.ps1 for editing and change following parameter’s default value
  • $certificatepassword – from b to more secured passowrd string
  • $dnsNameList – by default the value is *.dev.local. Change this value to match your host pattern. You can specify individual host comma(,) separated.

Note

Alternatively, you can can pass those two as parameter while firing createcert.ps1 command.

3. Open docker-compose.yml file and navigate to cm service and perform following changes:

  • Add new environment parameter HOST_HEADER and set cm host value to it. If you have multiple host(this is what in my case), specify them semicolon(;) separated list. For example host1.dev.local;host2.dev.local
  • Under the volumes bind the new volume for folder startup to c:\startup path of container.
  • Under the port bind the https’s default secure port 443 with the next available container port

Note

The container host port needs to be new port which is not been use by any other services.
  • Lastly, change the entypoint to the path of startup.ps1 file under the startup folder bound under the volumes in above step for startup folder.

After all above changes to CM service of docker-compose.yml file will look something like below

services:
  ...
  cm:
    image: ${REGISTRY}sitecore-xm-cm:${SITECORE_VERSION}-windowsservercore-${WINDOWSSERVERCORE_VERSION}
    entrypoint: powershell.exe -NoLogo -NoProfile -File C:\\startup\\startup.ps1
    volumes:
      - .\src:C:\src
      - .\startup:C:\startup
    ports:
      - "44001:80"
      - "44002:443"
    networks:
      default:
        aliases:
          - cm.dev.local
          ...
    environment:
      HOST_HEADER: cm.dev.local
      ...

4. Copy folder startup and it’s content to same folder where your docker-compose.yml file is.

5. Open the powershell in elevated mode and execute following command

PS> cd <<docker-compose.yml file's folder path>>
PS> ./startup/createcert.ps1

Above powershell script will generate three files cert.cer, cert.pfx and cert.password.text under the startup folder.

This command will also generate the self-signed wildcard certificate and install to your system’s local certificate store under personal.

To verify that run mmc and open local computer certificate store.

Self signed wildcard certificate for *.dev.local

6. Now, is the time to fire up the container for sitecore. To do so run following docker compose command

PS> docker-compose up -d

After successful execution the container services will be up and one can access the host binding with https. For example https://cm.dev.local in this case.

Advance trouble shooting

  1. To check the certificate is exist after the createcert.ps1 script execution. This command can be run on both your local and against cm container as well.
PS> Get-ChildItem -Path cert:\LocalMachine\Root


PS> Get-ChildItem -Path cert:\CurrentUser\Root

  1. To verify the binding under the container’s IIS for the specified hosts use following commands
PS> Get-Website -Name 'Default Web Site'
  1. To get all the bindins and their port details for a website
PS> Get-WebBinding -Name 'Default Web Site'

References

Sitecore Powershell Reports – Export Functionality not working


The QA team, we are working with has raised a very interesting issue while testing newly created data report using Sitecore Poershell Extenstion(SPE).

The Issue

The data report was executing perfectly but while trying to export the data in any of pre-defined formats offered by SPE, it was not working.

The Sitecore Powershell is allowing export of report data in various industrial standard formats out of the box as listed below:

  • CSV
  • HTML
  • XML
  • Excel
  • JSON

These formats have option links in the ribbon above but when clicking, none of those producing any output.

¯\_(ツ)_/¯

The Investigation

First step is to try to reproduce the issue. We tried on all the available environments and it is happening on every environment except for the local environment.

I though the issue may have to do with some missing config or SPE. So, we quickly try to re-install the SPE module on CM with no over-write option for both files and content on Integration Environment. But that does not fix the issue. ☹

So, we started listing what are the major difference from modules and features point of view between local development and other environments on Azure. It turns out that all other environments have exactly the same piece of code, configurations and modules installed except for Federated Authentication using Sitecore Identity Server for CM.

The Fix

We did quick search over the internet and one of my colleague found out that there is one file which is disabled for SPE which needs to be enable if we are using sitecore 9.1 and higher(we are running 9.3) along with identity server.

The file needs to be enabled is Spe.IdentityServer.config file which is part of the SPE package.

Once package is installed, the file is located at path <<website Root>>\App_Config\Include\Spe\Spe.IdentityServer.config.disabled. The content of this disabled file is as below.

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:role="http://www.sitecore.net/xmlconfig/role/" xmlns:security="http://www.sitecore.net/xmlconfig/security/">
  <sitecore role:require="Standalone or ContentManagement" security:require="Sitecore">
    <pipelines>
      <owin.cookieAuthentication.validateIdentity>
        <processor type="Sitecore.Owin.Authentication.Pipelines.CookieAuthentication.ValidateIdentity.ValidateSiteNeutralPaths, Sitecore.Owin.Authentication">
          <siteNeutralPaths hint="list">
            <!-- This entry corrects the infinite loop of ExecuteCommand in the SPE Console -->
            <path hint="spe">/sitecore%20modules/PowerShell</path>
          </siteNeutralPaths>
        </processor>
      </owin.cookieAuthentication.validateIdentity>
    </pipelines>
  </sitecore>
</configuration>

Tip: The best way to get these config enable in Docker container world, is to leave the above mentioned .disabled file as is. Create new configuration file with above content in Visual Studio solution deploying to z folder under app_config\include on your binding volume path which will be taken care by Sitecore config patching.

Enjoy exporting SPE reports data…!!!

References

https://github.com/SitecorePowerShell/Console/releases
https://doc.sitecorepowershell.com/troubleshooting

Sitecore Docker -Coveo Diagnosis Page Search Rest Endpoint Issue


While configuring Coveo search on my local development environment using Docker, something got my attention on Coveo’s diagnosis page(<<Sitecore CM Host>>/sitecore modules/Web/Coveo/Admin/CoveoDiagnosticPage.aspx).

This page has all the green ticks except for the one. This is Coveo Search REST Endpoint. See image below for more details.

Coveo Diagnostic Page REST API Error
Coveo Diagnostic Page REST API Error on Docker

As usually, I copied the API end point URL and hit in the Browser and it serve the request with no error. It is HTTP-200 response with valid JSON result.

The error in the log file also not giving any lead either.

Coveo.SearchProvider.Applications.BaseVerifier.VerifyComponent(:0) ERROR StateVerifier has encountered an error while verifying the component "Coveo Search REST Endpoint".<br>Exception: Coveo.SearchProvider.Applications.StateVerifierException<br>Message: Failed to obtain resource located at 'http://sicore930.dev.local/coveo/rest/'. See inner exception for details.<br>Source: Coveo.SearchProvider.Applications<br>at Coveo.SearchProvider.Applications.CommonStateVerifier.TryPingRestEndpoint(String p_Endpoint)<br>at Coveo.SearchProvider.Applications.CommonStateVerifier.<>c__DisplayClass11_0.b__0()<br>at Coveo.SearchProvider.Applications.BaseVerifier.VerifyComponent(Func`1 p_VerifyMethod, String p_ComponentName)

I opened docker powershell command for the cm container and tried to request the host from within container.

PS> Docker container ls

Grab the name or container id

PS> Docker exec -it <<container name/id>> powershell

This will open a powershell window connected to the container specified.

PS> Invoke-RestMethod -Uri "http://sitecore930.dev.local/coveo/rest" | ConvertTo-Json

It has given me following error

Now things are little clear to me. The Coveo diagnosis page is using current host to make REST API request from IIS server running on the container. The container does not have host file entry to reseolve the host url.

So now, I started searching how to make entry in container’s host file??? I was sure, I am not the first person who wanted this kind of stuff.

Following command has does the trick. but for that we need to first fire up the command prompt of the cm container.



PS> Docker exec -it <<container name/id>> powershell

Once the CM’s command prompt is ready execute below command to add the host file entry.



C:> echo 127.0.0.1 sitecore930.dev.local >> "C:\Windows\System32\drivers\etc\hosts"

After executing above command on Container’s command prompt, now my Coveo Diagnosis page is Happy…!!!

Please do let me know, is there any better solution you guys have in place for this issue.

Till that time happy Coveo searching…!!!

Additional powershell command to check the content of the file:



PS> Get-Content -Path <<fully qualified file path>>