我一直在尝试通过 Azure 门户将连接字符串从 webjobs 的 App.config 文件移动到主机网站。我尝试过:
ConnectionStringSettings test = ConfigurationManager.ConnectionStrings["AzureDB"];
我还尝试使用 GetSetting 并将连接字符串作为键/值对放入配置选项的应用程序部分。
这仍然只显示我的本地连接字符串。我也尝试过使用 CloudConfigurationManager 但无济于事。
到处都有这样的例子,并且在SO中引用:
However, you don't have to set it in app.config for the web job if you set them in the portal. The WebJobs SDK knows how to read them from there.
那么我如何访问它们?
最佳答案
- 安装Microsoft Azure Configuration Manager
- 将连接字符串移至 appSetting 部分(用于调试目的)
使用
CloudConfigurationManager
检索连接字符串:var myConnectionString = CloudConfigurationManager.GetSetting("MyConnectionString");
您现在可以在 Azure 门户中管理连接字符串。
关于azure - 从网络作业访问网站连接字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29537581/