November Happy Hour will be moved to Thursday December 5th.

Henrik Fransas
Jan 31, 2015
  4295
(1 votes)

Important information if you are having a EPiServer site as a Azure Website

One of the great thing that works with Azure website is the availability to set connectionstrings and AppSettings in the config section of the site in Azure Portal. This makes it possible to get away from some config transformation and does so that you do not need to have password in clear text in the web.config.

Sadly this is not working for a EPiServer site I have noticed and now I think I know why. It seems like EPiServer are reading all the settings from a cached version of the web.config file. This cached version are created on initialization of the site and saved in the database in the table tblSiteConfig with the property name WebConfig.

This works great in a normal site but for a Azure website where there are appsettings and connectionstrings defined in config this becomes a problem. The problem is that Azure are updating these settings in runtime so the information in web.config are never changed, it can say whatever as long as the key exists and match the key/name in the config for the site. That means that EPiServer does not know the “real” value and wrongly uses that one in the web.config file and this can be a big problem if you for example think the production site are using a production database because you defined it so in the configuration tab but it is actually using a developer or testdatabase or whatever you have in the web.config file.

An easy way to check this is to temporary update your site with this information. Add this code to for example the controller of the startpage

ViewBag.NetConnectionStrings = ConfigurationManager.ConnectionStrings["EPiServerDB"]; ViewBag.EPiServerConnectionString = EPiServerDataStoreSection.ConfigurationInstance.ConnectionStrings.ConnectionStrings["EPiServerDB"];

The first line is how to get a connectionstring “the Microsoft way” and the second line is how to get a connectionstring “the EPiServer way”. Then in the view for the startpage add this:

@if (PageEditing.PageIsInEditMode) { <h3>ConfigurationManager.ConnectionStrings["EPiServerDB"]:</h3> <p>@ViewBag.NetConnectionStrings</p> <h3>EPiServerDataStoreSection.ConfigurationInstance.ConnectionStrings.ConnectionStrings["EPiServerDB"]:</h3> <p>@ViewBag.EPiServerConnectionString</p> }

The if statement is very important because you do not want to share this information with the whole world Ler

I have reported this as a bug to EPiServer but you can do a workaround until it is done by adding config transformations for this.

Jan 31, 2015

Comments

Erik Henningson
Erik Henningson Feb 1, 2015 11:00 AM

Thanks for sharing!
I was just about to remove the connectionstring in web.config, so you probably saved me a couple of hours of headache.

Henrik Fransas
Henrik Fransas Feb 1, 2015 12:37 PM

Nice that I could help Erik, it feels god -:)

Henrik Fransas
Henrik Fransas Feb 2, 2015 09:05 AM

I have now got confirmation on that this is a feature not built in to EPiServer yet, but they are working on it now.

Feb 5, 2015 11:44 AM

Hmm, EPiServer CMS does not read a cached configuration from database, that is just a cache for mirroring and is not used in Azure. Though to support non-web environments it seems to call ConfigurationManager.OpenMappedExeConfiguration which might not be supported by this Azure feature. We will have a look and see if we can use ConfigurationManager.ConnectionStrings instead without breaking anything. Thanks for letting us know.

Henrik Fransas
Henrik Fransas Feb 5, 2015 12:25 PM

Thanks for the explanation Per!
Good luck!

Henrik Fransas
Henrik Fransas Mar 22, 2015 08:49 AM

This is now fixed in the latest update from EPiServer
http://world.episerver.com/documentation/Release-Notes/ReleaseNote/?releaseNoteId=122518

Please login to comment.
Latest blogs
Adding Geolocation Personalisation to Optimizely CMS with Cloudflare

Enhance your Optimizely CMS personalisation by integrating Cloudflare's geolocation headers. Learn how my Cloudflare Geo-location Criteria package...

Andy Blyth | Nov 26, 2024 | Syndicated blog

Optimizely SaaS CMS + Coveo Search Page

Short on time but need a listing feature with filters, pagination, and sorting? Create a fully functional Coveo-powered search page driven by data...

Damian Smutek | Nov 21, 2024 | Syndicated blog

Optimizely SaaS CMS DAM Picker (Interim)

Simplify your Optimizely SaaS CMS workflow with the Interim DAM Picker Chrome extension. Seamlessly integrate your DAM system, streamlining asset...

Andy Blyth | Nov 21, 2024 | Syndicated blog

Optimizely CMS Roadmap

Explore Optimizely CMS's latest roadmap, packed with developer-focused updates. From SaaS speed to Visual Builder enhancements, developer tooling...

Andy Blyth | Nov 21, 2024 | Syndicated blog