Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Changed connection string definition in web.config #1922

Closed
wants to merge 1 commit into from

2 participants

@ngsrinivas

Adding the connection string under in web.config throws a NullReferenceException when recovering it through

String connectionString = ConfigurationManager.ConnectionStrings["StorageConnectionString"].ConnectionString;

later on. Instead, add the connection string under its rightful place in web.config.

@ngsrinivas ngsrinivas Changed connection string definition in web.config
Adding the connection string under <appSettings> in web.config throws a NullReferenceException when recovering it through

String connectionString = ConfigurationManager.ConnectionStrings["StorageConnectionString"].ConnectionString;

later on. Instead, add the connection string under its rightful place in web.config.
cc3c2ab
@cjgronlund
Collaborator

@ngsrinivas
Thanks for this contribution to Azure documentation. I've submitted this PR to the article writer for review.
--Carolyn

@cjgronlund
Collaborator

@ngsrinivas
Thanks again for this contribution. The writer will incorporate changes in a separate PR, so I'll close this one. But, your corrections are much appreciated!
--Carolyn

@cjgronlund cjgronlund closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jul 15, 2014
  1. @ngsrinivas

    Changed connection string definition in web.config

    ngsrinivas authored
    Adding the connection string under <appSettings> in web.config throws a NullReferenceException when recovering it through
    
    String connectionString = ConfigurationManager.ConnectionStrings["StorageConnectionString"].ConnectionString;
    
    later on. Instead, add the connection string under its rightful place in web.config.
This page is out of date. Refresh to see the latest.
Showing with 7 additions and 7 deletions.
  1. +7 −7 includes/storage-configure-connection-string.md
View
14 includes/storage-configure-connection-string.md
@@ -49,17 +49,17 @@ To configure your connection string in the Azure service configuration:
If you are writing an application that is not an Azure cloud service, (see previous section), it is recommended you use the .NET configuration system (e.g. `web.config` or `app.config`). This includes Azure Web Sites or Azure Virtual Machines, as well as applications designed to run outside of Azure. You store the connection string using the `<appSettings>` element as follows. Replace `my-account-name` with the name of your storage account, and `my-account-key` with your account access key:
<configuration>
- <appSettings>
- <add key="StorageConnectionString" value="DefaultEndpointsProtocol=https;AccountName=<my-account-name>;AccountKey=<my-account-key>" />
- </appSettings>
+ <connectionStrings>
+ <add name="StorageConnectionString" connectionString="DefaultEndpointsProtocol=https;AccountName=my-account-name;AccountKey=my-account-key" />
+ </connectionStrings>
</configuration>
For example, the configuration setting in your config file may be similar to:
<configuration>
- <appSettings>
- <add key="StorageConnectionString" value="DefaultEndpointsProtocol=https;AccountName=storagesample;AccountKey=nYS0gln9fT7bvY+rwu2iWAEyzSNITGkhM88J8HUoyofpK7C8fHcZc2kIZp6cKgYRUM74lHI82L50Iau1+9hPjB==" />
- </appSettings>
+ <connectionStrings>
+ <add name="StorageConnectionString" connectionString="DefaultEndpointsProtocol=https;AccountName=storagesample;AccountKey=nYS0gln9fT7bvY+rwu2iWAEyzSNITGkhM88J8HUoyofpK7C8fHcZc2kIZp6cKgYRUM74lHI82L50Iau1+9hPjB==" />
+ </connectionStrings>
</configuration>
See [Configuring Connection Strings][] for more information on storage connection strings.
@@ -72,4 +72,4 @@ You are now ready to perform the how-to tasks in this guide.
[connection-string4]: ./media/storage-configure-connection-string/connection-string4.png
[connection-string5]: ./media/storage-configure-connection-string/connection-string5.png
-[Configuring Connection Strings]: http://msdn.microsoft.com/en-us/library/windowsazure/ee758697.aspx
+[Configuring Connection Strings]: http://msdn.microsoft.com/en-us/library/windowsazure/ee758697.aspx
Something went wrong with that request. Please try again.