现在的位置: 首页 > 综合 > 正文

windows azure常见问题处理及技巧[持续更新]

2012年06月26日 ⁄ 综合 ⁄ 共 2702字 ⁄ 字号 评论关闭

本贴记录windows azure 平台中遇到的常见问题以及解决方案和一些平常技巧。

因本人也是逐步在学习这个平台的东西,所以将持续更新,记录开发遇到的问题以及个人愚见的解决方案。有问题之处,欢迎指正。

本贴地址:http://www.cnblogs.com/ginohuo/archive/2010/09/15/1827062.html

【1】. Some Tips for table service.

【1.1】 修改最大连接数,如果需要。

Config file:  

<system.net>

<connectionManagement>

<add address = "*" maxconnection = "24" />

</connectionManagement>

</system.net>

代码: 

ServicePointManager.DefaultConnectionLimit = 24;

【1.2】 Turn off 100-continue

Config file:  

<system.net>

<settings>

<servicePointManager expect100Continue="false" />

</settings>

</system.net>

代码:  

ServicePointManager.Expect100Continue = false;

【1.3】 关闭Context跟踪,如果用不上的环境(比如都是查询)

context.MergeOption = MergeOption.NoTracking;

【1.4】 合理利用PartitionKey & RowKey

具体参见: More about “PartitionKey”&"RowKey” in windows azure table storagehttp://www.cnblogs.com/ginohuo/archive/2010/08/31/1813753.html

<2> using customer httphandler in windows azure webrole, 在webrole中使用自定义HttpHandler.

由于部署以后的webrole实际运行在IIS7上面,如果您配置的是:

<system.web>
      <httpHandlers>

将会报错,正确的配置是在<system.webServer>节点中。

<system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
    <validation validateIntegratedModeConfiguration="false"></validation>
    <handlers>
      <add path="*.do" name="KeywordsHandler" verb="GET" type="KeywordsWebRole.KeywordsHandler,KeywordsWebRole" resourceType="Unspecified" allowPathInfo="true"></add>
    </handlers>
  </system.webServer>

<3> 使用role配置文件里的storage连接信息创建client account时,使用以下代码:

CloudStorageAccount account = CloudStorageAccount.FromConfigurationSetting("DataConnectionString");

出现以下错误:

Exception: SetConfigurationSettingPublisher needs to be called before FromConfigurationSetting can be used.

解决方案:

在 public override bool OnStart()中加入以下代码:

CloudStorageAccount.SetConfigurationSettingPublisher((configName, configSetter) =>
          {
              configSetter(RoleEnvironment.GetConfigurationSettingValue(configName));

              RoleEnvironment.Changed += (anotherSender, arg) =>
              {
                  if (arg.Changes.OfType<RoleEnvironmentConfigurationSettingChange>()
                    .Any((change) => (change.ConfigurationSettingName == configName)))
                  {
                      if (!configSetter(RoleEnvironment.GetConfigurationSettingValue(configName)))
                      {
                          RoleEnvironment.RequestRecycle();
                      }
                  }
              };
          });

【4】 关于部署

【4.1】 部署必要的dll到云端(第三方的,等等),通过IntelliTrace功能查询云端服务器已经具有的程序集。

【4.2】配置正确的Storage连接字符串。发布之时注意检查用于开发和产品环境的不同Storage连接字符串。

【4.3】注意32bit的程序集。云端是64位系统,可以加载运行32bit的程序集。

在可能的情况下,尽量使用64bit的程序集。另外一些32 Bit Native Library在云端可能会加载失败,可以通过IntelliTrace来跟踪

【4.4】不要尝试运行需要管理员权限的组件。 (比如在云端写入注册表)

【4.5】配置正确的 ASP.NET providers。如果使用了Sql azure 作ASP.NET provider的存储,需要在Sql azure数据库中坐相应的初始化处理。或者使用azure table provider,或者其他…需要注意开发环境和产品环境的配置。

【4.6】尽量使用Https的Storage连接。

【上篇】
【下篇】

抱歉!评论已关闭.