[英]How do I get a connection string from Azure App Service configuration in a .Net Frame Asp.Net application?
I have a standard.Net Framework Asp.Net application deployed in an Azure App Service.我在 Azure 应用服务中部署了一个标准的 .Net 框架 Asp.Net 应用程序。 Within the Azure configuration, I've set up a couple environment variables and a connection string.在 Azure 配置中,我设置了几个环境变量和一个连接字符串。
I'm able to retrieve the environment variables correctly at runtime.我能够在运行时正确检索环境变量。
var value = System.Environment.GetEnvironmentVariable("AppSettingTest");
How do you I retrieve the connection string?你如何检索连接字符串?
This application IS NOT Asp.Net Core.此应用程序不是 Asp.Net Core。 I am not using dependency injection and a startup class. I could store that value in an environment variable, but I'm led to believe connection strings stored in the App Service configuration connection string is more secure.我没有使用依赖注入和启动 class。我可以将该值存储在环境变量中,但我相信存储在 App Service 配置连接字符串中的连接字符串更安全。
Thank you Andrew Williamson and JohnB posting your discussions as answer to help other community members.感谢Andrew Williamson和JohnB发布您的讨论作为帮助其他社区成员的答案。
Environmental variables in Azure App Service are prefixed with APPSETTING_
, SQLCONNSTR_
, etc. complete list is available here full list here Azure 应用服务中的环境变量以APPSETTING_
、 SQLCONNSTR_
等为前缀。完整列表可在此处获得完整列表在这里
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.