Welcome! This is my personal blog about Web technologies, software development, open source and other related topics
The ideas and opinions expressed here are solely mine and don't represent those of others, either individuals or companies.The code snippets or references to software products or analogous are to be used without any warranty of any kind. If you enjoy the content, feel free to share it and re-use it as long as you provide a link to the original post.
Step 4 – Setup the App Configuration either using appSettings or Azure App Configuration
Setup a App Configuration using appSettings.json
Use/Download the template here provided by Sitecore to setup the configuration
Create a json file on your local machine by copying the content in the template. In my case I have created OCHeadstartConfig.json. The template looks as below- Highlighted values are the minimum configuration required for Headstart project. Few of the configuration will come from the Seed step explained in Part-2 – Step 4 – Populate Ordercloud Markeplace with the seed request
Following configuration(highlighted) needs to be updated minimum to get the Headstart project working-
Get the StorageAccount.Settings.ConnectionString from Storage Explorer-
Create appSettings.json file and copy the above configuration in the file.
appSettings.json file should be in Headstart.API project-
IMP – Check if the middleware applicaiton is running and listening to localhsot 5001 port. If not you should run the Headstart.Api before running UI application.
Setup a App Configuration using Azure App Configuration
Get the configuration connection string
Goto the Access Keys – Read-only keys tab and copy the connection string
Add a new Environment Variable named – APP_CONFIG_CONNECTION and copy the connection string in the Value.
Run the middleware application with the Demo profile.
IMP – If you see compiler error’s whilst running the application. See this blog for the resolution.
Step 5 – Run the Seller UI application
Now that we have all the required configuration checked and changed, time to run the Seller UI application
RUN – from the visual studio terminal or powershell
npm install
npm run start
Now we have Seller application runing on localhost:4200 port
Provide Admin Username and Password as noted in Part -1 of the blog Step 3- Prepare Seed Request
After successful login-
Also we can see the Seller Admin-
Hope you enjoyed setting Sitecore Ordercloud Headstart 🙂
Create a new maketplace e.g.- OrderCloudHeadstart in Us-West region
IMP– At the time this blog was written looks like only Us-West region is supported when a seed request is sent. This may change in future but connect to OrderCloud team is you want this to be in region other than Us-West
Note the newly created Marketplace ID – in my case it is – OrderCloudHeadstart
If you havent provided the Marketplace ID whilst creating the OrederCloud will create once for you. You can find the same in the Marketplace.
Navigate to API Console and Get the Admin User, as you see there are no Admin users. You may also check other endpoints.
PortalUsername – enter the portal username you used to create a marketplace
PortalPassword – enter the portal password you used to create a marketplace
InitialAdminUsername – this request will create a admin user. Enter the admin username you wish to create
InitialAdminPassword – enter the admin password you want to set
MiddlewareBaseUrl – this is not required for local build
MarketplaceID – Enter the Marketplace ID you created in Step 1
Marketplace.Region– enter this to be sandbox in this case. For the other environments you might want to user different values for Staging and Production
WebhookHashKey – Set the webhook haskey to secure your webhook request.
Postman request should look like this –
STEP 4 – Setup a App Configuration using appSettings.json
Use/Download the template here provided by Sitecore to setup the configuration
Create a json file on your local machine by copying the content in the template. In my case I have created OCHeadstartConfig.json. The template looks as below- Highlighted values are the minimum configuration required for Headstart project.
Following configuration(highlighted) needs to be updated minimum to send the seed request working-
Get the StorageAccount.Settings.ConnectionString from Storage Explorer-
Create appSettings.json file and copy the above configuration in the file.
appSettings.json file should be in Headstart.API project-
IMP – Check if the middleware applicaiton is running and listening to localhsot 5001 port. If not you should run the Headstart.Api before running UI application.
Step 5 – Send the seed request to Ordercloud Markeplace
Ensure the Headstart Api is running and listening to 5001 port as mentioned in Step 2
Send the seed request
You can see the same in application that is listening to 5001 port the request was sent to-
If you have set the request correctly you should receive the success response-
IMP – Note the below response and the request that was sent specifically Admin Username and Password as this will be required later when configuring the UI application
{
"Comments": "Success! Your environment is now seeded. The following clientIDs & secrets should be used to finalize the configuration of your application. The initial admin username and password can be used to sign into your admin application",
"MarketplaceName": "ocdockertest",
"MarketplaceID": "ocdockertest",
"OrderCloudEnvironment": "Sandbox",
"ApiClients": {
"Middleware": {
"ClientID": "1141E496-8517-4953-809B-XXXXXXXXX",
"ClientSecret": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
},
"Seller": {
"ClientID": "6E98D7A1-35E9-4156-B60B-XXXXXXXXXX"
},
"Buyer": {
"ClientID": "E1EBE13C-CC74-4021-B4A9-XXXXXXXXXX"
}
},
"Success": true,
"Exception": null
}
Comments – seed response comments
MarketplaceName – gets the Marketplace name that was configured in Step 1
MarketplaceID – UniqueId that was sent as part of request and the data seeded in this Marketplace
OrderCloudEnvironment – Environment where the request was sent
ApiClients.Middleware.ClientID – Note down Middleware ClientID
ApiClients.Middleware. ClientSecret – Note down Middleware ClientSecret
ApiClients.Seller.ClientID – Note down the Seller ClientID
ApiClients.Buyer.ClientID – Note down the Buyer ClientID
Step 5- Check the Marketplace for the data been puplated
In Step 1- we saw there was not admin user created. After the seed request you can see the Admin User is created with the name mentioned in request.
Admin User
InitialAdminUser with the username provided in request is created
Also the MiddlewareIntegrationsUser is created
Buyer User
Buyer User is created-
Api Clients
Api clients created and the same was sent as response. This is used so each client have a different Id’s that helps any application to connect.
Errors-
Ensure the StorageAccountSettings:HostUrl and ConnectionString is configured correctly.
Thats it in this blog. Hope you are enjoying setting your Ordercloud Headstart project.
Since we will be now setup a backend application (i.e. admin etc) the Client IDs and Client Secret that was create in Step 5 needs to be secured. This can be condifured in Azure App Configuration. See the link on how to setup this.
Use/Download the template here provided by Sitecore to setup the configuration
Create a json file on your local machine by copying the content in the template. In my case I have created OCHeadstartConfig.json. The template looks as below-
Provide the Resource name in this case I have used OrderCloudHeadStartConfig
Select Location and Pricing tier.
Once the resource is created in the Import/Export option select –
Source service – Configuration file
For language – Other
File type- Json
Source file – *.json (auto selected)
Select the folder icon in Source file option and click Apply to import the configuration.
After the config file is imported navigate to “Configuration Explorer”. There are 63 config key values are imported but in template there are 64.
“SendgridSettings:OrderApprovalTemplateID”: “”, is not imported for due to some reason. Create a new manually if required. For the Demo this is not required.
Click on the values to see the values of the key that was imported-
Set the following values by Right clicking the keys. Copy this from Step 4 where the response was received from seed request-
OrderCloudSettings:MiddlewareClientID
OrderCloudSettings:MiddlewareClientSecret
OrderCloudSettings:MarketplaceID
OrderCloudSettings:MarketplaceName
Continue updating config in next section for Storage Account.
Step 2- Create a Azure Storage Account (if you already don’t have)
Create a Azure Storage Account
Follow the steps and set the configuration as per your requirements
Copy the storage account name and Storage connection string
Set StorageAccountSettings:BlobPrimaryEndpoint – https://yourstorageaccount.blob.core.windows.net/occontainer
Set StorageAccountSettings:ConnectionString
Thats in in this blog. In next blog will cover setting up the UI project.
Hope you are enjoying setting your Ordercloud Headstart project.
Admin User who created the Marketplace can delete and Transfer the Ownership of the Account. Where the ownership is transfered to the users cannot delete the Marketplace.
To delete the Marketplace you should have first created a Marketplace and login to the portal as Admin User having Full Access.
To setup restart policy to the container, use following command-
docker run --restart=<<policy option>> <<container>>
Following are the options for the container restart-
no (default)
on-failure
always
unless-specified
Following is the matrix for the restart policies-
* – this will start when the Docker daemon is started
Above is applicable if the container starts successfully
Live Restore
If you want to keep container running if the Docker daemon crashes or stops use the live restore option. This reeduces the container downtime due to daemon crashes or planned outages or upgrades.
Update the /etc/docker/daemon.json in Ubuntu system and add option live-restore:true
Follow below steps to configure Sitecore Ordercloud Headstart middlewarewithout having to provision Azure online resources. i.e. setup offline Azure resources
Install Azurite- Pre-requisite is to install node js
npm install -g azurite
Run Azurite- Navigate to the folder where the supporting files should be deployed e.g.: c:\Azurite
azurite start
OR - if you want specfic folder and in debug mode
azurite --silent --location c:\azurite --debug c:\azurite\debug.log
Blob service should listen to http://127.0.0.1:10000
Step 2 – Install Microsoft Azure Storage Explorer
Install Azure storage explorer. Download from here
Step 3 – Configure Blob Containers
Connect to Local Azure Storage
Click on the connect to open the connection dialog box
Select the Local storage emulator
Fill in the required details
Display name
Account name – this wil be used to connect to the blob storage
Blobs port- port used to connect to the vlob storage
Queues and Tables port- port used to connect queues and tables respectively
These are the connection information (you might have to note this)-
Local account is created-
Storage Explorer is now able to conect to Local Storage Emulator i.e. Azurite
Create a Blob Container – ngx-translate and create new Virtual Directory i18n
Blob Container and folder name can be any other name. You need to configure this correctly in UI config.See this in later steps
Upload the translation file
Ideally Container, Virtual Directory and trnslation file should be created by Headstart Api. I couldn’t make it work. Hence alternative this I have attached en.json file here.
Once uploaded you should be able to see the uploaded file-
Set Public Access Level to Blob Container
Select the Public read access for containers and blobs
Configure CORS settings
CORS settings are required for accessing the en.json file to access from the local blob storage
Error – while running the HeadStart.Api from the Azure Api Configuration when Cosmos is not setupin ServiceCollectionExtensions.cs
When writing this blog there is a issue whilst connecting the Cosmos service is the configuration for the same is set.
Change the code to following in ServiceCollectionExtensions.cs file-
Change the highlighted line as the empty strings are not gracefully handled.
Resolution –
==> ServiceCollectionExtensions.cs
if(string.IsNullOrEmpty(config.DatabaseName)||
string.IsNullOrEmpty(config.EndpointUri) ||
string.IsNullOrEmpty(config.PrimaryKey))
{
// allow server to be started up without these settings
// in case they're just trying to seed their environment
// in the future we'll remove this in favor of centralized seeding
// capability
return services;
}
Error – while running the HeadStart.Api from the Azure Api Configuration when Cosmos is not setupin CosmosExtensions.cs
When writing this blog there is a issue whilst connecting the Cosmos service is the configuration for the same is set.
Change the code to following in CosmosExtensions.cs file-
Change the highlighted line as the empty strings are not gracefully handled.
Resolution- Crate a cosmos endpoint or change the highlighted line of code to-
==> CosmosExtensions.cs
if( string.IsNullOrEmpty(endpointUrl) ||
string.IsNullOrEmpty(primaryKey) ||
string.IsNullOrEmpty(databaseName))
{
// allow server to be started up without these settings
// in case they're just trying to seed their environment
// in the future we'll remove this in favor of centralized seeding
//capability
return services;
}
Components of the Docker Engine – Docker Daemon, Rest API and Docker Cli
Component that manages Images, Containers, Volumes and Network – Docker Daemon
Component that manages containers in Docker Engine – LibContainer
Container can run with Docker – Yes
Component keeps alive container even if Docker Daemon is not working – Containerd-Shim
Docker engine objects- Images, Container, Volume and Network
In Container data is writable but not persistable – Yes
Dcoker looks for images in docker hub by default- Yes
Readonly component in Docker engine – Docker Images
Default directory where Docker data is stored (Ubuntu) – /var/lib/docker
Directory where the Docker config is stored(Ubuntu)- /etc/docker
OCI stands for – Open Container Initiative
OCI specification – runtime-spec and image-spec
View version of Docker engine – docker version
Stop the Docker service – systemctl stop docker or/and systemctl stop docker.socket
Start the Docker service – systemctl start docker.socket or/and systemctl start docker
Check Status of Docker service – systemctl status docker
Debug docker whilst starting the service – dockerd –debug
Where is the Daemon file located (Ubuntu) – /etc/docker/daemon.json
Where is the daemon socket located (Ubuntu) – /var/run/docker.sock
Port to connect the docker externaly with encrypted trafic – 2376
Port to connect the docker externaly with unencrypted trafic – 2375
Start the docker daemon manually – dockerd
Default docker daemon interface – Unix Socket
Default network driver – bridge
Stop Command signals running container on STOP command – SIGTERM followed by SIGKILL
Restart policies – no, on-failure, always and unless-stopped
Reduce container downtime due to daemon failure or restart- Enable Live Restore
Docker Images FAQ’s
Default Docker Image Registry – Docker Hub
Various Image Registry –
Docker Trusted Registry
Google Container Registry
Amazon Container Registry
Azure Container Registry
Types of Images in Docker Hub
Official Images
Verified Images
User Images
Base vs Parent Image –
Base Image are creatged from scratch, which means its empty. You cannot create a scratch image as it is always to be used. Any other images created from Base Image but used as parent to custom images are Parent Image. e.g. Ubuntu which is made from debian image. Here debian image is a Parent Image
Docker Swarm
What is the maximum and recommended number of mananger a swarm cluste can have? There is no max limit but recommended is 7 managers in swarm cluster