HomeGuidesAPI ReferenceGraphQL
Submit Documentation FeedbackJoin Developer CommunityOptimizely GitHubOptimizely NuGetLog In

Creating and deploying a Content Cloud (CMS) site

This topic describes a deployment onboarding scenario where you create a new website based on the Optimizely Alloy sample site, and deploy the application, database and content to the Integration environment in Optimizely Digital Experience Platform (DXP).

📘

When is this applicable?

This is an onboarding scenario for a first-time/onboarding deployment of a new site based on the Optimizely sample templates, to use from start for development in a cloud environment. A new site like this does not require database restore, and the database schema is created during initial deployment.

Before you start

This example uses deployment API to publish code.

  • See DXP requirements for recommended versions of software, tools and services to use when deploying.
  • See Getting started with DXP for deployment information.
  • See Installing Optimizely for how to add the Optimizely NuGet feed to Visual Studio.
  • Before deploying, add a wildcard binding to the site in the Manage Websites screen. This will help prevent failures due to URL-dependent code when migrating the database between environments. The following image shows an example of wildcard binding.
    1. Go to Admin > Config > Manage Websites.
    2. Click Add and add a wildcard (*) Host Name.
741741

Deployment steps

The following steps create a new website, add Azure and Search & Navigation (formerly called Find), and deploy the code and database with content to the Integration environment in DXP. The deployment uses the publishing profiles provided by Optimizely with your DXP setup.

📘

Note

Optimizely has a bootstrap feature for deploying content. If there is an export package located in [SolutionDir]\App_Data\DefaultSiteContent.episerverdata, the bootstrap feature imports that package during initialization and creates a site with content. The bootstrap is applied only if the site in the web app does not have any existing content.

STEP 1. Create new Optimizely project

Follow the steps in Creating a starter project.

dotnet new epi-cms-empty
  1. Go to Tools > NuGet Package Manager > Manage NuGet Packages for Solution to update the website to the latest Optimizely NuGet packages.
  2. In the NuGet Package manager:
    1. Select Updates.
    2. Select Optimizely Packages in the Package source field to locate the latest updates.
    3. Enable Select all packages.
    4. Click Update and confirm the updates.
12641264
  1. Add cloud platform to the website. In the NuGet package manager:

    1. Select Browse.
    2. Enter Optimizely Azure in the search field.
    3. Select the EPiServer.CloudPlatform.Cms package.
    4. Select your project.
    5. Click Install and confirm the installation.
642642
  1. To configure the EPiServer.CloudPlatform.Cms package, add this code in ConfigureServices method in startup.cs file.
public class Startup
{
    public void ConfigureServices(IServiceCollection services, IConfiguration configuration)
    {
        ...
        services.AddCmsCloudPlatformSupport(configuration);
    }
}​

📘

Note

If you only want to add the EPiServer.CloudPlatform.Cms package to specific environments, you can run something similar to the following code to check the environment.

public void ConfigureServices(
    IServiceCollection services,
    IConfiguration configuration,
    IWebHostEnvironment env)
{
    ...
    if (env.IsDevelopment())
    {
        services.AddCmsCloudPlatformSupport(configuration);
    }
}
  1. Run the solution.

STEP 2. Publish website to create code package

📘

Note

You can replace steps 1 through 4 with the following command in PowerShell. This creates a publish folder in  the \bin\release folder that could be zipped up and renamed to ProjectName.cms.app.00001.nupkg. See dotnet publish command - .NET CLI.

dotnet publish -c Release
  1. In Solution Explorer, right-click the project in Visual Studio and select Publish.
  2. In the Pick a publish target dialog box, select New Folder.
845845
  1. Click Next.
  2. Choose location or keep default.
12661266
  1. Click Finish.
  2. Zip the contents of the publish directory and rename to ProjectName.cms.app.00001.nukpg.

STEP 3. Deploy package

Get API credentials. See Deployment API authentication.

📘

Note

If not already installed, install the Epicloudand Azure.Storage modules, then import the modules to your session. In PowerShell, run these commands.

Install-Module -Name EpiCloud
Install-Module -Name Azure.Storage -Scope CurrentUser -Repository PSGallery -Force -AllowClobber
Import-Module Azure.Storage
Import-Module EpiCloud

The following sample to deploy the code uses PowerShell. Any deployment API method will work as long as you are deploying a package.

# Connect EpiCloud using credentials from portal
Connect-EpiCloud -ProjectId "projectId" -ClientKey "key" -ClientSecret "secret"


# Upload .NET Core Alloy to blob storage
$sasUrl = Get-EpiDeploymentPackageLocation
Add-EpiDeploymentPackage -SasUrl $sasUrl -Path .\AlloyNetCore.cms.app.0.1.0.nupkg


# Deploy package to environment. This will first build a docker image out of the package and then deploy it to the target environment.
Start-EpiDeployment -DeploymentPackage "AlloyNetCore.cms.app.0.1.0.nupkg" -TargetEnvironment "Integration" -DirectDeploy -Wait

STEP 4. Verify the website

  1. Go to the default access URLs for the environment, for example http://[projectNNNNinte].dxcloud.episerver.net.
  2. Log in as administrator to the website.
  3. Verify that the website is working.

STEP 5. Add Search & Navigation

An index is automatically set up and configured as part of DXP. In this step, you add Optimizely Search & Navigation (formerly Find) as default search for your solution, and publish the changes to Integration.

  1. In the NuGet package manager for your project, locate the EPiServer.Find.Cms package and click Install.
984984
  1. In Visual Studio's Solution Explorer, right-click the project and select Publish.

🚧

Caution

In the Edit > Publish > Settings screen, ensure that Update database is not selected (deselect if needed).

  1. Click Publish.
  2. Verify that the website is working.

Related topics


Did this page help you?