powershell - Web Config changes for deployment slots in Azure -


i have created 3 deployment slots on azure website.

  1. devtest
  2. qa
  3. staging

for each slot need customize web.config file. changes through out web.config file , not in appsettings , connectionstring sections, such web service endpoints, smtp details, logging details, debugging details, etc...

it seems though azure supports changes in connectionstring , appsettings.

how configure these different slots update rest of web.config?

the end result would continuously integrate devtest, swap qa, staging , production. have tried release management seems support azure vm deployments. noob @ powershell believe may answer.

any appreciated.

====== resolution ======

so, thought i'd feedback on else looking way this. created webconfig.cs class follows:

[assembly: webactivatorex.preapplicationstartmethod(typeof(webconfig), "populatefromappsettings")] namespace application.presentation.web {     using system;     using system.configuration;     using system.xml;      public static class webconfig     {         private static xmldocument webconfig;          private static bool docchanged = false;          public static bool isconfigured = false;          static webconfig()         {             if (isconfigured)             {                 return;             }              webconfig = new xmldocument();             webconfig.load(appdomain.currentdomain.setupinformation.configurationfile);         }          public static void populatefromappsettings()         {             if (isconfigured)             {                 return;             }              // system.web             setattributevalue("/configuration/system.web/compilation", "debug", configurationmanager.appsettings["compilationdebug"]);             setattributevalue("/configuration/system.web/customerrors", "mode", configurationmanager.appsettings["customerrorsmode"]);              // log4net             setattributevalue("/configuration/log4net/appender/param[@name='connectionstring']", "value", configurationmanager.appsettings["azureappenderconnectionstring"]);             setattributevalue("/configuration/log4net/appender/param[@name='containername']", "value", configurationmanager.appsettings["azureappenderconnectionstring"]);             setattributevalue("/configuration/log4net/appender/param[@name='directoryname']", "value", configurationmanager.appsettings["azureappenderconnectionstring"]);              // system.identitymodel             setattributevalue("/configuration/system.identitymodel/identityconfiguration/issuernameregistry/trustedissuers/add", "name", configurationmanager.appsettings["issuernameregistrytrustedissuers"]);             setattributevalue("/configuration/system.identitymodel/identityconfiguration/issuernameregistry/trustedissuers/add", "thumbprint", configurationmanager.appsettings["trustedissuersthumbprint"]);             setattributevalue("/configuration/system.identitymodel/identityconfiguration/audienceuris/add", "value", configurationmanager.appsettings["audienceurivalue"]);             setattributevalue("/configuration/system.identitymodel.services/federationconfiguration/wsfederation", "issuer", configurationmanager.appsettings["wsfederationissuer"]);             setattributevalue("/configuration/system.identitymodel.services/federationconfiguration/wsfederation", "realm", configurationmanager.appsettings["wsfederationrealm"]);             setattributevalue("/configuration/system.identitymodel.services/federationconfiguration/wsfederation", "reply", configurationmanager.appsettings["wsfederationreply"]);             setattributevalue("/configuration/system.identitymodel/identityconfiguration/certificatevalidation", "certificatevalidationmode", configurationmanager.appsettings["certificatevalidationmode"]);             setattributevalue("/configuration/system.identitymodel/identityconfiguration/certificatevalidation", "revocationmode", configurationmanager.appsettings["certificaterevocationmode"]);             setattributevalue("/configuration/system.identitymodel/identityconfiguration/certificatevalidation", "trustedstorelocation", configurationmanager.appsettings["certificatetrustedstorelocation"]);              // system.servicemodel             setattributevalue("/configuration/system.servicemodel/client/endpoint", "address", configurationmanager.appsettings["endpointaddress"]);             setattributevalue("/configuration/system.servicemodel/client/endpoint/identity/serviceprincipalname", "value", configurationmanager.appsettings["serviceprincipalname"]);              if (docchanged)             {                 webconfig.save(appdomain.currentdomain.setupinformation.configurationfile);             }              isconfigured = true;         }          private static void setattributevalue(string xpath, string attributename, string value)         {             var selectsinglenode = webconfig.selectsinglenode(xpath);             if (selectsinglenode != null && selectsinglenode.attributes != null)             {                 if (selectsinglenode.attributes[attributename].value != value)                 {                     selectsinglenode.attributes[attributename].value = value;                     docchanged = true;                 }             }             else             {                 throw new exception(string.format("config attribute '{0}' not found in config @ path '{1}'", attributename, xpath));             }         }     } } 

this piece of code causes method run @ startup.

[assembly: webactivatorex.preapplicationstartmethod(typeof(webconfig), "populatefromappsettings")] 

i created variables in web.config->appsettings , created them under azure -> application settings.

it seems work except 1 problem. update code executes when website run first time. means first execution, settings wrong. when reload website, new settings take effect. small price pay think. post if figure out better ways of doing this.

powershell not quite answer here, powershell 1 client surface azure app service platform functionality. web.config considered content deployment slot perspective , not swap invariant. 1 option consider surfacing settings require customization app settings (environment variables) , populating them across slots. @ runtime can detect slot code running in/which settings should used reading azure app service populated website_slot_name app setting.


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -