Ronil Rangaiya
Jul 13, 2023
  1337
(1 votes)

Tips for Deploying to Azure Web App

In this post, I will share my experience in deploying a CMS 12 solution to a self-managed Azure Web App. Although the official documentation provides a good starting point, I wanted to share some tips and potential pitfalls.

For this blog, I'll assume you already have a CMS 12 solution ready for deployment.

1. Easily create Web App + Database

You can use the "Web App + Database" resource create blade from the MarketPlace which simplifies the creation of the web app and SQL database resources. This flow will automatically create a secure connection between the web app and the database and ensures best practices for secure database access. The database username and password will be automatically generated and the connection string added to the web app configuration. You can choose to update the database settings later if needed.

💡 After creation, remember to update the automatically added connection string name on the web app configuration to EPiServerDB and add MultipleActiveResultSets=True.

2. Choose the correct Service Bus tier

The CMS event system requires Topics so you need to choose the "Standard" pricing tier at a minimum. If you choose the Basic tier (as I did), you'll get the following exception on startup:

3. Cloud Configuration

There are two ways of configuring the Azure resources

Configure via Code

For DXP deployments, you can simply add the AddCmsCloudPlatformSupport method however for self-hosted Azure deployments you will need to configure using EPiServer.Azure package directly. See this post for more on code configuration options.

services.AddAzureBlobProvider(options => options.ContainerName = "mosey-media");
services.AddAzureEventProvider(options => options.TopicName = "mosey-events");

💡 Add the EPiServerAzureBlobs and EPiServerAzureEvents connection strings on the web app configuration, which will be used by default.

Configure via appsettings file

In my opinion, code configuration is cleaner and provides more control however you can also configure via the appsettings.json as per the Optimizely documentation. When doing this do note that the "ConnectionString" attribute for AzureBlobProvider and AzureEventProvider is for the actual connection string and not the connection string name.

4. Search Configuration

To configure Search and Navigation, add the following application settings to the web app configuration

episerver__Find__DefaultIndex

episerver__Find__ServiceUrl

💡 Note the double underscore in the key name to ensure it gets translated into an environment variable.

5. Create Admin User

To register an Admin user, add the following line to your Startup.cs. This will register a startup middleware to redirect to the Register page on the first request to the environment.

services.AddAdminUserRegistration();

💡 If you created your site from the Alloy or CMS Empty site template then this line is already added.

6. HTTPS Certificate Error

If the site fails to load and you see "BackgroundService failed" and/or "Unable to configure HTTPS endpoint" exceptions in your log stream, check your "urls" appsetting and remove any https url.

"urls": "http://*:8080/"

I was getting this exception when using the default domain <site>.azurewebsites.net

Jul 13, 2023

Comments

Please login to comment.
Latest blogs
Opti ID overview

Opti ID allows you to log in once and switch between Optimizely products using Okta, Entra ID, or a local account. You can also manage all your use...

K Khan | Jul 26, 2024

Getting Started with Optimizely SaaS using Next.js Starter App - Extend a component - Part 3

This is the final part of our Optimizely SaaS CMS proof-of-concept (POC) blog series. In this post, we'll dive into extending a component within th...

Raghavendra Murthy | Jul 23, 2024 | Syndicated blog

Optimizely Graph – Faceting with Geta Categories

Overview As Optimizely Graph (and Content Cloud SaaS) makes its global debut, it is known that there are going to be some bugs and quirks. One of t...

Eric Markson | Jul 22, 2024 | Syndicated blog

Integration Bynder (DAM) with Optimizely

Bynder is a comprehensive digital asset management (DAM) platform that enables businesses to efficiently manage, store, organize, and share their...

Sanjay Kumar | Jul 22, 2024

Frontend Hosting for SaaS CMS Solutions

Introduction Now that CMS SaaS Core has gone into general availability, it is a good time to start discussing where to host the head. SaaS Core is...

Minesh Shah (Netcel) | Jul 20, 2024

Optimizely London Dev Meetup 11th July 2024

On 11th July 2024 in London Niteco and Netcel along with Optimizely ran the London Developer meetup. There was an great agenda of talks that we put...

Scott Reed | Jul 19, 2024