问题导读
1.如何配置Azure Power Shell?
2.Azure Power Shell如何添加账户?
3.New-AzureManagedCache -Name mycache -Location "South Central US" -Sku Basic -Memory 128MB命令的含义是什么?
配置Azure Power Shell
1.下载Azure Power shell
https://azure.microsoft.com/en-us/documentation/articles/powershell-install-configure/#Install
2. 执行Add-AzureAccount,会提示输入Azure账号密码
3. 可以看到账号成功添加
打开Azure Power Shell
1. 运行
[mw_shl_code=bash,true]Add-AzureAccount [/mw_shl_code]
(如果已经添加就不用了)
2. 运行
[mw_shl_code=bash,true]New-AzureManagedCache -Name mycache -Location "South Central US" -Sku Basic -Memory 128MB [/mw_shl_code]
进到Azure Cache页面,可以看到Cache正在创建
3. 进入https://portal.azure.com/#create/Microsoft.Cache.1.0.4创建Cache
4. 点击菜单Redis Caches 可以看到redis已经创建好了:
5. 安装nuget package
6. Console Application的代码:
[mw_shl_code=bash,true]static void Main(string[] args)
{
ConnectionMultiplexer connection =
ConnectionMultiplexer.Connect("your_domain.redis.cache.windows.net,ssl=true,password=YourPrimaryKey");
IDatabase cache = connection.GetDatabase();
// Perform cache operations using the cache object...
// Simple put of integral data types into the cache
cache.StringSet("key1", "value");
cache.StringSet("key2", 25);
// Simple get of data types from the cache
string key1 = cache.StringGet("key1");
Console.WriteLine(key1);
int key2 = (int)cache.StringGet("key2");
Console.WriteLine(key2);
Console.Read();
}[/mw_shl_code]
PrimaryKey在这里看:
将代码中的"your_domain"替换为你的DNS,password替换为你的PrimaryKey
|