Windows Azure Platform Family of articles Catalog
This article describes the national Azure China by the century connected operation.
Attention:
As of today October 7, 2015, the Redis cache feature of the National Azure China by the century interconnect is only preview version.
Azure Redis Cache can be created with the new portal (https://portal.azure.com) at Global Azure (www.windowsazure.com).
However, this new portal is currently unavailable in Azure China, so you can now create the Redis cache service only through Azure PowerShell.
Before you begin this chapter, familiarize yourself with the basics of Azure PowerShell.
Http://www.cnblogs.com/threestone/category/616633.html
General Introduction:
1.Azure China currently offers two levels of Basic (Basic) and standard
2.Azure China currently offers C0-C6 different service types
The first section, creating an azure Redis Cache
We run PowerShell as an administrator and execute the following commands. Implement create standard type, 13GB size Redis Cache
Add-azureaccount-Environment Azurechinacloud#pop-up interface enter user name passwordSelect-azuresubscription ' [subscriptionname] ' –current#set the current subscription nameSwitch-azuremode-name Azureresourcemanagernew-azureresourcegroup-name [Yourresourcegroupname]-Location ' China East '#Create a new resource group in the East China data CenterNew-azurerediscache-resourcegroupname [Yourresourcegroupname]-name [rediscachename]-location ' China East '-sku ' Standard '-Size ' 13GB '#in the Eastern China Data Center, Redis Cache for 13GB, type Standard, SLA guaranteed
Note: For the relevant concepts of resource groups, I will explain them in more detail in a future article.
Take the author environment as an example:
-We create a redis Cache in eastern China
-We create a resource group named Leiresourcegroup
-We created the Redis name Leirediscache
The PowerShell command is:
Add-azureaccount-Environment Azurechinacloud#pop-up interface enter user name passwordSelect-azuresubscription ' Internal billing ' –current#set the current subscription nameSwitch-azuremode-name Azureresourcemanagernew-azureresourcegroup-name ' Leiresourcegroup '-Location ' China East '#Create a new resource group in the East China data CenterNew-azurerediscache-resourcegroupname ' Leiresourcegroup '-name ' leirediscache '-location ' East '-sku ' standard '-Size ' 13GB '#in the Eastern China Data Center, Redis Cache for 13GB, type Standard, SLA guaranteed
Execution results such as:
Note: False in Enablenonsslport requires the client to force SSL connections.
, PrimaryKey and Secondaykey are access keys for accessing the Redis cache.
The second section, using the Azure Redis Cache
The next step is to use this Redis cache, the author's development environment is:
1.Visual Studio Update 4
2.Azure SDK 2.7
3. For security purposes, we use SSL access
1. First we run Visual Studio as an administrator
2. Create a cloud Project to add Web Role
3. In the project file, select this Web Role and right click on NuGet, such as:
4. Download Stackexchange.redis
5. Add the following code to the Web form:
Public Partial classDefault:System.Web.UI.Page {protected voidPage_Load (Objectsender, EventArgs e) { } Private StaticLazy<connectionmultiplexer> lazyconnection =NewLazy<connectionmultiplexer> (() = { //follow the specific Redis name and Redis Key to modify the following : returnConnectionmultiplexer.connect ("[Yourrediscachename].redis.cache.chinacloudapi.cn,abortconnect=false,ssl=true,password=[yourrediscachekey] "); }); Public Staticconnectionmultiplexer Connection {Get { returnLazyconnection.value; } } protected voidBtnset_click (Objectsender, EventArgs e) {Idatabase Cache=connection.getdatabase (); //Perform Cache operations using the Cache object ...//Simple put of integral data types into the cacheCache. Stringset ("Key1", TxbSet.Text.Trim ()); } protected voidBtnget_click (Objectsender, EventArgs e) {Idatabase Cache=connection.getdatabase (); //Perform Cache operations using the Cache object ...//Simple put of integral data types into the cacheTxbget.text = cache. Stringget ("Key1"); } }
In addition, we can set the Redis cache expiration time by the following code:
Cache. Stringset ("key1""value1", Timespan.fromminutes ( ));
For more information, please refer to:https://msdn.microsoft.com/en-us/library/azure/dn690521.aspx
If the reader is wrong. NET environment, please refer to the MSDN article:https://msdn.microsoft.com/en-us/library/azure/dn690470.aspx
Part III, deleting Azure Redis Cache
Please note that once the Redis cache is created, it is charged immediately.
If we do not need to use Redis Cache, please use the following Azure PowerShell removal:
Remove-azurerediscache-name [Rediscachename]-resourcegroupname [yourresourcegroupname] -Force
Azure Redis Cache (2) Create and use Azure Redis cache