Q76. How to configure Azure Connection Strings for connecting to the storage emulator?
This is a continuation of the previous question, where we discussed configure Azure Connection Strings. Now, we will create a connection string which we can use for local storage that is storage emulator. In Visual studio, select cloud service project, click on the settings section of the role designer.
Enter the connection string name myLocalString and click on the ellipsis button to display the Storage Account Connection String builder dialog. In this dialog, set the value of the connection string to UseDevelopmentStorage=true.
We can create multiple connection strings for cloud service project. The benefit of using multiple connection strings is that we need not change configurations each time we publish to a different target environment. When we debug the application, by default VS uses the local storage and the compute emulator. On publishing, the cloud service application uses the connection string pointing to Windows Azure storage account. Given below is the code we use to access the connection string value by using the CloudConfigurationManager class in the application code.
var conn = CloudConfigurationManager.GetSetting("MyConnectionString");
We will discuss how to retrieve the connection string from the configuration file in the next question.
See More Questions and Answers on - Azure Table Storage (cont..)