Deploy CMS PaaS
Why deploy to Optimizely cloud
Section titled “Why deploy to Optimizely cloud”Optimizely cloud hosting provides managed infrastructure for CMS PaaS — automatic scaling, database management, CDN, and environment promotion. Deploying to this environment frees you from managing servers and lets you focus on building your site.
What you will do
Section titled “What you will do”- Prepare your project for deployment
- Create a deployment package
- Deploy using the Optimizely CLI or CI/CD pipeline
- Verify the deployment in each environment
Prepare your project
Section titled “Prepare your project”Before deploying, ensure your project builds cleanly and has the correct configuration.
# Clean and build in Release mode
dotnet clean
dotnet build --configuration Release
# Run tests before deploying
dotnet test --configuration Release
# Verify the publish output
dotnet publish --configuration Release --output ./publish Check your appsettings.json to ensure environment-specific settings use environment variables or the Optimizely configuration service.
var builder = WebApplication.CreateBuilder(args);
// Load environment-specific settings
builder.Configuration
.AddJsonFile("appsettings.json", optional: false)
.AddJsonFile(
$"appsettings.{builder.Environment.EnvironmentName}.json",
optional: true)
.AddEnvironmentVariables();
builder.Services.AddCms(); Do not hardcode connection strings or secrets. Use environment variables that the Optimizely cloud injects at runtime.
Create a deployment package
Section titled “Create a deployment package”The Optimizely cloud accepts NuGet packages (.nupkg) for deployment.
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<PackageId>MySite.Cms</PackageId>
<Version>1.0.0</Version>
<EnableDefaultContentItems>true</EnableDefaultContentItems>
</PropertyGroup>
<ItemGroup>
<Content Include="Views\**" />
<Content Include="ClientResources\**" />
<Content Include="wwwroot\**" />
</ItemGroup> # Create the deployment package
dotnet publish --configuration Release
nuget pack MySite.Cms.nuspec -Version 1.0.0 -OutputDirectory ./artifacts Deploy with the Optimizely CLI
Section titled “Deploy with the Optimizely CLI”The Optimizely CLI streamlines package uploads and environment promotion.
# Install the Optimizely deployment CLI
dotnet tool install -g Optimizely.Cms.Cli
# Upload package to Integration environment
opti deploy upload \
--project-id your-project-id \
--api-key your-api-key \
--api-secret your-api-secret \
--package ./artifacts/MySite.Cms.1.0.0.nupkg \
--target-environment Integration
# Check deployment status
opti deploy status \
--project-id your-project-id \
--api-key your-api-key \
--api-secret your-api-secret Automate with CI/CD
Section titled “Automate with CI/CD”Set up a GitHub Actions workflow to deploy on every push to your release branch.
name: Deploy CMS
on:
push:
branches: [release]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Build and publish
run: dotnet publish -c Release -o ./publish
- name: Deploy to Integration
run: |
dotnet tool install -g Optimizely.Cms.Cli
opti deploy upload \
--project-id ${{ secrets.OPTI_PROJECT_ID }} \
--api-key ${{ secrets.OPTI_API_KEY }} \
--api-secret ${{ secrets.OPTI_API_SECRET }} \
--package ./publish \
--target-environment Integration Promote between environments
Section titled “Promote between environments”Optimizely cloud provides three environments: Integration, Preproduction, and Production. Promote code forward after testing.
# Promote from Integration to Preproduction
opti deploy promote \
--project-id your-project-id \
--source Integration \
--target Preproduction
# After testing, promote to Production
opti deploy promote \
--project-id your-project-id \
--source Preproduction \
--target Production Post-deployment verification
Section titled “Post-deployment verification”After each deployment:
- Check the deployment status in the Optimizely management portal
- Verify the site loads correctly in a browser
- Confirm content types synchronized — look for any migration warnings in logs
- Test critical user flows (content editing, publishing, search)
Common issues
Section titled “Common issues”| Issue | Cause | Fix |
|---|---|---|
| Deployment times out | Package too large or slow network | Exclude unnecessary files from the package |
| Missing views after deploy | Views not included in publish output | Add <Content Include="Views\**" /> to .csproj |
| Database migration fails | Schema conflicts | Review migration logs and resolve conflicts before promoting |