I am searching for the connection string that is need to be defined to use windows azure storage emulator.
So far, all the sources I have found says these connection strings should go to ServiceDefinition
and ServiceConfiguration
files located in Windows Azure project. However, I am not using Azure project but the ASP.NET MVC 3.
For, ASP.NET MVC project, it should probably go to web.config
file. However, I have no idea what it should look like ?
I have Azure account if that is needed for emulator.
Thanks.
As this article says connectionstring is DevelopmentStorage=true
So in Web.config you can use:
<appSettings>
<add key="StorageConnectionString" value="UseDevelopmentStorage=true" />
</appSettings>
In ServiceConfiguration.cscfg:
<Setting name="StorageConnectionString" value="UseDevelopmentStorage=true" />
You can use CloudConfigurationManager it will get the configuration from the Service Configratuon settings if it exists. Use it likes this:
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(
CloudConfigurationManager.GetSetting("StorageConnectionString"));
If it doesn't exist in ServiceConfiguration it will fall back to the application settings of your web.config. That way if you move application to Azure if you want and not have to change anything in how you retrieve your connection strings. I tend to hide it all in an ISettingsProvider interface (So I don't take a dependency on anything) but that is probably overkill.
The main benefit of putting connection in the ServiceConfiguration is that you can change the setting without having to re-deploy the application.
If you choose to use web.config then you can use transform to swap out the developmentstorage account to a real account on publish. If you use Azure just have a different connection string in the Cloud service configuration.
Don't need actual Azure account to run the emulator.
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