Read connection string from Azure connection string configuration

I uploaded the azure webjob on an azure website. I tried to read the connection string from the azure site, where the azure webjob uses the code below, but it returns nothing. The connection strings on the azure websites are located on the configure tab on the azure website. I'm something wrong here.

CloudConfigurationManager.GetSetting("ConnString") 

thanks

+5
source share
2 answers

CloudConfigurationManager.GetSetting ("ConnString") is looking for the parameter with the key "ConnString" in the settings of your application in Azure, and not your connection strings.

You need to add a value in the application settings for your website containing connection strings

enter image description here

+6
source

To get application settings or a connection string, use the regular .NET API

System.Configuration.ConfigurationManager.AppSettings["name"] as well as System.Configuration.ConfigurationManager.ConnectionStrings["name"]

CloudConfigurationManager is designed for the role of web roles / work roles.

0
source

Source: https://habr.com/ru/post/1205956/


All Articles