从Azure管理获取连接字符串和密码 [英] Get connection string and password from Azure management

查看:41
本文介绍了从Azure管理获取连接字符串和密码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Azure的用户,想从Azure管理门户获取连接字符串和电子邮件密码.我将这两个变量放在应用程序设置中,并试图在我的网站上访问它们,但连接字符串始终返回此错误: ConnectionString属性尚未初始化.

I am a user of Azure and want to get a connection string and email password from the azure management portal. I have put these two variables in the app settings and tried to get access to them on my website but the connection string always returns this error: The ConnectionString property has not been initialized.

这是我的C#代码:

private string connectionString = Environment.GetEnvironmentVariable("SQLAZURECONNSTR_bitverifydb");
private string emailPassword = Environment.GetEnvironmentVariable("APPSETTING_Password");

推荐答案

目前尚不清楚您使用的是哪个Azure平台.其他一些答案假定它是CloudService.但是,在某些情况下,您使用的是AppService,它与使用System.Configuration的.NET相同.

It's not clear from your question which Azure platform you are using. Some other answers assumed it's CloudService. However, in a case, you are using AppService, it's the same code as .NET using System.Configuration

var connString = ConfigurationManager.ConnectionStrings["bitverifydb"].ConnectionString;
var password = ConfigurationManager.AppSettings["Password"]

这篇关于从Azure管理获取连接字符串和密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆