Deploy the Commerce Engine

When you deploy the Commerce Engine, you perform the following tasks:

Compile the Commerce Engine

To compile the Commerce Engine:

  1. Install the Sitecore Commerce SDK by unzipping the Sitecore.Commerce.SDK.1.x.xxxx.zip file, located at the root of the Sitecore Commerce release package.
  2. Open a command prompt and run the restore command from the SDK root folder:
    dotnet restore
    Note: By default, the dotnet.exe is installed under c:\Program Files\dotnet if the path has not been added automatically.
  3. Run the publish command to create a build of the Sitecore Commerce Engine in a local folder. For example:
    dotnet publish .\Sitecore.Commerce.Engine -o c:\Deploy\Sitecore.Commerce
    Note: Make sure that the installed version of the .NET Framework is the DevPack/SDK edition, not the Runtime edition. The dotnet publish command will fail if only the Runtime edition is installed.

Create the Commerce Server databases

To create the SitecoreCommerce_Global and SitecoreCommerce_SharedEnvironments databases:
  1. Open SQL Server Management Studio.
  2. Run the CommerceServicesDbScript.sql script (located in the Sitecore SDK directory).

Install the Commerce Engine service

To install the Commerce Server Engine service:

  1. Open IIS Manager.
  2. Create a new Application Pool called CommerceAuthoring and set the following:
    • Select No Managed Code for the .NET CLR Version of the App Pool.
    • Select Integrated for Managed pipeline mode.
    • Set the Identity to use the same CSFndRuntimeUser that you used for Commerce Server as the identity.
  3. Create a new IIS Site called CommerceAuthoring:
    • Keep the default binding settings with the exception of the port, which is set to 5000.
    • Set the Application Pool to the application pool you created in step 2.
    • Create a new folder in C:\inetpub called CommerceAuthoring and set the Physical Path to this new folder.
  4. Copy the contents of the c:\Deploy\Sitecore.Commerce folder (created when you compiled the Commerce Server Engine) to the new physical directory you created in step 3.
  5. Verify that you can retrieve metadata from the Commerce Engine service via the following URL: http://localhost:5000/api/$metadata.

Configure web payment functionality for the site

Create a Braintree sandbox account to incorporate web payment functionality into your storefront site.

To create a Braintree sandbox account:

  1. Go to https://www.braintreepayments.com/sandbox.
  2. Enter the required information in the Sign up for the sandbox pane, and click Try the sandbox.
  3. Follow the instructions to activate and log in to your Braintree sandbox account.
  4. Get the MerchantID, Public Key and Private Key information from the Braintree sandbox website.
  5. Use the information from step 4 to fill in the corresponding section inside the PlugIn.Habitat.CommerceAuthoring-1.0.0.json file under the wwwroot\data\Environments folder (in the IIS site folder you created when you installed the Commerce Engine service).
    • Search for "$type": "Plugin.Sample.Payments.Braintree.BraintreeClientPolicy, Plugin.Sample.Payments.Braintree" inside the PlugIn.Habitat.CommerceAuthoring-1.0.0.json file
    • Make sure the key values are contained by quotation marks. For example:
      "MerchantId": "hmkcvh546n4h4875",
      "PublicKey": "6mr6yhpxfdm9dw23",
      "PrivateKey": "e94bbef4a521c344f47e2a8c26f7e89d",

Bootstrap and initialize the Commerce Server environment

The Bootstrap process loads the environments from the data/environments directory in the physical location of the IIS service to the Commerce Engine service.

The Habitat catalogs and inventory (located under wwwroot\data\Catalogs) are imported during the bootstrap process. You can verify that all catalogs and inventory are imported through the Catalog Manager. If they are not present, you must import them manually.

Make sure that the application pool identity for the Commerce Authoring site ((.\CSFndRuntimeUser)) has the proper permissions for the Catalog web service in the Windows Authorization Manager.

Note: Before you perform the following steps, review the Default Commerce Engine service settings section. If you have not configured the environment .json files correctly, the process may may fail.
  1. Open a browser and run http://localhost:5000/commerceops/Bootstrap(). The URL is case-sensitive.

    When the Bootstrap process finishes, you can view new rows inside the "CommerceEntities" and "CommerceLists" tables of the SitecoreCommerce_Global database.

    If the Bootstrap process does not finish as expected, check the CommerceAuthoring\wwwroot\logs for possible errors.

  2. Run the Initialize Environment process to initialize the following environments for the Commerce Authoring Service. Note that the following URLs are case-sensitive; if you copy the URLs from this topic, make sure there are no invisible formatting characters for the quotation marks.
    1. Open http://localhost:5000/commerceops/InitializeEnvironment(environment='AdventureWorksShops') in a browser to initialize the Adventure Works environment.
    2. Openhttp://localhost:5000/commerceops/InitializeEnvironment(environment='HabitatAuthoring') in a browser to initialize the Habitat Authoring environment.

    When the initialization process finishes, you can view new rows inside the "CommerceEntities" and "CommerceLists" tables of the SitecoreCommerce_SharedEnvironments database.

    If the initialization process does not complete as expected, check the CommerceAuthoring\wwwroot\logs for possible errors.
    Note: If you need to run the initialization process again, you must clear all rows in the "CommerceEntities" and "CommerceLists" tables and restart the CommerceAuthoring site to clear the cache.
  3. If you need to run the Minion services automatically for post-order processing, make sure the EnvironmentName attribute in the \CommerceAuthoring\wwwroot\config.json file is set to "HabitatMinions".
  4. Restart the CommerceAuthoring IIS service to complete activation.