Nucleus .Net Core CMS

Hosting in Azure App Service

NOTE: This guide assumes that you are using Azure Sql Server as your database, and Azure App Storage as your file system.

  1. If you don't already have one, create an Azure free account. The free App Service tier isn't appropriate for a production site, but you can use it to get started, and upgrade your App Service tier later.

  2. Sign in to the Azure portal, click "App Services" and create an App service.

  3. Identify your app service IP address. In the Azure portal App services page, click your App Service, then choose the "Networking" option under "Settings". The IP address is displayed as "Inbound Address". Copy the IP address, you will need this value for step 6.

  4. Select the "Configuration" menu item for your App Service, then click the "Default documents" link at the top of the page. Remove all of the default documents, and add a single "/" default document. Click Save at the top of the page.

  5. Return to the Azure portal home page, click "SQL Databases" and create a database.

  6. In the Azure portal SQL databases page, select your database, and click the "Set server firewall" link at the top of the page. Add the IP address that you collected in step 3, then click "Save" at the top of the page.

  7. Get your database connection information by clicking the "Connection strings" link. Note that the connection string password is not set in the displayed connection string - you must substitute the password that you entered when you created the database. The connection string is required for step 10.

  8. Connect to your App service using an FTP client. You can get your FTP credentials and endpoint by using the "Deployment Center" option after selecting your App Service. Click the "FTPS credentials" link at the top of the page to view FTP information.

  9. Un-zip the install package (zip file) locally, then upload the files to your Azure /site/wwwroot folder.

  10. The Nucleus setup wizard can automatically set up your database configuration, so you can skip this step and paste your database connection string into the wizard when prompted.

    If you want to manually configure your database settings, edit databaseSettings.Production.json or databaseSettings.Development.json. If you are setting up a development environment you will need to create a databaseSettings.Development.json file. Use the template below and copy/paste your Azure database connection string in to the ConnectionString setting.

{
  "Nucleus": {
    "Database": {
      "Connections": [
        // Database connections are available to the core and extensions, but must be configured in the Schemas 
        // section in order to be used.
        {
          "Key": "nucleus-azure",
          "Type": "SqlServer",
          "ConnectionString": "[copy your connection string from Azure Portal]"
        }
      ],
      "Schemas": [
        {
          // A name of "*" makes this schema the default.  The ConnectionKey value must match a Key from the Connections
          // section.
          "Name": "*",
          "ConnectionKey": "nucleus-azure"
        }
      ]
    }
  }
}
  1. Create an Azure storage account.

  2. In Azure Portal, open your storage account, select "Access Keys" from the "Security+Networking" submenu and click the "Show Keys" link. Click the copy button next to the first connection string to copy it to the clipboard.

  3. The Nucleus setup wizard can automatically set up your file system configuration, so you can skip this step and paste your Azure Storage connection string into the wizard when prompted.

    If you want to manually configure your file system provider, edit appSettings.Production.json or appSettings.Development.json. Locate the Nucleus/FileSystems/Providers section and add a setting for your Azure storage account.

"FileSystems": {
  "Providers": [
    // File providers have a key, name, provider type and root folder.  You can specify multiple file providers, and the user
    // will be presented with a list.  The "Name" property is shown to the user.  Each entry has a key which uniquely identifies 
    // the provider entry.
    {
      "Key": "Azure-Storage",
      "Name": "Azure-Storage",
      "ProviderType": "Nucleus.Extensions.AzureBlobStorageFileSystemProvider.FileSystemProvider,Nucleus.Extensions.AzureBlobStorageFileSystemProvider",
      "ConnectionString": "DefaultEndpointsProtocol=https;AccountName=your-account-name;AccountKey=your-account-key;EndpointSuffix=core.windows.net",
      "RootPath": "my-container/my-nucleus-root-folder"
    }
  ]

If you want to use a specific container, or container/sub-folder as your root for Nucleus file storage, set the RootPath configuration property to your container name (and optionally, a sub-folder). If you want Nucleus to be able to access all containers and folders within your Azure storage service, you can set the RootPath value to an empty string, or remove the setting.

  1. Nucleus writes logs, cache and other files to sub-folders of %ProgramData%\Nucleus by default. In Windows, this is C:\ProgramData\Nucleus, which is an appropriate location for the files. In an Azure App Service, %ProgramData%\Nucleus is mapped to \local\ProgramData, which is treated as temporary storage and is reset every time your Azure App Service is restarted. This is not ideal for logs, so you should configure Nucleus to save log files within the Azure %HOME% folder. Understanding the Azure App Service file system

    Edit the appSettings.json or appSettings.Production.json file. Locate the FolderOptions section, which is commented out by default. Remove the comments, and set Nucleus:FolderOptions:DataFolder to {WebRootFolder}/App_Data/Nucleus. The {WebRootFolder} token is replaced automatically at run time.
"Nucleus:" 
{
  "FolderOptions": {
    "DataFolder": "{WebRootFolder}/App_Data/Nucleus"
}

In an Azure App Service, {WebRootFolder} is replaced at run-time by /site/wwwroot/, so the logs would be written to /site/wwwroot/App_Data/Nucleus/Logs. /site/wwwroot/App_Data is a safe location to use for logs and other Nucleus data because files stored within /App_Data are never directly served by IIS. The /site/wwwroot/ folder is the Azure App Service %HOME% directory, which Azure App Service treats as persistent storage.

  1. Get your site Url from the Azure portal by clicking "App services", then selecting your App Service. Click the site Url to launch your site.

Troubleshooting

If the site does not launch or returns an error, click the "App Service Logs" option in Azure Portal. Enable Application Logging(Filesystem) and Web Server logging, then click "Log Stream" (in the left-hand menu). Try to open your site again, and error details will be shown in the Log Stream page.