Content Hub – defining self-referencing relations, creating, linking and displaying entities – part 1

What are relations

In Content Hub data modeling, relations are used to define how entities are linked together. One of the entity in this relationship will be a parent and the other will be a child. The relation can either

  • be between two different types, say M.AssetType and M.Asset
  • be of the same type, say between M.Asset entities. This type of relation is known as self-referencing

In Content Hub, it is recommended to name relations using the notation ParentEntityToChildEntity. For example AssetTypeToAsset, is a relation where M.AssetType is Parent of M.Aset. Conversely, M.Asset is Child of M.AssetType

In this blog post, I will dive more into self-referencing relations, how to define them, how to create entities and link them up as well as display them within Content Hub.

Defining self-referencing relation

We typically use self-referencing relation where you want to define some form of parent-child hierarchy within your entities of the same type. Let say we have a use-case where have a ‘master’ asset and we need to link related or supporting files, so that we can easily find all related or supporting files to master asset.

To define this, you will follow the following steps:

  1. From the dashboard, click on Schema and search and find M.Asset. Select to open the M.Asset definition management page.
  2. Click on ‘New member‘ button to launch ‘New member‘ popup below. Select Create a new relation to a non-taxonomy definition option
  3. This opens a window to capture the relation definition, conditions for the relation, whether it is mandatory among other configurations. This is similar to one below
  4. We will use the above dialog to define self-reference relation. As you can see, I have alread named my relation AssetToLinkedAsset, which mean M.Asset is Parent M.Asset, using the OneToMany cardinality. I will explain more about what is cardinality later in this blog.
  5. We will ignore defining any Conditional, Required and Advanced settings for now, we are going to use the default values, as shown below.
  6. Then click Save to create the relation. This will close the popup window and go back to the M.Asset definition management page.
  7. That is it, we have defined self-referencing relation. Ensure you click on Apply changes to commit changes on the M.Asset definition management page.
  8. If we refresh our M.Asset definition management page, you will notice we now have two relationships as shown below
  9. Content Hub will automatically generate two relations shown above, where M.Asset is Parent of M.Asset as well as M.Asset is Child of M.Asset. In fact, these fields are AssetToLinkedAsset:Parent and AssetToLinkedAsset:Child respectively within the M.Asset schema

What is relation cardinality

In Content Hub, we make use of cardinality to describes how parent and children are related. All values are from Parent => Child. Below are the supported cardinalities

  • OneToOne One parent to one child.
  • OneToMany One parent to many children
  • ManyToMany Many parents to many children.

The choice depends on your use case. In my current use case, I would like my ‘master’ asset to have one or more linked or supporting files, hence I have used OneToMany

Next steps

In this blog post, I have looked at what are self-referencing relations in Content Hub. I walked through a sample use-case for them, how to define them, and steps to follow within Content Hub. In the next follow up post, I will walk you through how to create and populate self-referencing entities and link them up to create parent-child hierarchy and to display this within Content Hub.

Stay tuned and leave us any feedback or comments.

Content Hub gems: Troubleshooting issue when creating asset public links

You may encounter this is error “The user does not have sufficient rights to create the specified entity

We will look at how to troubleshoot and resolve it. But first, what are public links?

What are public links used for?

In Content Hub, we use public links to share assets with external partners who typically do not have direct permission to download the assets. This means anyone who has access to this static URL can cache and fetch the file.

Creation of Public Links

I will start with a scenario where my Content Hub user doesn’t have permission to create public links. My user belongs to my GlobalContentCreator user group. Within Content Hub, on the Asset Details page, when my user tries to access the Public links menu, they notice it is missing as shown below.

The Public links menu is missing because the required permissions have not been configured within GlobalContentCreator user group. Below is a snippet of the existing permissions for M.Asset and M.File

You notice the CreatePublicLinks and ReadPublicLinks permissions are missing. We need to enable them first, as shown below:

With this change in place, the Public links menu now appears on the Asset Details page for my user, as shown below.

Does this resolve the issue?

I will now let my user to put this to test.

As expected, when my user clicks on the Public links menu, it opens New pubic link popup window. They proceed to fill out the form and submitting it as shown below. However, they are still getting the error. What is going on?

M.PublicLink permissions are needed as well

Asset public links are entities of type M.PublicLink. In fact, M.Asset is Parent of M.PublicLink (using the AssetToPublicLink relationship)

Therefore, I need to assign additional permissions for M.PublicLink. I need to update my GlobalContentCreator user group with the following changes:

The minimum permissions needed are Read and Create to create the public links. However, I have additionally allowed my users to update and delete them as well.

This is it. With this change, the issue is resolved and my users can happily generate public links. Happy days.

Next steps

In this blog post, I have explored steps you need to take to troubleshoot and resolve the issue “the user does not have sufficient rights to create the specified entity” when generating public links.

Stay tuned and leave us any feedback or comments.

Creating and publishing a Content Hub custom connector – Visual Studio project set-up guide

Background

I recently shared a video playlist on how I built a Content Hub custom connector that allows you to publish video assets into your existing video streaming platforms

On this blog post, I wanted to share details on how to setup your Visual Studio project and solution as well us how to deploy or publish the connector to your Microsoft Azure cloud.

Create a function app project

Using latest Visual Studio IDE, create a new Azure Functions project, using C# template as shown below

Choose a meaningful name for your project and progress through the next step. Ensure you select Http triggered function as show below.

Finalise the create project wizard to get your project created.

Add Content Hub web SDK reference

As shown below, add a reference to Stylelabs.M.Sdk.WebClient NuGet Package to your project.

In addition, ensure you have added the Microsoft NuGet Packages below to enable dependency injection to your Func app.

Enabling FunctionStartup in your Func app

To enable dependency injection in your project, add a Startup class similar to the one shown below. The Startup class needs to inherit the FunctionStartup, which allows us to configure and register our interfaces.

Creating Function App on Microsoft Azure portal

As explained in the video playlist, you will need to publish your Func app into your Microsoft Azure subscription.

You will need to create a Function App app in your Microsoft Azure subscription using the create template as shown below. Ensure you select relevant Subscription, Resource Group and .NET Runtime stack.

Progress through the create wizard screens to stand up your Function app in the portal.

Getting publish profile from the Microsoft Azure portal

On your newly created Function app, navigate to the Deployment Center as shown below

Clicking on the the Manage publish profile link should present a pop up window, from which you can download the publish profile. Keep note on the location where you have downloaded this publish profile file.

Importing publish profile into your Visual Studio project

Right-click on your project within VS, which should pop-up the menu shown below.

Click on the Publish… menu to launch the Publish window similar to the one shown below.

Using the Import Profile option will allow you to browse and select the publish profile file that you previously downloaded from Microsoft Azure portal. This will then successfully setup the publish profile to your Microsoft Azure subscription.

Publishing the custom connector from VS into Microsoft Azure portal

On the Publish window, you will notice your publish profile is selected, similar to one below.

Clicking on Publish button will deploy the Function app to your Microsoft Azure subscription.

Next steps

In this blog post, we have explored at how to set-up a Function app in your local developer environment, add required NuGet Packages as well us publishing it to your Microsoft Azure subscription

Feel free to watch the rest of my YouTube playlist where I am demonstrating the end-to-end custom connector in action. Stay tuned.

Content Hub gems: Leveraging action scripts to aggregate CMP content and your linked assets – part 2

Introduction

We previously looked at how to leverage action scripts to simply how to access content and linked assets with a single web API call. In this blog post, we follow up with a deep dive into the code and logic within the action script itself.

The script

The first part of the script is shown below.

  1. Line 1 to 5 has all the required libraries being used in the script
  2. Line Line 7 & 8 has logic for extracting the id of the content item, which we are gathering the data in this script. Data from the web API request is specified in Context.Data, which is a JToken. The script expects it to be a JObject containing a contentId property.
  3. Line 10 to 14 contains logic for checking whether the content id could not be extracted from the data. In which case, a response http status-code 400 (bad request) together with a user-friendly error-message is returned. This is done with help of helper function SetError, as shown below:
  4. Line 16 to 19 contain the EntityLoadConfiguration we are going to use when loading the assets linked to our content item. Only Filename, Title and Description as well as AssetToSubtitleAsset relation will be loaded in our use case.
  5. Line 21 to 24 similarly contain the EntityLoadConfiguration we are going to use when loading the content item (our blog post content type). Blog_Title, Blog_Quote, Blog_Body as well as CmpContentToMasterLinkedAsset & CmpContentToLinkedAsset relations will be loaded here. CmpContentToMasterLinkedAsset relation holds the link to the master image associated with this item. CmpContentToLinkedAsset relation has the assets linked with this item, such as the video asset.
  6. Line 26 to 31 contain the logic for loading the content (Blog post), by leveraging MClient.Entities.GetAsync function and specifying the content id and the EntityLoadConfiguration already defined above. We have a check on line 27 whether the content entity was actually found, and return a response http status-code 400 (bad request) together with a user-friendly error-message, when none was found.
  7. Line 33 to 37 start preparing the output object for our script. We have created a new JObject which has the shown properties. We have added the values of properties Blog_Title and Blog_Quote and Blog_Body. We are going to add more properties as we walk through the rest of the script.

Second part of the script

The code listing from line 39 through to 83 has the logic for loading the video asset linked with this content item.

  1. Line 39 get the list of video asset ids by using a helper function GetLinkedVideos shown below. This function makes use of the LINQ query, which filters down only entities of type M.Asset which are linked to current content id (parent in the CmpContentToLinkedAsset relation). In my use case, I have used the file extension .mp4 to identify video asset (but you could use any other property or combination of properties to meet your specific use cases)
  2. Line 40 checks if our GetLinkedVideos found any video ids, in which case the rest of the logic will try and process them
  3. Line 42 extract the first video id that was found. I have used the MCient.Logger.Info method to log user friendly messages that helped me show which video ids were found. These message appear on the Action Script’s View Logs window.
  4. Line 45 to 46 contain the logic for loading the video asset entity, by leveraging MClient.Entities.GetAsync function and specifying the video asset id and the EntityLoadConfiguration already defined before in first part of the script. Line 46 checks to ensure the video asset was found, for us to do further processing
  5. Line 48 and 49 contains the logic for getting the video asset public link, which is required as part of the output from the script. On line 48, I am leveraging GetPublicLinks function, which I have defined as shown below. I am interested in the original rendition of my video asset. Please note that if the video asset does not have original public link generated, nothing will be retrieved.
  6. Which is why the code on line 49 further makes use of a function named GetFirstPublicLinkUrl which helps load the M.PublicLink entity and inspect the RelativeUrl property, as shown below.
  7. Line 50 to 55 we are now creating a new JObject which has the shown properties as expected the output of the script. This object is added to videoAsset section of our main result object.
  8. Line 57 contain logic for getting the video asset subtitles. The AssetToSubtitleAsset is a IParentToManyChildrenRelation, so we get hold of subtitles using the Children property from this relation. In essence, a video subtitle is an asset in its own right. So the code listing from Line 59 is trying to load each of the subtitle asset and we are interested in the Title property as well as the Public Link (original rendition). This is now familiar to how we got public link for the video asset itself. We add each of these properties in a JArray, which in turn, is added to the result.

Part three of the script

In the last part of the script, we also get the master asset linked to our content item. In this case, we are interested in the asset Public Link, asset file name, Blog_Title and Blog_Body properties. We create a new JObject which has the shown properties as expected and added to the result object.

Line 103 stores our result object that we have been preparing onto the Context. This tells the script to return it to the user.

Final script output

The script output is similar to the one shown below.

This completes the code listing for this script.

Next steps

In this blog post, I have looked at the second part of the Content Hub Action Scripts for Web API use cases. We have taken a deep dive into the source code for the script, covering the various components and how they work together. For a practical use cases, look at my blog post on how I have created a custom connector for publishing video assets from Content Hub into Cloudflare Stream

Stay tuned and leave us any feedback or comments.

Content Hub gems: Leveraging action scripts to aggregate CMP content and your linked assets – part 1

Use case and problem

Within Content Hub CMP, the content metadata can be stored in various places including the properties and related entities. For example, a Blog post content item can have multiple attachments, such as Imagery and Video assets linked from the DAM, as shown below.

Imagine you wanted to query all these metadata for your blog post, plus all the linked attachments. For the assets, you would like to also get video subtitles or even public links for them. Sounds complicated enough?

Well, this blog post will explore a Content Hub hidden gem to save your day. Please read on.

Web Scripts

Luckily for us, Content Hub supports creation of Action scripts that are designed to be executed using a Web API. This is a very powerful capability since we can leverage such a script to aggregate metadata from various Content Hub entities, whether this is stored within properties or relations. We can then execute this script using a single Web API, thereby avoiding unnecessary multiple trips to fetch such data.

How to create an Action Script

  1. To create a new script, navigate to Manage -> Scripts page
  2. Then click on +Script button
  3. This will pop-up a screen similar to this shown below. Enter Name, specify Action Script type and optionally enter Description. Click Save
  4. The Action script will be created and appears on the scripts list, similar to below:

How to add code/edit, build and publish your script

  1. Click on your script from the script list, which will open Script details page
  2. Click on the Edit button on top of the page to enable editor section, as shown below. Use the editor section to add the source code for your script
  3. Click on Build button to compile the source code for your script.
  4. Click on Publish button to publish the script and make code changes take effect.
  5. Finally, remember to Enable the script from the script list, to make it available for use

Executing your Action Script

To execute your Action script, simply send an HTTP POST request to the script endpoint, using a tool such as Postman or CURL. Below is a Postman sample. ch_base_url is your Content Hub instance base URL. SCRIPT_ID is the script identifier

In the sample request above, I have specified the request body with a parameter containing the CMP content identifier that I would like to aggregate all the metadata. I will cover more on the workings of this script in a follow up blog post.

Please note I presume you know how to specify the Authentication for the Web API calls to your Content Hub instance. This involves getting access tokens from your Content Hub instance.

Script output

If successful, you will get an output similar to the one below.

You can see within a single Web API call, we are able to get all the metadata related to a CMP Blog post content item:

  • M.Content properties for the Blog post such as Title, Quote and Description
  • M.Content relations such as CmpContentToMasterLinkedAsset and CmpContentToLinkedAsset
  • M.Asset properties such as Filename, Title and Description
  • M.Asset relations such as AssetToSubtitleAsset
  • Video asset subtitle properties such as Filename, Title and Description
  • M.Asset public links such as DownloadOriginal URLs

Next steps

In this blog post, I have introduced the first part on Content Hub Action Scripts for Web API use cases. We have walked through steps of creating a new script, editing and build the source code, publishing and enabling it for use. We have also looked at how to execute the Web script using a Postman tool.

In the second part, we will deep dive into the source code for the script that I used to produce the sample output above. Stay tuned and leave us any feedback or comments.

Unlocking the Potential: Tips and Tricks for Working with GraphQL Queries and Sitecore Experience Edge

Adapted from
adapted from www.wallarm.com

What is GraphQL

GraphQL is a kind of query language and server-side runtime technology used widely for application programming interfaces (APIs) that ensure that the client gets the required data. Nothing less or nothing more. Created by Facebook, GraphQL has a lot of aims and functions:

  • A powerful data-fetching API
  • API interface that’s easy to learn and work with
  • An open-source query language making APIs fast and flexible
  • An effective method to streamline security management for the API
  • A way to give developers and business analysts the ability to develop APIs with desirable methods
  • A query language that gets along with a given integrated development environment easily and effectively
  • The facility to develop APIs that will function the way the client/end-user wanted or expected

GraphQL Playground

The easiest way to compose GraphQL queries to query your Sitecore Experience Edge is to make use of the GraphQL playground. I am presuming that you already have your Sitecore Experience Edge instance
connected to your Sitecore Content Hub instance or Sitecore XM Cloud instance.
To refresh your memory, you can visit this blog post where I have detailed steps to help you with the set up

In this blog post, I will be working with my Sitecore Content Hub instance to share a few tips and tricks. You will find these tips and tricks applicable to Sitecore XM Cloud as well.

Preview and Delivery APIs

Before you can access the GraphQL playground, you need to decide whether you are going to be using the Preview API or the Delivery APIs.

  • Preview API: The Preview API is a GraphQL endpoint that exposes a preview of your content. Use the Preview API to access content that is not approved yet, including drafts. This can be useful when you want to test content in a staging environment before going to production. This is accessible using endpoint {ContentHubURL}/api/graphql/preview/v1 where ContentHubURL is your Sitecore Content Hub instance url.
  • Delivery API: The Delivery API is a GraphQL endpoint that exposes approved and published content. Use this API for all production-related actions. This is accessible using endpoint https://edge.sitecorecloud.io/api/graphql/v1

You will also need access to API Keys to use with your Preview or Delivery APIs. You can obtain your API keys as follows:

  • Navigate to Manage -> API Keys to launch the API Keys management screen
  • On the API Keys screen, you need to provide the required name and scope of the API Keys, then click the call to action to generate the Preview or Delivery API keys. Please keep a note of them as you get only once chance to view and copy them. I recommend storing these keys securely on your Key Vault or similar tool.

Launching GraphQL Playground

To launch the GraphQL playground, open your browser and specify the following URL:

  • Preview IDE: {ContentHubURL}/api/graphql/preview/ide This will launch the Preview API playground
  • Delivery IDE: https://edge.sitecorecloud.io/api/graphql/ide This will launch the Delivery API play ground

Below is a screenshot of Delivery API playground

  • A – This is the Delivery IDE URL
  • B – This is the Delivery API endpoint
  • C – This the GraphQL query section, where you will specify the queries. In my example, this the query to list all published assets, by using the predefined object allM_Asset
  • D – This is the output of the GraphQL query, showing the results as JSON object. Notice only the id and title are returned, as specified in my query. This is one of the main advantages of using GraphQL, you get nothing less or nothing more than what you specify.
  • HTTP Header – this is where we specify our API Key using the “X-GQL-Token” header. In this example, I have used the Delivery API key as I am querying my Delivery instance.

Troubleshooting tips and tricks

I am presuming you have so far been successful getting your GraphQL playground working. If you encounter any issues, try and troubleshoot as follows:

  • Do you have your Delivery Platform setup correctly? ?Check that your Sitecore Content Hub has a license for Delivery platform, and this has been enabled. One way of verifying this is by having Manage -> Delivery Platform icon on your dashboard, as shown below. If you are missing it, contact Sitecore Support to have it enabled.
  • Are you using correct Delivery API or Preview API Keys? Do not get the Delivery or Preview API keys mixed. To avoid any potential mix up, ensure you assign your API keys names to reflect Delivery or Preview scope when generating them. If you are not sure anymore, you can always discard and generate new ones (Please note in Production environments, deleting and generating new API keys may affect production services, plan this carefully
  • Are you accessing the correct GraphQL Playground? Similarly to above, ensure your browser is pointing to Delivery IDE or Preview IDE accordingly. For example, if you haven’t published all your Assets, you may get discrepancy in the assets output within Delivery IDE and Preview IDE. Please note Preview IDE will show content that is not approved yet, including drafts.
  • Have you checked Browser Developer Tools? Your browser “Network” section captures detailed logs on requests and responses. An example screenshot below will help verify the response coming back from GraphQL server:

GraphQL tips and tricks

Using filters with your query

Suppose you want to control how many items to query, then you will need to filter the query results. Below is an example, where we are getting a single asset with id value of "some_asset_id"

Using parameters with query filters

Suppose you want to use a parameter with your filter the query. A use case is to be able to dynamically filter the list of assets based on some condition. Below is an example, where we are using a parameter for the id value of "some_asset_id"

  • A – We make use of the Query Variables section to define parameters. In this case it is named "assetId"
  • B – We define the parameter using the arguments to the query as shown here. ID is the strong scalar type for the Asset Identifier field

Next steps

This completes this blog, where I have walked you through GraphQL and Sitecore Experience Edge. I hope you find this useful, and feel free to leave me any comments or thoughts. See you soon in my next blog post.

How to bulk import Video Subtitles into Sitecore Content Hub

I recently was working on a cool project that required migration of hundreds of videos from a legacy video platform to Sitecore Content Hub as part of a digital modernization strategy. These video assets happened to have subtitles for multiple languages, which presented a significant challenge in itself.

If you are familiar with Sitecore Content Hub DAM, we have a capability to do a bulk import of DAM assets using the Excel import feature. There is also a fair number of blogs with guidance on how to go about this process. However, if you are looking for a quick guide on performing bulk import of video subtitles, there seems to be lack of documentation or step by step guidance.

I thought I document this process to fill this gap and share my story of overcoming this challenge.

First things first – recap on importing video subtitles via Portal page

I am assuming you already have a video asset imported into your Sitecore CH instance.

After selecting your video asset, the asset details page will look like this one below.

Clicking Upload files button will prompt with a dialog box shown below:

  • Click My device, navigate to the location of the files, select them, and then click Open. Optionally, to add more files, click + Add more; otherwise click Upload files.
  • Click From link, paste links to the files you want to upload, and then click Import.

Please note as of this writing, Sitecore CH supports only SRT and SUB subtitle formats.

After successful upload of the subtitle files, your Video subtitles section will look like this below.

At this stage, we haven’t specified the localised language for the subtitle file. To do this, click the file name or click Edit language and, in the Edit language dialog box, select the language from the drop-down list and then click Save.

Congratulations! You can now have the closed caption option (CC) show in the media player, which lets you select the uploaded subtitles to play along with your video.

Where are my subtitle files stored?

As you may have guessed it right, the subtitle files uploaded are actually M.Asset entities which as stored within the M.Content.Repository.Subtitle Content repository. You can view these files using your All-assets portal page, and filter the Subtitle Content repository.

How are the subtitle files linked to the video asset?

To view the subtitle and video asset relationship, head on to the Schema section by navigating to Manage -> Schema -> M.Asset

On the M.Asset schema page, search for subtitle. This will filter the schema for subtitles as show below.

This means that:

  • the video asset is the Parent of the Subtitle asset (AssetToSubtitleAsset:Parent)
  • the subtitle asset is the Child of Video asset (AssetToSubtitleAsset:Child)
  • the subtitle language is an OptionList

So, how do I bulk import Video Subtitles?

Now that we know subtitle are M.Asset entities, we will leverage the Excel Import template to achieve the bulk import.

When importing an Excel file, ensure that the name of each worksheet matches the name of the corresponding definition. For example, to import assets, a worksheet must be called M.Asset

You can hand-craft the Excel file if you already know the fields needed for your import. This guidance here also has preparation steps that you can undertake.

A safer option is to Export the sample video asset plus the subtitles, so you can figure out how the template should look like.

This will require creating an Export profile with minimal number of fields required for the bulk import. If you follow the steps on how to create an M.Asset export profile, you should end up with one similar to one below.

Manage -> Export Profiles -> Create new export profile

{
  "properties": [
    "File",
    "Title",
    "FileName",
    "SubtitleLanguage"
  ],
  "relations": {
    "AssetToSubtitleAsset": {
      "exportRelatedEntities": true
    }
  },
  "includeSystemProperties": true,
  "publicLinks": {
    "asset": false,
    "masterfile": false
  },
  "version": "1.1"
}

Pay attention to the Relations section, where we are enabling the export of the AssetToSubtitleAsset related entities. Also, ensure includeSystemProperties is enabled.

Export your sample video asset into Excel

  • Navigate to your Assets portal page.
  • Search and locate your video asset.
  • Select the video asset (tick the checkbox of your selection component)
  • On the right-hand side, access the Actions dropdown menu, and click on “Export to Excel”
  • Your download should be ready and accessible from Profile -> Downloads link

M.Asset Video Subtitles Import template

Your M.Asset video subtitles import template will look similar to this one below.

You can view and download sample Excel file too.

As you can see:

  • Row 1 – this has the M.Asset entity properties in your Sitecore CH instance
  • Row 2 and 3 – these have the entries for the two subtitles that we configured.
  • Row 4 – this is the entry for the video asset.
  • Pay special attention to the AssetToSubtitleAsset:Parent which is how the subtitles are linked to the parent video asset using identifier  id123456789 in this example
  • Pay special attention to the AssetToSubtitleAsset:Child which is how the video asset is linked to all subtitles. This will have pipe delimited list of subtitles identifiers (e.g., id123456789-viralvideo-ar-AE|id123456789-viralvideo-fr-FR)
  • Please note, you need to pre-generate unique values for the identifier column for your subtitles, in order to be link them with parent video as shown above. This will be key to successful bulk import of the subtiltes.
  • Use the File column for the URL to the actual video asset and subtitle assets.  

And finally, the bulk import from Excel

To bulk import, use the Asset Creation page.

  1. On the menu bar, click Create.
  2. On the Create page, in the top-right corner, click Add and then select Import Excel.
  3. Do one of the following:
    • Drag the Excel file you want to upload into the dialog box.
    • Click browse, then pick the Excel file you want to upload.
  4. Optionally, click Add more to add more files if needed.
  5. Click Upload files.

Next steps

On this blog post, we have look at how to bulk import video subtitles to your Sitecore Content Hub instance. I am keen to hear your feedback or comments. Please do use the comments section for that.

I have also blogged on How to bulk import CMP content items with multiple languages. Please check it out too.

Stay tuned for future posts as well look and feel free to look around at my existing posts on Sitecore platform.

Sitecore personalize and mobile app projects series – part 2b

Introduction

On this series of blog posts, I am documenting my journey of delivering personalized content to end users of a mobile app.

Enabling Experience Edge for Sitecore XM

In this blog, I will cover integration between Sitecore Experience Edge and your Sitecore XM instance. Below is a reminder of our architecture.

Recap on Experience Edge for Experience Manager (XM)

Sitecore Experience Edge for Experience Manager (XM) is an API-based service from Sitecore that gives you globally replicated, scalable access to your Sitecore Experience Platform items, layout, and media.

Sitecore XM + Experience Edge architecture, adapted from Sitecore docs

Experience Edge for XM acts as a publishing target for your Sitecore content and media, and provides a GraphQL API that lets you deliver “Headless content”, which will be consumed by the Mobile app.

Getting Started with Sitecore XM Cloud

You can request for a demo from Sitecore, by filling and submitting this form available on Sitecore website. Sitecore Support team will then get back to you with details on how to access your Sitecore XM cloud instance.

Alternatively, you can request for an XM + Edge Demo from the Sitecore Demo Portal page. This is the Portal where you can also request the Sitecore Play! Summit and Sitecore Play! Shop demos. The XM + Edge Demo will come configured with an Experience Edge, ready to go.

Below are the steps to use:

Step-by-step guide to obtain XM + Edge Demo

  1. Logon to https://portal.sitecoredemo.com/. On the home page, click on “Quick Deploy”. This is the quickest way to get your demo instance based on Demo Team’s default configurations.
  2. This will open a modal, from which the user can:
    • select a demo template
    • select an instance name based on the guidelines described above, in the “Choosing an instance name” section
    • select a demo channel with preferred demo version
    • select a region to which the instance will be deployed to
  3. Instance names are valid under the following conditions:
    • The name must not already be used by another instance
    • The name must be at least 3 characters long
    • The name must contain only alphabetical characters or a hyphen
    • The name must start with a character (not a number or hyphen)
  4. In case the name is not valid, or the name is taken, an error message will appear after the name has been validated by the Demo Portal API
  5. Click on Deploy Now button to submit the information captured above
  6. The Demo provisioning process may take a couple of minutes. Grab a cup of tea or coffee while this runs. Finally, you will receive an email notification from get[at]sitecoredemo.com, similar to one below.
  7. You can follow the links in the email to access your instance. Alternatively, log on to https://portal.sitecoredemo.com/ and you will see the link on your dashboard

Accessing your Sitecore XM instance and Experience Edge instance

Opening your XM+ Edge Demo instance, you will get a landing page like one below

To access you XM instance, follow the URL in the section named Important Links This will open your Sitecore XM login page, and which you can access using the provided credentials To access your Experience Edge tenant, use the URL provided in the Edge Tenant section, plus the API key. You can see details on What is GraphQL in the other blog post in this series

Next steps

This completes this blog, where I have walked you through getting your Sitecore XM and Sitecore Experience Edge integration working. I hope you find this useful, and feel free to leave me any comments or thoughts.

In my next blog, I will be looking at integration between Sitecore Experience Edge and Sitecore Personalize.

Sitecore Zero-downtime deployments – Part 2

Sitecore Container based CI/CD Flow

With modern and mature DevOps, we all want smooth, sleek and painless automated deployments with zero-downtime. Sitecore deployments are no exception. Have you embraced zero-downtime deployments? This is not a new topic. If you look around Sitecore community, you see an odd question popping here and there regarding this topic.

The journey towards achieving zero-downtime deployments for any application in fact starts with your code base. So, in this series of blog posts, we will refresh ourselves on concepts like “Code Freeze” and the CI/CD process before deep diving into implementing Sitecore zero-downtime deployments.

Sitecore container based CI/CD flow

Sitecore Deployment options

Sitecore can be deployed to the cloud using IaaS, PaaS or Containers.  Microsoft Azure cloud  is preferred, although you can deploy to other providers like AWS

  • IaaS makes use of Virtual Machines
  • PaaS makes use of Azure App Service to run Sitecore web apps
  • Containers makes use of Azure Kubernetes Service (AKS)

How working with containers is different

When working outside of containers, you would typically build your application and then push it directly to the IaaS or PaaS instances hosting them. Using Containers changes this process slightly. The infographic below captures this process in detail

Sitecore containers CI/CD process summary

Explanation of the CI/CD process

  1. So developers make changes to the codebase.
  2. They then commit their changes into the repository, in this case stored in GitHub
  3. An Azure DevOps Pipeline monitors this repository and triggers a new image build each time there is a commit into the repo
  4. These images are built by Azure DevOps and the new image version is pushed into an Azure Container Registry (ACR) instance
  5. We have Other triggers for a base images that might have changed. For example, an update to the base Windows image or Sitecore image that can also trigger a new image build to occur. This is where the CI part of the process ends. We now have our new images built and available for deployment.
  6. So this is where the CD element starts. A release element is going to execute to start the deployment process.
  7. The first thing the CD element does is to push the new version of the k8s Specs into AKS, including pinning the deployments to the unique tag of the new images.
  8. AKS will now connect to the ACR instance to pull down these new images and build new deployments based on them.
  9. Of course any Sitecore deployment isn’t complete without a push of the content changes. Once the specs have been deployed the content is then also pushed to the CM instance running in AKS and a publish is executed.
  10. Once this has happened your end users can now browse the site and interact with the new containers running in AKS.

Hopefully, these blog post help you understand how to manage Sitecore Container based CI/CD process going forward. If you still struggling, engage your digital partners to look for long term solutions.

Next steps

In the next blog post in this series, we will look at BLUE-GREEN deployments and how to leverage this strategy to implement Sitecore Zero Downtime deployments.

Sitecore Zero-downtime deployments – Part 1

Why Zero-downtime deployments?

With modern and mature DevOps, we all want smooth, sleek and painless automated deployments with zero-downtime. Sitecore deployments are no exception. Have you embraced zero-downtime deployments? This is not a new topic. If you look around Sitecore community, you see an odd question popping here and there regarding this topic.

The journey towards achieving zero-downtime deployments for any application in fact starts with your code base. So, in this series of blog posts, we will refresh ourselves on concepts like “Code Freeze” and the CI/CD process before deep diving into implementing Sitecore zero-downtime deployments.

Code freeze? “Thing of the past”

A Code freeze is an adopted milestone from the Waterfall days.

“No changes whatsoever are permitted to a portion or the entirety of the program’s source code. Particularly in large software systems, any change to the source code may have unintended consequences, potentially introducing new bugs”

Wikipedia

Typical Code Freeze Challenges:

  • Complex Sitecore solution with several dependencies
  • Very large code bases possibly with legacy code
  • Multiple teams from multiple geographies
  • Complex and painful code merges
  • Dedicated QA testing window
  • Multiple languages and frameworks

All these challenges may mean you introduce some “code freeze” when preparing for your deployments. Naturally, this is not where you want to be. If not managed properly, this becomes a blocker, a barrier from a true CI/CD process and your journey to your Sitecore zero down time deployments. Let’s refresh ourselves on some tips to help address some of the issues.

Solving Code Freeze Challenges:

  • Adopt a code branching strategy
  • Adopt “clean code” principles
  • Adopt microservices architecture
  • Embrace modern CI/CD processes
  • Embrace containers

Git Branching Strategy

Git Branching Strategy
  • use of feature branches off the main branch – this will isolate work in progress from completed work, avoiding “code freezes” sessions when preparing for a release. Always use Pull Requests to merge feature branch into main branch. Make use of descriptive naming of your branches as best practice
  • use of release branches off main branch when close to your release, at end of your sprint or cycle. Make use of bugfix branches for any bugs fixes in your release and merge them back to release branch
  • There are other branching options available, such as the Release flow branching strategy

Embracing Microservices

Diagram of a CI/CD monolith
CI/CD monolith v Microservices – courtesy of Microsoft Docs

Let us now look how Microservices make life easier.  A traditional monolithic app on the left, there is a single build pipeline whose output is the application executable. All development work feeds into this pipeline. If team B break, the whole thing breaks. In contrast with microservices philosophy on the right, there should never be a long release train where every team has to get in line. The team that builds service “A” can release an update at any time, without waiting for changes in service “B” to be merged, tested, and deployed.

Next steps

Hopefully, these tips help you address “Code Freeze” problem going forward. If you still struggling, engage your digital partners to look for long term solutions.

In the next blog post in this series, we will look at Sitecore CI/CD processes to support Sitecore Zero Downtime deployments.