I wrote an asp.net mvc 4 web site. For my corporation purpose, I created several publish profiles, in order to publish it on differents azure websites. Each profile changes the connection strings.
It worked very well.
I am now trying to do the same thing with an azure cloud service (I added my web site as a web role in a new cloud service project). But I can't find out how to change the connection string of my web role depending of my cloud service project publish profile at deploy-time.
Is there a way to do such a thing ?
Thanks !
You could store the connection string in the ServiceConfiguration file .cscfg of your Role and then use the following in your code to retrieve the setting:
string connectionString = RoleEnvironment.GetConfigurationSettingValue("myConnectionString");
You can modify the values in the ServiceConfiguration through the Management Portal once deployed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With