Windows Azure Cloud Service (47) 修改Cloud Service时区
《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北京时间
本博-三石Blog(下文简称本博),在本博客文章结尾处右下脚未注明转载、来源、出处的作品(内容)均为本博原创,本站对于原创作品内容对其保留版权,请勿随意转载,如若真有需要的朋友可以发Mail联系我;转载本博原创作品(内容)也必须遵循“署名-非商业用途-保持一致”的创作共用协议,请务必以文字链接的形式标明或保留文章原始出处和博客作者(Lei Zhang)的信息,关于本博摄影作品请务必注意保留(www.cnblog.com/threestone)等相关水印版权信息,否则视为侵犯原创版权行为;本博谢绝商业网站转载。版权所有,禁止一切有违中华人民共和国著作权保护法及相关法律和本博(法律)声明的非法及恶意抄袭。
Windows Azure Cloud Service (47) 修改Cloud Service时区的更多相关文章
- [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 ...
- Windows Azure Affinity Groups (3) 修改虚拟网络地缘组(Affinity Group)的配置
<Windows Azure Platform 系列文章目录> 本文介绍的是国内使用世纪互联运维的Azure China 在笔者之前的文章中,我们知道现在微软官方不建议使用Affinity ...
- Windows Azure Virtual Machine (29) 修改Azure VM 数据磁盘容量
<Windows Azure Platform 系列文章目录> 当我们使用Windows Azure管理界面,创建Azure虚拟机的时候,默认挂载的磁盘是固定大小的 1.比如我创建1个Wi ...
- Windows Azure Virtual Machine (30) 修改Azure VM 的Subnet
<Windows Azure Platform 系列文章目录> 我在使用Azure Virtual Machine虚拟机的时候,常常会结合Virtual Network虚拟网络一起使用. ...
- Windows Azure Web Site (8) 设置Web Site时区
<Windows Azure Platform 系列文章目录> 许多已经使用Azure Web Site的用户已经发现了,Azure Web Site默认的系统时间是UTC时区. 比如我们 ...
- [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 ...
- 比较Windows Azure 网站(Web Sites), 云服务(Cloud Services)and 虚机(Virtual Machines)
Windows Azure提供了几个部署web应用程序的方法,比如Windows Azure网站.云服务和虚拟机.你可能无法确定哪一个最适合您的需要,或者你可能清楚的概念,比如IaaS vs PaaS ...
- [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 ...
- [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 ...
随机推荐
- 使用Roboguice依赖注入规划Android项目
前言 好久没写博客了,罪过啊-记事本里累积了不少东西,整理整理放上来. 关于依赖注入 Dependency Injection( 依赖注入)可以很好的帮助我们分离模块,降低耦合.提高可测试性.(PS: ...
- DataPager 分页样式(css)
<asp:DataPager ID="> <Fields> <asp:NextPreviousPagerField ShowFirstPageButton=&q ...
- 【星路演】DeviceOne:跨平台APP开发平台
视频 DeviceOne是一个跨Android.IOS.Windows三个平台的一个PAAS平台,主要是提供给开发者一个节省70%的成本一个开发. 我们原来想做一个APP,我们会去找三个平台的原生人员 ...
- 【吉光片羽】js横向滚动与浮动导航
1.横向滚动,这个方法是见过最简洁的了. #demo { background: #FFF; overflow: hidden; border: 1px dashed #CCC; width: 117 ...
- 免费打造自己的个人网站,免费域名、免费空间、FTP、数据库什么的,一个不能少,没钱,也可以这么任性
作为一名程序猿,拥有自己的个人网站,是一件多么有逼格的事~~至于个人网站的好处嘛?那是多的说都说不完啊~~例如我们可以放自己的作品,展示自己的风采,放自己女神的照片(女神看到后会怎么样,自己想吧,哈哈 ...
- Java多线程系列--“JUC锁”07之 LockSupport
概述 本章介绍JUC(java.util.concurrent)包中的LockSupport.内容包括:LockSupport介绍LockSupport函数列表LockSupport参考代码(基于JD ...
- 科蓝软件急招前端开发、PHP、.NET工程师
职位:前端开发 工作年限:不限 学历要求:大专 招聘人数:2 专业:不限 薪酬:面议 工作地点:浙江嘉兴.北京 岗位职责: 1.负责公司项目的UI设计: 2.负责将UI静态化 ...
- Gradle中的buildScript代码块
在编写Gradle脚本的时候,在build.gradle文件中经常看到这样的代码: build.gradle 1 2 3 4 5 6 7 8 9 buildScript { repositories ...
- JS设置cookie、读取cookie、删除cookie
JS设置cookie.读取cookie.删除cookie JS设置cookie,注意一定要path=/ ,根目录,不然其他目录可能查询不到..默认是本目录. document.cookie ...
- fir.im Weekly - 如何打造 Github 「爆款」开源项目
最近 Android 转用 Swift 的传闻甚嚣尘上,Swift 的 Github 主页上已经有了一次 merge>>「Port to Android」,让我们对 Swift 的想象又多 ...