Startup task

Current version: 8.2

The Startup task will run after the Cloud Service instance has been set up, and will perform the Commerce Server set up. Your Startup task should not set up your Commerce Server site and its resource(s). You should create these ahead of time, so that new Cloud Service instances only need to install, configure, and connect to a SQL instance that already has the appropriate databases.

The Startup task is defined inside of the ServiceDefinition.csdef, and points to a Startup.cmd file, which will be called after the Cloud Service is set up.

The following example is an example for how to lay out a Cloud Service project in Visual Studio. Any files created under the WebRole1 node will be copied into the same location in your website. The default search path for files is under the bin folder of the website, so it is recommended to copy the setup assets there. Create a CommerceSever folder that contains all of the assets required for setup: the PowerShell setup script, the Commerce Server installer exe, a template CSConfig.xml file to be used by Commerce Server Configuration Wizard, and a ProfilesKeys.xml. You should pre-create your profile keys, so that each Cloud Service instance is using the same keys.

The Commerce Server installer .exe cannot be run in process by using the Startup.cmd, otherwise it has trouble with space issues on the drives. The workaround for this issue is to create a Scheduled Task in the Startup.cmd that calls in the setup PowerShell script, and then call that Scheduled Task immediately to start the installation. The following an example from the sample setup script of how to do this.


@REM Create a task that will run with full network privileges. 

"Creating scheduled task to install Sitecore Commerce Server" 
SET RUN_DIR=%CD% NET start ScheduleSCHTASKS /CREATE /TN "Install Commerce Server" /SC ONCE /SD 01/01/2020 /ST 00:00:00 /RL
HIGHEST /RU SYSTEM /TR "powershell -Version 3.0 -ExecutionPolicy Unrestricted 
%RUN_DIR%\CommerceServer\Setup-CommerceServer.ps1 -rootPath '%RUN_DIR%'" /F
SCHTASKS /RUN /TN "Install Commerce Server" 
@REM have to return 0 or it will cause a failure

Do you have some feedback for us?

If you have suggestions for improving this article,