HomeGuidesAPI ReferenceGraphQL
Submit Documentation FeedbackJoin Developer CommunityLog In

Creating and deploying a Commerce cloud site

This topic describes a simple onboarding deployment scenario to create a new Commerce website and deploy the application, database, and content to the Integration environment in Optimizely DXP.

📘

When is this applicable?

This is an onboarding scenario for a first-time deployment when you want to set up a site and run development in a cloud environment from the beginning. Through Visual Studio you can deploy an empty database. A new site like this does not require database restore, and the database schema will be created during initial deployment.

Before you start

This topic uses Visual Studio with the Optimizely extensions and publish profiles. However, you can also use other deployment methods.

Deployment steps

This section describes how to create a new website with CMS, Commerce and Azure, and deploy the code and database with content to the Integration environment in DXP. The deployment is done from deployment API, using the publishing profiles provided with your DXP setup.

🚧

Important

A Commerce solution consists of two databases: one for CMS and one for Commerce. So, you need to repeat some deployment steps for each site.

STEP 1. Create new Optimizely project

Follow the steps in Creating a starter project.

dotnet new epi-commerce-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.
  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.Commerce package.
    4. Select your project.
    5. Click Install and confirm the installation.
  1. To configure the EPiServer.CloudPlatform.Cms package, you need to 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);
        services.AddCommerceCloudPlatformSupport(configuration)
    }
}
  1. Run the solution.

STEP 2. Publish website to create code package

  1. In Visual Studio's Solution Explorer, right-click the project and select Publish.
  2. In the Pick a publish target dialog box, select New Folder.
  1. Click Next.
  2. Choose location or keep default.
  1. Click Finish.

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.

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 (formerly Find)

An index is automatically set up and configured as part of DXP. In this step, you add Optimizely Search & Navigation 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.
  1. In Solution Explorer, right-click the project in Visual Studio 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.

See also: Deploying code changes


Did this page help you?