《Windows Azure Platform 系列文章目录

  本文介绍内容适合于Azure Global和Azure China

  我们在使用Cloud Service的时候,会发现默认的Cloud Service是UTC时区。

  在很多时候,我们的应用程序使用的时区是UTC+8时区,也就是北京时间。

  遇到这样的问题,我们传统的做法是修改aspx.cs代码,把UTC时区修改为UTC+8时区。

  但是这样做费时费力,有没有更好的解决方法呢?

  

  其实,我们可以在Azure Startup Task中,执行CMD命令,修改系统当前的时区。

  在开始本章内容之前,请读者参考笔者之前的文档:

  Windows Azure Cloud Service (24) 使用Startup注册COM组件(上)

      Windows Azure Cloud Service (25) 使用Startup注册COM组件(下)

  可以对Azure Startup Task有一个基本的认识。

  我们本章内容需要使用到的工具有:

  1.Azure Visual Studio 2013 Update4

  2.安装Azure SDK

  3.Azure China账户

  接下来开始本章的内容。

  1.首先我们以管理员身份,运行Visual Studio 2013。

  2.创建一个新的Cloud Project,命名为LeiCloudServiceTimeZone,并添加Web Role。图略

  3.在Project的根目录下,创建一个新的文件,重命名为changetimezone.cmd

  4.在Cloud Project里,点击changetimezone.cmd,选择右键属性,Copy to Output Directory选择Copy always

  

  5.在changetimezone.cmd,设置如下逻辑:

 tzutil /s "China Standard Time" 

  6.修改ServiceDefinition.csdef,修改Startup节点,让Cloud Service项目启动的时候,执行changetimezone.cmd命令。如下图:

  

  7.最后我们在aspx页面中,输出当前的系统时间:

Label1.Text = DateTime.Now.ToString();

  8.最后我们部署Cloud Service,显示如下:

  

  可以看到部署的当前时间,就是UTC+8北京时间

  参考资料:http://social.technet.microsoft.com/wiki/contents/articles/29554.change-time-zone-of-azure-role-instances-vm-s.aspx

  本博-三石Blog(下文简称本博),在本博客文章结尾处右下脚未注明转载、来源、出处的作品(内容)均为本博原创,本站对于原创作品内容对其保留版权,请勿随意转载,如若真有需要的朋友可以发Mail联系我;转载本博原创作品(内容)也必须遵循“署名-非商业用途-保持一致”的创作共用协议,请务必以文字链接的形式标明或保留文章原始出处和博客作者(Lei Zhang)的信息,关于本博摄影作品请务必注意保留(www.cnblog.com/threestone)等相关水印版权信息,否则视为侵犯原创版权行为;本博谢绝商业网站转载。版权所有,禁止一切有违中华人民共和国著作权保护法及相关法律和本博(法律)声明的非法及恶意抄袭。

Windows Azure Cloud Service (47) 修改Cloud Service时区的更多相关文章

  1. [Windows Azure] Create and use a reporting service in Windows Azure SQL Reporting

    Create and use a reporting service in Windows Azure SQL Reporting In this tutorial you will learn ab ...

  2. Windows Azure Affinity Groups (3) 修改虚拟网络地缘组(Affinity Group)的配置

    <Windows Azure Platform 系列文章目录> 本文介绍的是国内使用世纪互联运维的Azure China 在笔者之前的文章中,我们知道现在微软官方不建议使用Affinity ...

  3. Windows Azure Virtual Machine (29) 修改Azure VM 数据磁盘容量

    <Windows Azure Platform 系列文章目录> 当我们使用Windows Azure管理界面,创建Azure虚拟机的时候,默认挂载的磁盘是固定大小的 1.比如我创建1个Wi ...

  4. Windows Azure Virtual Machine (30) 修改Azure VM 的Subnet

    <Windows Azure Platform 系列文章目录> 我在使用Azure Virtual Machine虚拟机的时候,常常会结合Virtual Network虚拟网络一起使用. ...

  5. Windows Azure Web Site (8) 设置Web Site时区

    <Windows Azure Platform 系列文章目录> 许多已经使用Azure Web Site的用户已经发现了,Azure Web Site默认的系统时间是UTC时区. 比如我们 ...

  6. [Windows Azure] What is a cloud service?

    What is a cloud service? When you create an application and run it in Windows Azure, the code and co ...

  7. 比较Windows Azure 网站(Web Sites), 云服务(Cloud Services)and 虚机(Virtual Machines)

    Windows Azure提供了几个部署web应用程序的方法,比如Windows Azure网站.云服务和虚拟机.你可能无法确定哪一个最适合您的需要,或者你可能清楚的概念,比如IaaS vs PaaS ...

  8. [Windows Azure] How to use the Queue Storage Service

    How to use the Queue Storage Service version 1.7 version 2.0 This guide will show you how to perform ...

  9. [Windows Azure] Building the web role for the Windows Azure Email Service application - 3 of 5

    Building the web role for the Windows Azure Email Service application - 3 of 5. This is the third tu ...

随机推荐

  1. python string intern

    python  字符串是不可变的. 字符串pool会对 t "looklike" Python identifiers 字符串做intern缓存.

  2. savepoint原理

    保存点 在MySQL中, 保存点SAVEPOINT属于事务控制处理部分.利用SAVEPOINT可以回滚指定部分事务,从而使事务处理更加灵活和精细.SAVEPOINT相关的SQL语句如下 SAVEPOI ...

  3. mongoDB研究笔记:写关注

    对于某些应用程序来说,写关注是重要的.它能判断哪些写操作成功写入了,哪些失败了,对于失败的操作,驱动程序能返回错误,由应用程序决定怎么处理.如果没有写关注,应用程序发送一个写操作到socket后,就不 ...

  4. 【Bugly干货】Android性能优化典范之多线程篇

    本文涉及的内容有:多线程并发的性能问题,介绍了 AsyncTask,HandlerThread,IntentService 与 ThreadPool 分别适合的使用场景以及各自的使用注意事项,这是一篇 ...

  5. 防止开发人员获取到敏感数据(SQL Server的数据加密简介)

    背景 有时候,我们还真的会碰到这样的需求:防止开发人员获取到敏感数据.也许你觉得很简单,把开发和运营分开不就可以了吗?是的,如果公司有专门的运营团队的话,但对于很多小公司来说,几个人的开发团队就兼顾了 ...

  6. 使用Struts 拦截namespace进行权限控制

    有时候我需要在几个包下都需要进行同一个权限控制.如在购物网站中,我们需要进入个人中心.下订单.评价商品等等都需要进行登录权限控制,但是这几个模块并不是位于同一个package下.Struts提供的拦截 ...

  7. 记一个界面刷新相关的Bug

    今天遇到一个比较有意思的bug, 这里简单记录下. Bug的症状是通过拖拉边框把我们客户端主窗口拖小之后,再最大化,会发现窗口显示有问题, 看起来像是刷新问题, 有些地方显示的不对了. 这里要说明的是 ...

  8. Asp.net MVC 中Ajax的使用 [分享]

    文章转自 http://www.huiyoumi.wang/upload/forum.php?mod=viewthread&tid=75&extra= Asp.net MVC 抛弃了A ...

  9. linux shell program summary

    from:Sep 23 2016 mathematical operation: floating number,bc calculator: we can also use bc in shell ...

  10. Redis中统计各种数据大小的方法

    转载于:http://www.itxuexiwang.com/a/shujukujishu/redis/2016/0216/125.html?1455853369如果 MySQL 数据库比较大的话,我 ...