好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

Windows Azure读取配置文件

Windows Azure读取配置文件

在传统的ASP.NET应用程序里,我们读取的配置文件一般都是放在Web.config,并且通过

System.Configuration.ConfigurationSettings.AppSettings[connString]来读取配置文件。

在Windows Azure里,我们也可以将配置文件写入Web.config里。但是因为我们的Web App其实是Azure VM远程托管运行的,如果需要修改配置文件的话我们不得不远程登录桌面,然后再修改IIS下的Web.config文件。管理起来非常复杂。

所以在一般情况下,Windows Azure项目的配置文件是写到CSCFG文件里的

我们查看CSCFG可以看到

然后在Web Project的Global.asax文件,在Application_Start()函数里添加

  protected   void  Application_Start()        
{
  AreaRegistration.RegisterAllAreas();
  RegisterRoutes(RouteTable.Routes);
  CloudStorageAccount.SetConfigurationSettingPublisher((configName, configGetter) =>                
  {
  configGetter.Invoke(RoleEnvironment.GetConfigurationSettingValue(configName));
  });
}

复制代码

这样在需要获取SQLCOnnectionString的时候调用:

CloudStorageAccount.FromConfigurationSetting( "  SQLConnectionString  " )

如果将来用户想修改CSCFG文件的时候,可以用过用户管理界面来修改

Windows Azure

 

Windows Azure Platform (二十二)Windows Azure读取配置文件

 

posted @  2012-03-02 17:30  Lei Zhang的博客 阅读(368) |  评论 (0)   编辑

Windows Azure Platform (二十一)使用Windows Azure Connect,实现云端应用连接本地SQL Server 2008 R2数据库

 

posted @  2012-02-06 18:06  Lei Zhang的博客 阅读(613) |  评论 (0)   编辑

Windows Azure Platform (二十)多个VM Instance场景下如何处理ASP.NET Session

 

posted @  2012-01-30 17:16  Lei Zhang的博客 阅读(88) |  评论 (0)   编辑

Windows Azure Platform (十九)使用Windows Azure诊断收集日志记录数据

 

posted @  2012-01-30 15:48  Lei Zhang的博客 阅读(744) |  评论 (0)   编辑

Windows Azure Platform (十七)使用工具管理Windows Azure Storage

 

posted @  2012-01-23 00:08  Lei Zhang的博客 阅读(32) |  评论 (0)   编辑

Windows Azure Platform (十八)用Visual Studio将应用程序部署到Windows Azure平台

 

posted @  2012-01-22 12:53  Lei Zhang的博客 阅读(40) |  评论 (0)   编辑

Windows Azure Platform (十六)Windows Azure Storage之Table、Queue

 

posted @  2012-01-22 12:44  Lei Zhang的博客 阅读(22) |  评论 (0)   编辑

Windows Azure Platform (十五)Windows Azure Drive

 

posted @  2012-01-21 20:15  Lei Zhang的博客 阅读(65) |  评论 (0)   编辑

Windows Azure Platform (十三)Windows Azure Storage Service存储服务之Blob详解(下)

 

posted @  2012-01-20 16:40  Lei Zhang的博客 阅读(70) |  评论 (0)   编辑

Windows Azure Platform (十三)Windows Azure Storage Service存储服务之Blob详解(上)

 

posted @  2012-01-19 22:24  Lei Zhang的博客 阅读(60) |  评论 (0)   编辑

Windows Azure Platform (十二)Windows Azure项目文件详解

 

posted @  2012-01-19 18:16  Lei Zhang的博客 阅读(45) |  评论 (0)   编辑

Windows Azure Platform (十一)微软Windows Azure平台资源汇总

 

posted @  2012-01-19 12:28  Lei Zhang的博客 阅读(44) |  评论 (0)   编辑

Windows Azure Platform (十)把本地的Azure Project部署到云端服务器上

 

posted @  2012-01-18 18:30  Lei Zhang的博客 阅读(72) |  评论 (0)   编辑

Windows Azure Platform (九)开发一个简单的Hello World

 

posted @  2012-01-18 16:58  Lei Zhang的博客 阅读(72) |  评论 (1)   编辑

Windows Azure Platform (八)用户管理界面

 

posted @  2012-01-18 16:33  Lei Zhang的博客 阅读(67) |  评论 (0)   编辑

Windows Azure Platform (七) Windows Azure Storage Service存储服务

 

posted @  2012-01-18 14:47  Lei Zhang的博客 阅读(59) |  评论 (0)   编辑

Windows Azure Platform (六) Windows Azure应用程序运行环境

 

posted @  2012-01-17 19:38  Lei Zhang的博客 阅读(61) |  评论 (0)   编辑

Windows Azure Platform (五) Windows Azure Platform

 

posted @  2012-01-17 15:03  Lei Zhang的博客 阅读(73) |  评论 (0)   编辑

Windows Azure Platform (四) Windows Azure架构

 

posted @  2012-01-17 12:57  Lei Zhang的博客 阅读(72) |  评论 (0)   编辑

Windows Azure Platform (三)

 

posted @  2012-01-17 11:26  Lei Zhang的博客 阅读(64) |  评论 (0)   编辑

Windows Azure Platform (二)

 

posted @  2012-01-16 19:32  Lei Zhang的博客 阅读(90) |  评论 (1)   编辑

Windows Azure Platform (一) 云计算的出现

 

posted @  2012-01-16 18:41  Lei Zhang的博客 阅读(145) |  评论 (4)   编辑

 

作者: Leo_wl

    

出处: http://www.cnblogs.com/Leo_wl/

    

本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。

版权信息

查看更多关于Windows Azure读取配置文件的详细内容...

  阅读:48次