Tuesday, September 13, 2022

Sitecore Headless Development with ASP.NET and Sitecore containers

Sitecore Headless Development with ASP.NET and Sitecore containers with the launch of Sitecore 10 

Step 1: Download and Install

Using PowerShell, download and install the template within your file system using the following command:

dotnet new -i Sitecore.DevEx.Templates --nuget-source https://sitecore.myget.org/F/sc-packages/api/v3/index.json 


Step 2: Check for Existing Processes

Check for existing services on ports 443 and 8984. If there are running services on these ports, you will need to stop them. Note that you may run into port collision errors if you have other Sitecore environments running on your workstation. 

Examples of Stop commands:

iisreset /stop

Stop-Service -Name "<name of service>"

nssm stop "<name of service>" 


Step 3: Create the MyProject Solution

Change the directory of PowerShell to the location where you want to create and run your project. Then, create the MyProject solution with the command shown below.

dotnet new sitecore.aspnet.gettingstarted -n MyProject 


Note: This command will give you an option to run the dotnet tool restore command and if you choose to do so enter "y" to run the command.


Step 4: Prepare and Run the Initialization Script

Change the PowerShell directory to point to the newly created MyProject folder. This folder contains all the scripts and items necessary for the Getting Started project solution. The initialization script prepares a valid and trusted wildcard certificate for *.myproject.localhost, the host file entries for myproject.localhost, and the required environment variable values in the .env file for the Sitecore instance. 

To run this script, use the path to your valid Sitecore license and your administrative password. Run the initialization script with the command below. Make sure to click "Yes" after running the command for installing the certificate.

.\init.ps1 -InitEnv -LicenseXmlPath "<C:\...\license.xml>" -AdminPassword "<admin password>"


Step 5: Run the up.ps1 Script

Run the up.ps1 script to start up the environment with the command:

.\up.ps1


Step 6: Confirm the Environment is Running

Near the end of the startup process, a browser will open for you to log in to the Identity server. Use the administrative password entered in Step 4 to log in as the Administrator (user name: admin). The Identity server will then ask you to confirm device authentication. Once this is finished, the script will use the Sitecore Content Serialization CLI to deserialize the sample content items. 

At the end of the startup process, the script will open new browser tabs with both myproject.localhost (the Rendering Host) and cm.myproject.localhost (the Content Management, Content Delivery, and Sitecore Layout Service). From here, you can confirm the environment is running appropriately.

No comments:

Post a Comment

How to Create a Public Link Using the Sitecore Content Hub REST API

Creating a public link using the Sitecore Content Hub REST API is a straightforward process that enables you to share content externally whi...