Before you deploy: production settings
Create appsettings.Production.json for anything that differs from development:
{
"Umbraco": {
"CMS": {
"Runtime": { "Mode": "Production" },
"ModelsBuilder": { "ModelsMode": "Nothing" },
"Hosting": { "Debug": false },
"Global": { "UseHttps": true },
"WebRouting": { "UmbracoApplicationUrl": "https://www.example.com/" }
}
}
}Runtime: Productionmakes Umbraco refuse unsafe settings, such as in-memory models or debug mode, at start-up.- Use SourceCodeManual models in development and precompiled views. See Models Builder.
- Put the connection string in an environment variable named
ConnectionStrings__umbracoDbDSN, not in the file.
Step 1: Publish
dotnet publish -c Release -o ./publishThe publish folder contains everything the server needs.
Option A: Windows Server with IIS
- Install the .NET 10 Hosting Bundle on the server, then restart IIS with
iisreset. - In IIS Manager, create an application pool with .NET CLR version set to No Managed Code.
- Create a site pointing at your publish folder, using that pool, and add your HTTPS binding.
- Give the pool's identity Modify permission on the folders Umbraco writes to:
$site = "C:\inetpub\mysite"
icacls "$site\umbraco" /grant "IIS AppPool\MySite:(OI)(CI)M"
icacls "$site\wwwroot\media" /grant "IIS AppPool\MySite:(OI)(CI)M"- Set environment variables for the site in
web.config(<environmentVariables>under<aspNetCore>) or as system environment variables.
Option B: Azure App Service
az group create -n mysite-rg -l uksouth
az appservice plan create -n mysite-plan -g mysite-rg --sku P0v3 --is-linux
az webapp create -n mysite-web -g mysite-rg -p mysite-plan --runtime "DOTNETCORE:10.0"
az webapp config connection-string set -n mysite-web -g mysite-rg \
-t SQLAzure --settings umbracoDbDSN="Server=tcp:...;Database=mysite;Authentication=Active Directory Default;"
cd publish && zip -r ../site.zip . && cd ..
az webapp deploy -n mysite-web -g mysite-rg --src-path site.zip --type zip- Linux plans are usually cheaper than Windows ones. Umbraco 18 runs well on both. See our Windows to Linux service.
- Use Azure SQL, not SQLite, if you'll ever run more than one instance.
- Store media in Azure Blob Storage with the
Umbraco.StorageProviders.AzureBlobpackage so it survives redeployments and scale-out.
Don't forget Data Protection keys
ASP.NET Core encrypts login cookies and anti-forgery tokens with Data Protection keys. If they're lost on every deployment, everyone is logged out and forms show errors. Persist them somewhere shared:
using Microsoft.AspNetCore.DataProtection;
builder.Services.AddDataProtection()
.SetApplicationName("MySite")
.PersistKeysToFileSystem(new DirectoryInfo("/home/data-protection-keys"));On Azure, Azure.Extensions.AspNetCore.DataProtection.Blobs with Key Vault is the robust choice.
After deploying
- Visit the site and log in to
/umbraco. - Run Settings › Health Check.
- Check the logs under Settings › Log Viewer for errors.
Need a hand?
umbraco.ninja has more than 20 years of Umbraco experience. If you'd rather not do this yourself, we'll set it up, test it and hand it over.
Get a fixed-price quote