Azure connection string best practices -


i have application migrating azure. use web.config transformation manage changing database connecting string dev/staging/prod environments. how best manage these multiple connection strings in azure?

in cases doesn't matter if developer can see production credentials, can use built-in visual studio 10 config transformations. if you're looking for, follow these steps:

1.navigate azure project folder in file explorer
2. make copy of serviceconfiguration.cscfg
3. rename copy serviceconfiguration.base.cscfg
4. each build configuration (e.g. dev, staging, production), create serviceconfiguration.<build config name>.cscfg file. in these files, can use normal config transformation syntax
5. open .ccproj file in text editor
6. find following node,

<itemgroup>     <servicedefinition include="servicedefinition.csdef" />     <serviceconfiguration include="serviceconfiguration.cscfg" /> </itemgroup> 

and replace (you have edit block match build configs):

<itemgroup>     <servicedefinition include="servicedefinition.csdef" />     <serviceconfiguration include="serviceconfiguration.cscfg" />     <none include="serviceconfiguration.base.cscfg">         <dependentupon>serviceconfiguration.cscfg</dependentupon>     </none>     <none include="serviceconfiguration.dev.cscfg">         <dependentupon>serviceconfiguration.cscfg</dependentupon>     </none>     <none include="serviceconfiguration.staging.cscfg">         <dependentupon>serviceconfiguration.cscfg</dependentupon>     </none>     <none include="serviceconfiguration.production.cscfg">         <dependentupon>serviceconfiguration.cscfg</dependentupon>     </none> </itemgroup> 

7.add following @ end of .ccproj file, above </project>:

<import project="$(msbuildextensionspath)\microsoft\visualstudio\v10.0\web\microsoft.web.publishing.targets" /> <target name="beforebuild">     <transformxml source="serviceconfiguration.base.cscfg" transform="serviceconfiguration.$(configuration).cscfg" destination="serviceconfiguration.cscfg" /> </target> 

8.if you're using ci server doesn't have visual studio 10 installed, you'll have copy c:\program files\msbuild\microsoft\visualstudio\v10.0\web folder , contents development machine server.

update: @solarsteve noted, might have add namespace serviceconfiguration.*.cscfg files. here's example of serviceconfiguration.base.cscfg:

<sc:serviceconfiguration servicename="myservicename" osfamily="1" osversion="*" xmlns:sc="http://schemas.microsoft.com/servicehosting/2008/10/serviceconfiguration" xmlns:xdt="http://schemas.microsoft.com/xml-document-transform">   <sc:role name="myrolename">     <sc:instances count="1" />     <sc:configurationsettings>       <sc:setting name="dataconnectionstring" value="xxx" />     </sc:configurationsettings>   </sc:role> </sc:serviceconfiguration> 

Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

aspxgridview - Devexpress grid - header filter does not work if column is initially hidden -

c# - How to execute a particular part of code asynchronously in a class -