Advanced license required
Features described on this page require the Xperience by Kentico Advanced license tier.
Content synchronization allows users to easily transfer content from one instance of Xperience by Kentico to another.
The purpose of content sync is to help manage content when using multiple environments. For example, a project's developers may have a local Development instance, from which initial content is sent to a hosted Staging instance. The staging instance is accessible only by editors and other staff, who use it to prepare content updates. The final content is then synchronized during regular releases to a public-facing Production instance.
This page describes how to set up and configure your applications to use content sync:
To learn how to synchronize content, see Content sync.
Before you start setting up content sync, it is important to understand which environment topologies are supported.
The most basic usage of content sync consists of a connection between one source instance and one target instance. Such connections can be chained to additional instances – a target can be configured as the source for another instance. However, only strictly linear topologies are supported. For example:
More complex topologies, for example with multiple branching target connections, loops, or bi-directional connections are not supported. The system does not strictly block content sync with unsupported topologies, but it may result in inconsistencies, errors or unintentionally overwritten content.
To set up an application as the source or target in a content sync connection, configure ContentSynchronizationOptions using the .NET options pattern (opens in a new tab) (available in the CMS.ContentSynchronization namespace).
The options are separated into Source and Target configuration. The following properties must be configured:
Enabled – a bool value that enables the application as a source or target for content sync.Secret – a secret key containing at least 32 characters. The same secret must be configured for the source and target applications.TargetUrl – only available for the Source configuration. Specify the URL where the target application is running. Must be absolute, with the HTTPS scheme, without query or fragment components.Use environment-specific configuration (opens in a new tab) or IHostEnvironment extension methods (opens in a new tab) to set the correct values for each application in your environment. To learn how to identify environments for SaaS projects, see Environment identification extension methods or Application settings for different SaaS deployment environments.
using Microsoft.Extensions.Hosting;
...
WebApplicationBuilder builder = WebApplication.CreateBuilder(args);
...
// Configures the development environment as the content sync source
if (builder.Environment.IsDevelopment())
{
builder.Services.Configure<ContentSynchronizationOptions>(options =>
{
options.Source.Enabled = true;
// Secret key that is at least 32 characters
// Must be the same for source and target application.
options.Source.Secret = "<YourSecretKey>";
options.Source.TargetUrl = "https://productiondomain.com";
});
}
// Configures the production environment as the content sync target
if (builder.Environment.IsProduction())
{
builder.Services.Configure<ContentSynchronizationOptions>(options =>
{
options.Target.Enabled = true;
options.Target.Secret = "<YourSecretKey>";
});
}For SaaS projects, you do not need to configure content sync manually (except for local development environments).
SaaS deployment environments have their content sync configuration done automatically based on Content synchronization connections defined in Xperience Portal.
Xperience 30.5.0 or newer required
Content synchronization and Staging environments are only available if the deployed Xperience project uses version 30.5.0 or newer.
You can use the content sync feature to transfer content from all types of environments, including non-production ones (local development, QA, UAT). This is a viable approach during development and for small projects. However, non-production environments do not provide sufficient performance, availability, and backup policies for projects with larger content editing teams.
To set up a stable and robust environment for long-term editing and staging of content, add the optional Staging (STG) deployment environment to your service plan.
The Staging environment provides a platform where editors and other staff can prepare content, and then transfer it to the production environment using content sync. Staging environments are designed to be nearly identical to production environments in most aspects, such as performance, availability, backup policies, and the option to set custom domains.
Use the following process to initialize a Staging deployment environment for an existing project:
cms.user object type in the package and use the CreateUpdate restore mode (Create is not sufficient).To use content sync for SaaS projects, you need to create synchronization connections between environments in Xperience Portal:
Limitations
The limitations described in Supported topologies apply for content sync between SaaS environments. Only linear connection chains are supported, without multiple branching target connections, loops, or bi-directional connections.
The connected environments must be running exactly the same version of Xperience by Kentico.
Connections from SaaS environments to external private cloud instances are not supported. The only instance outside of SaaS environments that can participate in a content sync connection is a LOCAL development environment used as a source.
After you create connections, select the Apply changes button in the information ribbon at the top of the interface. Applying these changes triggers a restart of the affected applications. You may need to manually refresh the current page for the Apply changes button to appear in the information ribbon.
Once the connection becomes Active, content sync is configured for the given environments and users can start transferring content.
You can delete connections and apply the changes if you wish to disable content synchronization between the given environments.
When you create a content sync connection with a LOCAL environment as the source, Xperience Portal displays Target URL and Connection secret values. Copy the values and use them in the content sync configuration of the application in your local development environment:
ContentSynchronizationOptions.Source.TargetURLContentSynchronizationOptions.Source.SecretThe Connection secret value is not stored and cannot be displayed again in the future. If you lose the secret, you need to delete the connection and create a new one.
You need to ensure that the source configuration only applies to the local development environment. To learn how to identify environments for SaaS deployment environments, see Environment identification extension methods or Application settings for different SaaS deployment environments.
To prepare your Xperience instances for content sync, configure the following features:
The following objects are required by content items and/or pages, but are not included in content synchronization:
You need to ensure that all instances connected through content sync have exactly the same set of these objects. For example, an error will occur if you try to synchronize a content item for which an exactly matching content type or member role is not available on the target.
The compatibility of objects is calculated based on their GUID identifiers and all available data. It is not sufficient to manually recreate objects with the same code name (with the exception of languages, which are only validated by their code name). When you update or add any of the required objects on the source server, you need to transfer them to the next environments using other deployment methods, i.e., SaaS deployment via a deployment package or Continuous Deployment.
Project code compatibility requirements
To enable synchronization of website channel pages and forms, you also need to deploy via SaaS deployment package or Continuous Deployment to transfer all code components related to pages and forms.
This includes page views, controllers, routing configuration, Page Builder components, Form Builder components and sections, etc.
Synchronization of linked content items, pages, and forms relies on the system's usage tracking features:
The limitations described for usage tracking also apply to content sync. Content items, pages or forms that are "linked" in an untracked manner are not automatically synchronized together with the linking item or page.
By default, all tracked linked content is included in the synchronization automatically. Users can open Detailed selection in the synchronization dialog to review selectable dependencies and exclude specific linked items before starting the synchronization. The usage tracking limitations described above still apply – detailed selection only shows dependencies that were detected through tracked references.
If your Xperience by Kentico instance was updated from an older version, you need to manually run the following scheduled tasks to track the missing content item or form usages:
When designing the content model of a project that uses content sync, distinguish between two types of data:
Content sync always transfers the complete latest published version of each content item or page. Individual fields cannot be excluded from the synchronization.
Do not mix source-owned and operational fields in a single content type
If a content type contains both source-owned and operational fields, every synchronization of the given items overwrites the operational values on the target instance with the values from the source instance.
For example, consider an Event content type with a Description field edited by content editors and a RegistrationCounter field updated automatically on the production instance. When an editor updates the description on the staging instance and synchronizes the event content item, the current registration counter value on production is replaced by the empty or outdated value stored on staging.
To prevent overwrites, model source-owned and operational data as separate objects:
The content types and object types that hold your operational data must exist on all instances connected using content sync, even if their items are only created on the target instance. Content types and object types are part of the project's code and data, and must be transferred using SaaS deployment packages or Continuous Deployment.
Make sure that editors do not create or edit operational items on the source instance – you can restrict access using permissions and workspaces.
When a target application receives content through content sync, the updates are not immediately applied. Every synchronization is represented and stored in the following way:
~/assets/synchronizations folderCMS_Synchronization database table)The synchronizations are applied automatically by the Content sync restoration scheduled task, which runs every 30 seconds. During the restoration, content is created or updated using the Xperience API:
You can monitor synchronizations that recently occurred or are scheduled to take place in the Content synchronization application.
Synchronization cleanup
The Content sync clean data scheduled task automatically cleans up synchronizations once per day. During the cleanup, synchronizations with the Failed or Completed status are removed. In rare cases, a synchronization may get stuck in one of the other transitional statuses that occur during restoration. Such tasks are cleaned up if they are older than 24 hours.
If you encounter any issues or errors when using content sync, you can use the system's logging functionality to analyze the content sync process. Content sync provides structured logging data during all steps of the process, including content preparation and transfer on the source instance and content restoration on the target instance.
To view the full content sync logs, your preferred logging provider must be configured in the following way:
Debug or higherCMS.ContentSynchronizationCMS.WebsitesCMS.ContentEngineCMS)The logs should help you identify the source of your issue, and can be helpful when describing the problem to Kentico support (opens in a new tab).
Troubleshooting without the administration
If your target production server is deployed without the administration, the built-in Event log is not available for troubleshooting content restoration. To work around this, you can add a custom logging provider to your application and view troubleshooting data externally (e.g., using Serilog, NLog, or Aspire dashboard).
If your logging provider supports distributed tracing (opens in a new tab), you can enable collection of content sync activities by adding the Kentico.Xperience.ContentSynchronization source to your tracing configuration. For example:
using Microsoft.Extensions.Logging;
using OpenTelemetry.Logs;
using OpenTelemetry.Trace;
// ...
var builder = WebApplication.CreateBuilder(args);
// ...
builder.Services.AddLogging(logging =>
{
logging.AddOpenTelemetry(options =>
{
// ...
});
});
// Configures OpenTelemetry tracing
builder.Services.AddOpenTelemetry()
.WithTracing(t => t
// Adds the source for content sync activities
.AddSource("Kentico.Xperience.ContentSynchronization")
.AddAspNetCoreInstrumentation()
.AddOtlpExporter());