Shaun Xu

The Sheep-Pen of the Shaun


News

logo

Shaun, the author of this blog is a semi-geek, clumsy developer, passionate speaker and incapable architect with about 10 years experience in .NET. He hopes to prove that software development is art rather than manufacturing. He's into cloud computing platform and technologies (Windows Azure, Aliyun) as well as WCF and ASP.NET MVC. Recently he's falling in love with JavaScript and Node.js.

Currently Shaun is working at IGT Technology Development (Beijing) Co., Ltd. as the architect responsible for product framework design and development.

MVP

My Stats

  • Posts - 95
  • Comments - 338
  • Trackbacks - 0

Tag Cloud


Recent Comments


Recent Posts


Archives


Post Categories



On 2nd May, 2013 Microsoft announced that the Windows Azure had been landed at China by Steven Ballmer. Currently there are two Windows Azure data centers in China, Beijing and Shanghai, which geo-replication each other.

The code name of Windows Azure in China was “Mooncake”, which is a famous food in Chinese Mid-Autumn Festival. Hence in the coming up posts when I said Mooncake, or MC, or MC Azure, normally it means the Windows Azure China.

It was also announced that from 6th June, the public beta registration will be opened and till now within 24 hours it had received thousands of requests. In the coming few weeks Microsoft will evaluate these requests and start to ship the accounts. This means, developers, partners and customers mainly in China (and in worldwide as well) would be able to develop, deploy and test their applications and services on Windows Azure China.

If you are familiar with Windows Azure platform, you will find the services and functionalities are almost same between worldwide Azure and Azure China. But there are something different when developing application against MC rather than worldwide Azure (a.k.a. WW Azure). Most of them are endpoints of vary azure services such as Cloud Service DNS name, SQL Database endpoint, Storage endpoints and Management API endpoint, etc.. In this post I’d like talk about these different so that we can develop and migrate application on MC Azure more smoothly.

This post will only focus on the different points between worldwide Azure and MC Azure. If you are new to windows azure platform, I highly recommended you to have a look on the documents on MC Azure and worldwide Azure here and here, before deeply read this post as I will NOT describe the functions/features in Azure.

Portal and Services

The first different point is the Windows Azure Portal. The WW Azure portal is http://www.windowsazure.com/ regardless which data center it’s. But the portal of MC is http://www.windowsazure.cn/, and it only for Windows Azure China.

image 

Since the portal is deferent, the develop portal is changed to https://manage.windowsazure.cn/ as well, where we can login and manage our azure services.

Once logged in, we will find that currently there are seven services provided in MC Azure, which are Virtual Machine, Cloud Service, SQL Database, Storage, Virtual Network, Service Bus and Active Directory. Other services will be available before the MC Azure was GA, such as Media Service, Mobile Service, HDInsight, SQL Reporting, etc..

image

First Cloud Service on MC

Now let’s create a new Cloud Service with one ASP.NET MVC 4 Web Role and deploy to MC. First of all we need to create the project in Visual Studio 2012 with Windows Azure SDK 2.0. As you know, we can deploy our project to azure by uploading the package, but in this post I’d like to demonstrate how to deploy it in MC Azure through Visual Studio.

Since we want to deploy the project from Visual Studio, we need to upload a new certificate to the portal for management. This is same as what we did for WW Azure. Clicked “SETTING” from the left hand side navigate bar and upload our management certificate. Then back to Visual Studio, click the Deploy context menu item and here we need to add a new subscription for our MC account. Click “Manage”.

imageCreate a new subscription and select the certificate I had uploaded through the management portal, paste the subscription ID and the name in the dialog. Then we need to change the service management URL, since it’s different between WW Azure and MC Azure. If you are working on MC Azure, the URL of Windows Azure Management API should be https://management.core.chinacloudapi.cn.

image

Then we can select the Cloud Services we wanted to deploy in this subscription, the environment (Production or Staging), build configuration, service configuration (Cloud or Local) and the storage we will upload our package to and then press Publish.

image If the management URL we specified was correct we can see Visual Studio started to upload our project to MC Azure and it should be ready after few minutes.

image Below is the MC portal after I deployed my project. As you can see it’s same as what we saw at WW Azure.

imageBelow is my first cloud service running on MC Azure. The public URL was http://shx.chinacloudapp.cn/. This is another different point in MC Azure, the cloud service DNS name is *.chinacloudapp.cn, while in WW Azure is *.cloudapp.com.

imageOnce it had been deployed we can review the status of this service through Visual Studio. Open the Server Explorer window and expand the Windows Azure Compute we can see our cloud service had been listed there with one instance running under the production environment.

image

Storage

Since we had created a new subscription information in Visual Studio in previous step, we can now easily manage our storage account through Visual Studio as well. Open the Server Explorer and add a new storage account.

image

In the popup windows we will select the subscription we had just added, then Visual Studio will populate all storage account under this subscription. Once we select the account we want to manage the endpoints will be shown automatically at the bottom of this windows. As you can see, the storage endpoints were *.blob.core.chinacloudapi.cn, *.queue.core.chinacloudapi.cn, *.table.core.chinacloudapi.cn, while in WW Azure the storage endpoints are *.blob.core.windows.net, *.queue.core.windows.net, *.table.core.windows.net.

image

If we added this account in Visual Studio Server Explorer we would be able to manage it in the same way as what we did for WW Azure. The screenshot below shows when I created a blob container and uploaded some pictures into my storage account located in MC Azure Beijing.

image Next, let’s add some code to use the storage service I created. For example, I will add some codes in my ASP.NET MVC website to list all blobs in my container. This is not a huge work but will show you what needs to be changed when using MC Azure. First I need to specify the storage account connection string in the cloud service setting window. As we had added our MC Azure subscription we can select the storage account we want by selecting the subscription and storage name.

image Alternatively you can specify the storage endpoints manually. Just need to pay attention that we must select “custom endpoints” and specify the blob, table and queue endpoints for MC Azure.

image That’s all. Now we can use the Azure SDK to operate our storage service same as what we did against WW Azure. Below the code I created to retrieve all blobs from my container.

   1: public ActionResult Index()
   2: {
   3:     ViewBag.Message = "Modify this template to jump-start your ASP.NET MVC application.";
   4:  
   5:     var connectionString = Microsoft.WindowsAzure.CloudConfigurationManager.GetSetting("StorageConnection");
   6:     var account = Microsoft.WindowsAzure.Storage.CloudStorageAccount.Parse(connectionString);
   7:     var client = account.CreateCloudBlobClient();
   8:     var container = client.GetContainerReference("samples");
   9:     var blobs = container.ListBlobs().Select(b => b.Uri.AbsoluteUri).ToList();
  10:  
  11:     ViewBag.Blobs = blobs;
  12:  
  13:     return View();
  14: }

And this is the website once I deployed to MC Azure which lists the blobs in my storage account in the same datacenter (Beijing).

image

SQL Database

Windows Azure SQL Database (a.k.a. WASD) is another resource we always use when building application. The WASD in MC Azure has a different base address, *.database.chinacloudapi.cn, the WW Azure WASD base address is *.database.windows.net. But the connection string format and login format are all the same.

For example, if I created a new WASD and updated its firewall setting then I can connect to this database located in MC Azure through any SQL Server management tools. Below is the WASD connection string I created in MC. The format is same but only different base address.

 image

We can use SQL Server Management Studio (SSMS) to manage our WASD from local machine, same as what we did for WW Azure.

image Let’s execute the script below to create a new table with some data into this database.

   1: /****** Object:  Table [dbo].[Resource]    Script Date: 9/4/2012 3:47:14 PM ******/
   2: SET ANSI_NULLS ON
   3: GO
   4: SET QUOTED_IDENTIFIER ON
   5: GO
   6: CREATE TABLE [dbo].[Resource](
   7:     [Key] [varchar](256) NOT NULL,
   8:     [Culture] [varchar](8) NOT NULL,
   9:     [Value] [nvarchar](4000) NOT NULL,
  10:  CONSTRAINT [PK_Resource] PRIMARY KEY CLUSTERED 
  11: (
  12:     [Key] ASC,
  13:     [Culture] ASC
  14: )WITH (STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF)
  15: )
  16:  
  17: GO
  18: INSERT [dbo].[Resource] ([Key], [Culture], [Value]) VALUES (N'Controller_HomeAbout_Message', N'en-US', N'Your app description page.')
  19: GO
  20: INSERT [dbo].[Resource] ([Key], [Culture], [Value]) VALUES (N'Controller_HomeAbout_Message', N'zh-CN', N'你的关于页面。')
  21: GO
  22: INSERT [dbo].[Resource] ([Key], [Culture], [Value]) VALUES (N'Controller_HomeContact_Message', N'en-US', N'Your contact page.')
  23: GO
  24: INSERT [dbo].[Resource] ([Key], [Culture], [Value]) VALUES (N'Controller_HomeContact_Message', N'zh-CN', N'你的联系信息页面。')
  25: GO
  26: INSERT [dbo].[Resource] ([Key], [Culture], [Value]) VALUES (N'Controller_HomeIndex_Message', N'en-US', N'Modify this template to jump-start your ASP.NET MVC application.')
  27: GO
  28: INSERT [dbo].[Resource] ([Key], [Culture], [Value]) VALUES (N'Controller_HomeIndex_Message', N'zh-CN', N'修改次模板页,快速开始您的ASP.NET MVC应用程序。')
  29: GO
  30: INSERT [dbo].[Resource] ([Key], [Culture], [Value]) VALUES (N'Model_AccountModels_LoginModel_Password_Display', N'en-US', N'Password')
  31: GO
  32: INSERT [dbo].[Resource] ([Key], [Culture], [Value]) VALUES (N'Model_AccountModels_LoginModel_Password_Display', N'zh-CN', N'密码')
  33: GO
  34: INSERT [dbo].[Resource] ([Key], [Culture], [Value]) VALUES (N'Model_AccountModels_LoginModel_Password_Required', N'en-US', N'Please input {0}.')
  35: GO
  36: INSERT [dbo].[Resource] ([Key], [Culture], [Value]) VALUES (N'Model_AccountModels_LoginModel_Password_Required', N'zh-CN', N'请输入{0}。')
  37: GO
  38: INSERT [dbo].[Resource] ([Key], [Culture], [Value]) VALUES (N'Model_AccountModels_LoginModel_RememberMe_Display', N'en-US', N'Remember me?')
  39: GO
  40: INSERT [dbo].[Resource] ([Key], [Culture], [Value]) VALUES (N'Model_AccountModels_LoginModel_RememberMe_Display', N'zh-CN', N'记住登录状态?')
  41: GO
  42: INSERT [dbo].[Resource] ([Key], [Culture], [Value]) VALUES (N'Model_AccountModels_LoginModel_UserName_Display', N'en-US', N'User Name')
  43: GO
  44: INSERT [dbo].[Resource] ([Key], [Culture], [Value]) VALUES (N'Model_AccountModels_LoginModel_UserName_Display', N'zh-CN', N'用户名')
  45: GO
  46: INSERT [dbo].[Resource] ([Key], [Culture], [Value]) VALUES (N'Model_AccountModels_LoginModel_UserName_Required', N'en-US', N'Please input the {0}.')
  47: GO
  48: INSERT [dbo].[Resource] ([Key], [Culture], [Value]) VALUES (N'Model_AccountModels_LoginModel_UserName_Required', N'zh-CN', N'请输入{0}。')
  49: GO
  50: INSERT [dbo].[Resource] ([Key], [Culture], [Value]) VALUES (N'Model_AccountModels_RegisterModel_ConfirmPassword_Compare', N'en-US', N'The password and confirmation password do not match.')
  51: GO
  52: INSERT [dbo].[Resource] ([Key], [Culture], [Value]) VALUES (N'Model_AccountModels_RegisterModel_ConfirmPassword_Compare', N'zh-CN', N'两次输入的密码不一致。')
  53: GO
  54: INSERT [dbo].[Resource] ([Key], [Culture], [Value]) VALUES (N'Model_AccountModels_RegisterModel_ConfirmPassword_Display', N'en-US', N'Confirm password')
  55: GO
  56: INSERT [dbo].[Resource] ([Key], [Culture], [Value]) VALUES (N'Model_AccountModels_RegisterModel_ConfirmPassword_Display', N'zh-CN', N'再次输入密码')
  57: GO
  58: INSERT [dbo].[Resource] ([Key], [Culture], [Value]) VALUES (N'Model_AccountModels_RegisterModel_Password_StringLength', N'en-US', N'The {0} must be at least {2} characters long.')
  59: GO
  60: INSERT [dbo].[Resource] ([Key], [Culture], [Value]) VALUES (N'Model_AccountModels_RegisterModel_Password_StringLength', N'zh-CN', N'{0}长度不足。')
  61: GO
  62: INSERT [dbo].[Resource] ([Key], [Culture], [Value]) VALUES (N'View_AccountLogin_ExtenalAccount', N'en-US', N'Use another service to log in.')
  63: GO
  64: INSERT [dbo].[Resource] ([Key], [Culture], [Value]) VALUES (N'View_AccountLogin_ExtenalAccount', N'zh-CN', N'使用其他服务登录。')
  65: GO
  66: INSERT [dbo].[Resource] ([Key], [Culture], [Value]) VALUES (N'View_AccountLogin_LocalAccount', N'en-US', N'Use a local account to log in.')
  67: GO
  68: INSERT [dbo].[Resource] ([Key], [Culture], [Value]) VALUES (N'View_AccountLogin_LocalAccount', N'zh-CN', N'使用本地帐户登录。')
  69: GO
  70: INSERT [dbo].[Resource] ([Key], [Culture], [Value]) VALUES (N'View_AccountLogin_RegisterIfNoAccount', N'en-US', N'{0} if you don''t have an account.')
  71: GO
  72: INSERT [dbo].[Resource] ([Key], [Culture], [Value]) VALUES (N'View_AccountLogin_RegisterIfNoAccount', N'zh-CN', N'如果没有账户,请{0}。')
  73: GO
  74: INSERT [dbo].[Resource] ([Key], [Culture], [Value]) VALUES (N'View_AccountRegister_Message', N'en-US', N'Create a new account.')
  75: GO
  76: INSERT [dbo].[Resource] ([Key], [Culture], [Value]) VALUES (N'View_AccountRegister_Message', N'zh-CN', N'创建一个新用户。')
  77: GO
  78: INSERT [dbo].[Resource] ([Key], [Culture], [Value]) VALUES (N'View_ExternalLoginsListPartial_MessageInfo', N'en-US', N'There are no external authentication services configured. See <a href="http://go.microsoft.com/fwlink/?LinkId=252166">this article</a> for details on setting up this ASP.NET application to support logging in via external services.')
  79: GO
  80: INSERT [dbo].[Resource] ([Key], [Culture], [Value]) VALUES (N'View_ExternalLoginsListPartial_MessageInfo', N'zh-CN', N'没有配置任何第三方认证服务。关于如何在ASP.NET应用程序中配置和使用第三方认证服务,请访问此<a href="http://go.microsoft.com/fwlink/?LinkId=252166">文章</a>。')
  81: GO
  82: INSERT [dbo].[Resource] ([Key], [Culture], [Value]) VALUES (N'View_ExternalLoginsListPartial_SocialLoginList', N'en-US', N'Log in using another service')
  83: GO
  84: INSERT [dbo].[Resource] ([Key], [Culture], [Value]) VALUES (N'View_ExternalLoginsListPartial_SocialLoginList', N'zh-CN', N'用其它认证服务登录')
  85: GO
  86: INSERT [dbo].[Resource] ([Key], [Culture], [Value]) VALUES (N'View_HomeAbout_Title', N'en-US', N'About')
  87: GO
  88: INSERT [dbo].[Resource] ([Key], [Culture], [Value]) VALUES (N'View_HomeAbout_Title', N'zh-CN', N'关于')
  89: GO
  90: INSERT [dbo].[Resource] ([Key], [Culture], [Value]) VALUES (N'View_HomeContact_Title', N'en-US', N'Contact')
  91: GO
  92: INSERT [dbo].[Resource] ([Key], [Culture], [Value]) VALUES (N'View_HomeContact_Title', N'zh-CN', N'联系信息')
  93: GO
  94: INSERT [dbo].[Resource] ([Key], [Culture], [Value]) VALUES (N'View_HomeIndex_Title', N'en-US', N'Home Page')
  95: GO
  96: INSERT [dbo].[Resource] ([Key], [Culture], [Value]) VALUES (N'View_HomeIndex_Title', N'zh-CN', N'首页')
  97: GO
  98: INSERT [dbo].[Resource] ([Key], [Culture], [Value]) VALUES (N'View_HomIndex_Featured', N'en-US', N'To learn more about ASP.NET MVC visit <a href="http://asp.net/mvc" title="ASP.NET MVC Website">http://asp.net/mvc</a>. The page features <mark>videos, tutorials, and samples</mark> to help you get the most from ASP.NET MVC. If you have any questions about ASP.NET MVC visit <a href="http://forums.asp.net/1146.aspx/1?MVC" title="ASP.NET MVC Forum">our forums</a>.')
  99: GO
 100: INSERT [dbo].[Resource] ([Key], [Culture], [Value]) VALUES (N'View_HomIndex_Featured', N'zh-CN', N'要了解更多关于ASP.NET MVC的信息请访问<a href="http://asp.net/mvc" title="ASP.NET MVC网站">http://asp.net/mvc</a>。该页面提供<mark>视频,教程和例子</mark>,以帮助你获得对全面的ASP.NET MVC资讯。如果您有任何关于ASP.NET MVC的问题,请访问我们的<a href="http://forums.asp.net/1146.aspx/1?MVC" title="ASP.NET MVC论坛">论坛</a>。')
 101: GO
 102: INSERT [dbo].[Resource] ([Key], [Culture], [Value]) VALUES (N'View_HomIndex_Suggest', N'en-US', N'We suggest the following:')
 103: GO
 104: INSERT [dbo].[Resource] ([Key], [Culture], [Value]) VALUES (N'View_HomIndex_Suggest', N'zh-CN', N'我们建议:')
 105: GO
 106: INSERT [dbo].[Resource] ([Key], [Culture], [Value]) VALUES (N'View_HomIndex_Suggest_1_Title', N'en-US', N'Getting Started')
 107: GO
 108: INSERT [dbo].[Resource] ([Key], [Culture], [Value]) VALUES (N'View_HomIndex_Suggest_1_Title', N'zh-CN', N'入门')
 109: GO
 110: INSERT [dbo].[Resource] ([Key], [Culture], [Value]) VALUES (N'View_HomIndex_Suggest_1_Val', N'en-US', N'ASP.NET MVC gives you a powerful, patterns-based way to build dynamic websites that enables a clean separation of concerns and that gives you full control over markup for enjoyable, agile development. ASP.NET MVC includes many features that enable fast, TDD-friendly development for creating sophisticated applications that use the latest web standards. <a href="http://go.microsoft.com/fwlink/?LinkId=245151">Learn more...</a>')
 111: GO
 112: INSERT [dbo].[Resource] ([Key], [Culture], [Value]) VALUES (N'View_HomIndex_Suggest_1_Val', N'zh-CN', N'ASP.NET MVC为您提供了一个强大的、基于模式的方式来构建动态网站,使一个干净的关注点分离,让您愉快,敏捷开发的完全控制权的标记。 ASP.NET MVC包含了许多功能,使快速创建复杂的应用程序,使用最新的Web标准,TDD友好的开发。<a href="http://go.microsoft.com/fwlink/?LinkId=245151">了解更多…</a>')
 113: GO
 114: INSERT [dbo].[Resource] ([Key], [Culture], [Value]) VALUES (N'View_HomIndex_Suggest_2_Title', N'en-US', N'Add NuGet packages and jump-start your coding')
 115: GO
 116: INSERT [dbo].[Resource] ([Key], [Culture], [Value]) VALUES (N'View_HomIndex_Suggest_2_Title', N'zh-CN', N'添加NuGet软件包,快速开始编码')
 117: GO
 118: INSERT [dbo].[Resource] ([Key], [Culture], [Value]) VALUES (N'View_HomIndex_Suggest_2_Val', N'en-US', N'NuGet makes it easy to install and update free libraries and tools. <a href="http://go.microsoft.com/fwlink/?LinkId=245153">Learn more...</a>')
 119: GO
 120: INSERT [dbo].[Resource] ([Key], [Culture], [Value]) VALUES (N'View_HomIndex_Suggest_2_Val', N'zh-CN', N'NuGet让安装和更新免费的代码库和工具变得异常容易。<a href="http://go.microsoft.com/fwlink/?LinkId=245153">了解更多…</a>')
 121: GO
 122: INSERT [dbo].[Resource] ([Key], [Culture], [Value]) VALUES (N'View_HomIndex_Suggest_3_Title', N'en-US', N'Find Web Hosting')
 123: GO
 124: INSERT [dbo].[Resource] ([Key], [Culture], [Value]) VALUES (N'View_HomIndex_Suggest_3_Title', N'zh-CN', N'寻找虚拟主机')
 125: GO
 126: INSERT [dbo].[Resource] ([Key], [Culture], [Value]) VALUES (N'View_HomIndex_Suggest_3_Val', N'en-US', N'You can easily find a web hosting company that offers the right mix of features and price for your applications. <a href="http://go.microsoft.com/fwlink/?LinkId=245157">Learn more...</a>')
 127: GO
 128: INSERT [dbo].[Resource] ([Key], [Culture], [Value]) VALUES (N'View_HomIndex_Suggest_3_Val', N'zh-CN', N'您可以很容易地找到一个Web托管公司,提供为您的应用程序的功能和价格的最佳组合。<a href="http://go.microsoft.com/fwlink/?LinkId=245157">了解更多…</a>')
 129: GO
 130: INSERT [dbo].[Resource] ([Key], [Culture], [Value]) VALUES (N'View_Layout_LogoHere', N'en-US', N'your logo here')
 131: GO
 132: INSERT [dbo].[Resource] ([Key], [Culture], [Value]) VALUES (N'View_Layout_LogoHere', N'zh-CN', N'在这儿放置图标')
 133: GO
 134: INSERT [dbo].[Resource] ([Key], [Culture], [Value]) VALUES (N'View_Layout_Title', N'en-US', N'My ASP.NET MVC Application')
 135: GO
 136: INSERT [dbo].[Resource] ([Key], [Culture], [Value]) VALUES (N'View_Layout_Title', N'zh-CN', N'我的ASP.NET MVC应用程序')
 137: GO
 138: INSERT [dbo].[Resource] ([Key], [Culture], [Value]) VALUES (N'View_LoginPartial_Login', N'en-US', N'Log in')
 139: GO
 140: INSERT [dbo].[Resource] ([Key], [Culture], [Value]) VALUES (N'View_LoginPartial_Login', N'zh-CN', N'登录')
 141: GO
 142: INSERT [dbo].[Resource] ([Key], [Culture], [Value]) VALUES (N'View_LoginPartial_Logoff', N'en-US', N'Log off')
 143: GO
 144: INSERT [dbo].[Resource] ([Key], [Culture], [Value]) VALUES (N'View_LoginPartial_Logoff', N'zh-CN', N'登出')
 145: GO
 146: INSERT [dbo].[Resource] ([Key], [Culture], [Value]) VALUES (N'View_LoginPartial_Register', N'en-US', N'Register')
 147: GO
 148: INSERT [dbo].[Resource] ([Key], [Culture], [Value]) VALUES (N'View_LoginPartial_Register', N'zh-CN', N'注册')
 149: GO
 150: INSERT [dbo].[Resource] ([Key], [Culture], [Value]) VALUES (N'View_PageName_About', N'en-US', N'About')
 151: GO
 152: INSERT [dbo].[Resource] ([Key], [Culture], [Value]) VALUES (N'View_PageName_About', N'zh-CN', N'关于')
 153: GO
 154: INSERT [dbo].[Resource] ([Key], [Culture], [Value]) VALUES (N'View_PageName_Contact', N'en-US', N'Contact')
 155: GO
 156: INSERT [dbo].[Resource] ([Key], [Culture], [Value]) VALUES (N'View_PageName_Contact', N'zh-CN', N'联系信息')
 157: GO
 158: INSERT [dbo].[Resource] ([Key], [Culture], [Value]) VALUES (N'View_PageName_Home', N'en-US', N'Home')
 159: GO
 160: INSERT [dbo].[Resource] ([Key], [Culture], [Value]) VALUES (N'View_PageName_Home', N'zh-CN', N'首页')
 161: GO

Then back to Visual Studio to add some codes to retrieve data from our WASD on MC Azure. First of all we need to specify the WASD connection string. Copy the connection string from MC Azure portal and add into our cloud service configuration through Visual Studio.

image Next, paste code into HomeController.cs so that it will retrieve all data from our database on the home page.

   1: public ActionResult Index()
   2: {
   3:     ViewBag.Message = "Modify this template to jump-start your ASP.NET MVC application.";
   4:  
   5:     // retrieve blobs from storage
   6:     var connectionString = Microsoft.WindowsAzure.CloudConfigurationManager.GetSetting("StorageConnection");
   7:     var account = Microsoft.WindowsAzure.Storage.CloudStorageAccount.Parse(connectionString);
   8:     var client = account.CreateCloudBlobClient();
   9:     var container = client.GetContainerReference("samples");
  10:     var blobs = container.ListBlobs().Select(b => b.Uri.AbsoluteUri).ToList();
  11:     ViewBag.Blobs = blobs;
  12:  
  13:     // retrieve records from sql database
  14:     var records = new List<KeyValuePair<string, string>>();
  15:     using (var conn = new SqlConnection(Microsoft.WindowsAzure.CloudConfigurationManager.GetSetting("SqlConnection")))
  16:     {
  17:         var cmd = conn.CreateCommand();
  18:         cmd.CommandText = "SELECT [Key], [Value] FROM [RESOURCE] ORDER BY [Key]";
  19:         conn.Open();
  20:         using (var reader = cmd.ExecuteReader())
  21:         {
  22:             while (reader.Read())
  23:             {
  24:                 records.Add(new KeyValuePair<string, string>((string)reader["Key"], (string)reader["Value"]));
  25:             }
  26:         }
  27:     }
  28:     ViewBag.Records = records;
  29:  
  30:     return View();
  31: }

Then publish the application to MC Azure, below is the result of the home page.

image

Summary

From the functionality perspective, Windows Azure China (MC Azure) is exactly same as the existing Windows Azure in worldwide (WW Azure). But MC Azure has some different endpoints. When developing against MC, we need to pay attention to the endpoints listed below.

Service Type Windows Azure Worldwide Windows Azure China
General *.windows.net *.chinacloudapi.cn
Compute *.cloudapp.net *.chinacloudapp.cn
Storage *.blob.core.windows.net
*.queue.core.windows.net
*.table.core.windows.net
*.blob.core.chinacloudapi.cn
*.queue.core.chinacloudapi.cn
*.table.core.chinacloudapi.cn
SQL Database *.database.windows.net *.database.chinacloudapi.cn
Management API https://management.core.windows.net https://management.core.chinacloudapi.cn
Portal http://manage.windowsazure.com http://manage.windows.cn

Some of them are easy to remember, but some may related with other function. For example, for diagnostic monitor and cache role, it needs to specify a storage account which should use MC storage endpoints. And some 3rd party component such as the Enterprise Library AutoScaling Application Block relies on the Management API, we need to check that the reference endpoint is correct to MC Azure. Some management tools, for example the Windows Azure Storage Explorer, we are willing them to add the functionality to specify the endpoints manually.

After all, MC Azure is the first worldwide public cloud computing landed in China and it’s also the first time Microsoft running Windows Azure with different endpoints and with a operating partner. It needs time to make the service getting better and it should be true that when Windows Azure China GA all services running on Worldwide Azure should be available on Windows Azure China, even though with some different endpoints but much better bandwidth and network connectivity to all developers and customers in China.

 

Hope this helps,

Shaun

All documents and related graphics, codes are provided "AS IS" without warranty of any kind.
Copyright © Shaun Ziyan Xu. This work is licensed under the Creative Commons License.

Comments

Gravatar # re: Tips an Tricks of Developing on Windows Azure China
Posted by web development in chennai on 8/2/2013 2:43 PM
I have got a relevant information based on my queries. Thanks for the wonderful postings.
Gravatar # curriculum vitae examples
Posted by surprisesolutions on 9/24/2013 6:15 PM
slides are good!
this blog is info!!
thanks!!!
Gravatar # re: Tips an Tricks of Developing on Windows Azure China
Posted by xx on 4/15/2014 10:39 AM
Very good.
It still works in vs 2013(en) for MC Azure.
Post A Comment
Title:
Name:
Email:
Comment:
Verification: