Setting the UmbracoApplicationUrl programmatically
Hi all,
I have a scenario where Umbraco running in a load balanced environment isn't picking up the correct umbracoApplicationUrl at start-up. A work-around here is to use the value in umbracoSettings.config, but our build/deployment process is fully automated, and there's a known bug in VSTS that only allows XML transformations at release time from web.config, but JSON transformations anywhere.
Because of that, we're looking to see if the umbracoApplicationUrl can be set in code, or the main web.config (without moving the whole settings config into it). The source code doesn't appear to expose a method to set the value, and I'm not sure if the available start-up methods are already too late?
Does any one know of a method to be able to override the umbracoApplicationUrl programmatically?
You can basically take responsibility for determining which servers should be Master or Slave, by implementing your own IServerRegistrar2 implementations (one for master, and one for slave)... and then have an appsetting (which you can transform for different environments) that you read on application startup that determines which server uses which IServerRegistrar2 implementation...
When you implement an IServerRegistrar2 class you implement a method GetCurrentServerUmbracoApplicationUrl() and it's here you can set programmatically your umbracoApplicationUrl... if you return null, Umbraco will look in UmbracoSettings, and then if not set there, default to the first request the server receives.
That looks to be exactly what we're after - thanks so much! Don't know why I didn't check the flexible load balancing docs first - we followed them to build the initial environments but something in my head told me "forcing" a site URL and "flexible" load balancing just couldn't be on the same page. Mind games!
Setting the UmbracoApplicationUrl programmatically
Hi all,
I have a scenario where Umbraco running in a load balanced environment isn't picking up the correct
umbracoApplicationUrl
at start-up. A work-around here is to use the value inumbracoSettings.config
, but our build/deployment process is fully automated, and there's a known bug in VSTS that only allows XML transformations at release time from web.config, but JSON transformations anywhere.Because of that, we're looking to see if the
umbracoApplicationUrl
can be set in code, or the main web.config (without moving the whole settings config into it). The source code doesn't appear to expose a method to set the value, and I'm not sure if the available start-up methods are already too late?Does any one know of a method to be able to override the
umbracoApplicationUrl
programmatically?Thanks!
Hi Ed
Have a look at the information on Flexible Load Balancing here:
https://our.umbraco.com/Documentation/Getting-Started/Setup/Server-Setup/Load-Balancing/flexible-advanced
You can basically take responsibility for determining which servers should be Master or Slave, by implementing your own IServerRegistrar2 implementations (one for master, and one for slave)... and then have an appsetting (which you can transform for different environments) that you read on application startup that determines which server uses which IServerRegistrar2 implementation...
When you implement an IServerRegistrar2 class you implement a method GetCurrentServerUmbracoApplicationUrl() and it's here you can set programmatically your umbracoApplicationUrl... if you return null, Umbraco will look in UmbracoSettings, and then if not set there, default to the first request the server receives.
regards
Marc
Hi Marc,
That looks to be exactly what we're after - thanks so much! Don't know why I didn't check the flexible load balancing docs first - we followed them to build the initial environments but something in my head told me "forcing" a site URL and "flexible" load balancing just couldn't be on the same page. Mind games!
Thanks again!
is working on a reply...