3

I'm in the process of deploying some windows azure projects and I've noticed that it's a bit of a pain to constantly switch my role configuration settings from using LocalStorage to actually use my Windows Azure Storage connection strings.

For local development, I want to use this:

UseDevelopmentStorage=true

But for deployed apps, I want to use something like:

DefaultEndpointsProtocol=https;AccountName=myAccountName;AccountKey=blah

I end up either changing my role's configuration connection strings just before I deploy, or if I forget to do that, I'll attempt to go into the Windows Azure portal and change them (but that usually happens after I watch my role instances start and stop over and over).

I feel like I'm missing something basic, but is there a straight-forward way to have the deployment process switch my role connection settings to use the production storage accounts instead of local storage?

David Hoerster
  • 28,421
  • 8
  • 67
  • 102

5 Answers5

4

You can use CloudConfigurationManager in Azure SDK 1.7 http://msdn.microsoft.com/en-us/LIBRARY/microsoft.windowsazure.cloudconfigurationmanager

This starts by looking in the ServiceConfiguration.cscfg e.g. ServiceConfiguration.Cloud.cscfg for config setting. If it isn't there it falls back to web.config and app.config

For example

CloudConfigurationManager.GetSetting("StorageConnectionString")

Will look in the appropriate cscfg file for StorageConnectionString setting, then it will search the web.config and then app.config.

GraemeMiller
  • 11,973
  • 8
  • 57
  • 111
2

If you want to use Visual Studio config transformations, see my answer to the question Panagiotis mentioned.

Community
  • 1
  • 1
Jonathan McIntire
  • 2,665
  • 23
  • 26
1

Switching from one connectionstring to another when moving from development to cloud

Cheers.

Community
  • 1
  • 1
vtortola
  • 34,709
  • 29
  • 161
  • 263
1

If you use CI server you can change the connection string there automatically. Details here.

Community
  • 1
  • 1
Anton Moiseev
  • 2,834
  • 4
  • 24
  • 30
0

I've answered a similar question here:

Visual Studio 2010 can apply Debug or Release transformations to Web.config, but what about the Azure settings?

Community
  • 1
  • 1
Igorek
  • 15,716
  • 3
  • 54
  • 92