Add extra parameters to your BizFx container/pod in Sitecore Commerce 10

Hello happy Sitecorians. The Sitecore Symposium is near and guess what, it’s all free, so register at once 🙂

Today’s post will be about how to add extra parameters to your BizFx – The Sitecore Commerce Business Tools. In our scenario, we want to be able to set the default environment name when the BizFx container/pod is created.

So how do we do that? Well, it’s quite easy. We need to create a custom docker image for BizFx, add a PowerShell script that will grab the extra parameter, and update the config.json file in C:\inetpub\wwwroot\assets\config.json.

Let’s start out with the docker file. The ARG BASE_IMAGE will hold the original BizFx image from Sitecore. The Init.ps1 is the PowerShell script we will create later.

# escape=`
# This Dockerfile is used to generate images for the following roles: bizfx



WORKDIR c:/inetpub/wwwroot

USER commerce_admin

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

COPY Init.ps1 "C:\\inetpub\\"

ENTRYPOINT ["C:\\LogMonitor\\LogMonitor.exe", "powershell.exe", "C:\\inetpub\\Init.ps1", "C:\\inetpub\\wwwroot\\assets\\config.json"]

Next is to create the PowerShell script – Init.ps1. Notice that we are grabbing the existing config.json, which is located in C:\inetpub\wwwroot\assets. And then we set the parameters, using environment variables which are set in docker compose/k8 specs.

    [Parameter(Mandatory = $true)]
    [string] $ConfigPath
$config = Get-Content -Path $ConfigPath | ConvertFrom-Json
$settings = @{
    "EnvironmentName" = $env:sitecore_xc_bizfx_default_environmentname
    "EngineUri" = $env:sitecore_xc_bizfx_authoring_url
    "IdentityServerUri" = $env:sitecore_xc_bizfx_identity_server_url
    "BizFxUri" = $env:sitecore_xc_bizfx_bizfx_url
    "Language" = $env:sitecore_xc_bizfx_default_language
    "ContentLanguage" = $env:sitecore_xc_bizfx_default_language
    "Currency" = $env:sitecore_xc_bizfx_default_currency
    "ShopName" = $env:sitecore_xc_bizfx_default_shopname
foreach ($key in $settings.Keys) {
    Write-Host "Updating [$configPath] config: Set [$($settings.Item($key))] as [$key]"
    $config.$key = $settings.Item($key)
$config | ConvertTo-Json | Set-Content $ConfigPath

& "C:\ServiceMonitor.exe" w3svc

In docker-compose.override.yml we will build the image:

    image: mycustom-xc-bizfx
      context: ./docker/build/bizfx

And finally in docker-compose.yml we set the environment variables:

    isolation: ${ISOLATION}
    image: ${XC_SITECORE_DOCKER_REGISTRY}sitecore-xc-bizfx:${XC_PACKAGES_TAG}
        condition: service_started
        condition: service_started
        condition: service_started
      sitecore_xc_bizfx_default_environmentname: ${XC_BIZFX_DEFAULT_ENVIRONMENTNAME}
      sitecore_xc_bizfx_bizfx_url: https://${BIZFX_HOST}
      sitecore_xc_bizfx_authoring_url: https://${AUTHORING_HOST}
      sitecore_xc_bizfx_identity_server_url: https://${ID_HOST}
      sitecore_xc_bizfx_default_language: ${XC_BIZFX_DEFAULT_LANGUAGE}
      sitecore_xc_bizfx_default_currency: ${XC_BIZFX_DEFAULT_CURRENCY}
      sitecore_xc_bizfx_default_shopname: ${XC_BIZFX_DEFAULT_SHOPNAME}
      - "traefik.enable=true"
      - "traefik.http.middlewares.force-STS-Header.headers.forceSTSHeader=true"
      - "traefik.http.middlewares.force-STS-Header.headers.stsSeconds=31536000"
      - "traefik.http.routers.bizfx-secure.entrypoints=websecure"
      - "traefik.http.routers.bizfx-secure.rule=Host(`${BIZFX_HOST}`)"
      - "traefik.http.routers.bizfx-secure.tls=true"
      - "traefik.http.routers.bizfx-secure.middlewares=force-STS-Header"

That should do it!

That’s all for now folks 😊

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.