How to read application parameter values ​​for an Azure website

I am trying to configure some key / value pairs for my Azure web application using the application settings section of the Windows Azure preview portal.

enter image description here

Now I'm trying to read the values ​​as shown below

ConfigurationManager.AppSettings ["MyWebApp.DbConnectionString"];

but it returns null values.

Reading application settings from Web.config in my web application works fine.

+6
source share
2 answers

I have found a solution.

web.config, Azure App. / , web.config.

Azure .

//Below code work for both.
ConfigurationManager.AppSettings["KeyName"]

web.config, Azure.

+9

Azure . , , .

, Web.config.

, Web.config. , Web.config, .

Environment.GetEnvironmentVariable("APPSETTING_my-setting-key");
Environment.GetEnvironmentVariable("SQLAZURECONNSTR_my-connection-string-key");

, , .

APPSETTING_.

, :

"Sql Databases" --> "SQLAZURECONNSTR_my-connection-string-key"
"SQL Server" --> "SQLCONNSTR_my-connection-string-key"
"MySQL" --> "MYSQLCONNSTR_my-connection-string-key"
"Custom" --> "CUSTOMCONNSTR_my-connection-string-key"

. Windows Azure Web Sites.

+3

All Articles