public void CreateOrUpdate_EmptyJSONFromCSM() { string responseString = (@"{}"); RedisManagementClient client = Utility.GetRedisManagementClient(responseString, null, HttpStatusCode.OK); RedisCreateOrUpdateResponse response = client.Redis.CreateOrUpdate(resourceGroupName: "resource-group", name: "cachename", parameters: new RedisCreateOrUpdateParameters { Location = "North Europe", Properties = new RedisProperties { RedisVersion = "2.8", Sku = new Sku() { Name = SkuName.Basic, Family = SkuFamily.C, Capacity = 1 } } }); Assert.Null(response.RequestId); Assert.Null(response.Resource.Id); Assert.Null(response.Resource.Location); Assert.Null(response.Resource.Name); Assert.Null(response.Resource.Type); Assert.Null(response.Resource.Properties); }
public RedisCreateOrUpdateResponse CreateOrUpdateCache(string resourceGroupName, string cacheName, string location, string redisVersion, string skuFamily, int skuCapacity, string skuName, Hashtable redisConfiguration, bool?enableNonSslPort) { RedisCreateOrUpdateParameters parameters = new RedisCreateOrUpdateParameters { Location = location, Properties = new RedisProperties { RedisVersion = redisVersion, Sku = new Sku() { Name = skuName, Family = skuFamily, Capacity = skuCapacity } } }; if (redisConfiguration != null) { parameters.Properties.RedisConfiguration = new Dictionary <string, string>(); foreach (object key in redisConfiguration.Keys) { parameters.Properties.RedisConfiguration.Add(key.ToString(), redisConfiguration[key].ToString()); } } if (enableNonSslPort.HasValue) { parameters.Properties.EnableNonSslPort = enableNonSslPort.Value; } RedisCreateOrUpdateResponse response = _client.Redis.CreateOrUpdate(resourceGroupName: resourceGroupName, name: cacheName, parameters: parameters); return(response); }
public RedisCreateOrUpdateResponse CreateOrUpdateCache(string resourceGroupName, string cacheName, string location, string redisVersion, string skuFamily, int skuCapacity, string skuName, string maxMemoryPolicy, bool?enableNonSslPort) { RedisCreateOrUpdateParameters parameters = new RedisCreateOrUpdateParameters { Location = location, Properties = new RedisProperties { RedisVersion = redisVersion, Sku = new Sku() { Name = skuName, Family = skuFamily, Capacity = skuCapacity } } }; if (!string.IsNullOrEmpty(maxMemoryPolicy)) { parameters.Properties.MaxMemoryPolicy = maxMemoryPolicy; } if (enableNonSslPort.HasValue) { parameters.Properties.EnableNonSslPort = enableNonSslPort.Value; } RedisCreateOrUpdateResponse response = _client.Redis.CreateOrUpdate(resourceGroupName: resourceGroupName, name: cacheName, parameters: parameters); return(response); }
public RedisCacheAttributesWithAccessKeys(RedisCreateOrUpdateResponse cache, string resourceGroupName) { Id = cache.Resource.Id; Location = cache.Resource.Location; Name = cache.Resource.Name; Type = cache.Resource.Type; HostName = cache.Resource.Properties.HostName; Port = cache.Resource.Properties.Port; ProvisioningState = cache.Resource.Properties.ProvisioningState; SslPort = cache.Resource.Properties.SslPort; RedisConfiguration = cache.Resource.Properties.RedisConfiguration; EnableNonSslPort = cache.Resource.Properties.EnableNonSslPort.Value; RedisVersion = cache.Resource.Properties.RedisVersion; Size = SizeConverter.GetSizeInUserSpecificFormat(cache.Resource.Properties.Sku.Family, cache.Resource.Properties.Sku.Capacity); Sku = cache.Resource.Properties.Sku.Name; PrimaryKey = cache.Resource.Properties.AccessKeys.PrimaryKey; SecondaryKey = cache.Resource.Properties.AccessKeys.SecondaryKey; ResourceGroupName = resourceGroupName; VirtualNetwork = cache.Resource.Properties.VirtualNetwork; Subnet = cache.Resource.Properties.Subnet; StaticIP = cache.Resource.Properties.StaticIP; TenantSettings = cache.Resource.Properties.TenantSettings; ShardCount = cache.Resource.Properties.ShardCount; }
public RedisCacheAttributesWithAccessKeys(RedisCreateOrUpdateResponse cache, string resourceGroupName) { Id = cache.Id; Location = cache.Location; Name = cache.Name; Type = cache.Type; HostName = cache.Properties.HostName; Port = cache.Properties.Port; ProvisioningState = cache.Properties.ProvisioningState; SslPort = cache.Properties.SslPort; MaxMemoryPolicy = cache.Properties.MaxMemoryPolicy; RedisVersion = cache.Properties.RedisVersion; Size = SizeConverter.GetSizeInUserSpecificFormat(cache.Properties.Sku.Family, cache.Properties.Sku.Capacity); Sku = cache.Properties.Sku.Name; PrimaryKey = cache.Properties.AccessKeys.PrimaryKey; SecondaryKey = cache.Properties.AccessKeys.SecondaryKey; ResourceGroupName = resourceGroupName; }
public void UpdateEnableNonSslPortBugTest() { TestUtilities.StartTest(); var _client = RedisCacheManagementTestUtilities.GetRedisManagementClient(this); RedisGetResponse responseGet = _client.Redis.Get(resourceGroupName: "SunnySDK25", name: "sunnysdk25-centralus"); Assert.True(responseGet.Resource.Properties.EnableNonSslPort.Value); Dictionary <string, string> redisConfiguration = new Dictionary <string, string>(); redisConfiguration.Add("maxmemory-policy", "allkeys-lru"); RedisCreateOrUpdateResponse responseCreate = _client.Redis.CreateOrUpdate(resourceGroupName: "SunnySDK25", name: "sunnysdk25-centralus", parameters: new RedisCreateOrUpdateParameters { Location = "Central US", Properties = new RedisProperties { RedisVersion = "2.8", Sku = new Sku() { Name = SkuName.Standard, Family = SkuFamily.C, Capacity = 2 }, RedisConfiguration = redisConfiguration } }); Assert.Equal(6379, responseCreate.Resource.Properties.Port); Assert.Equal(6380, responseCreate.Resource.Properties.SslPort); Assert.True(responseCreate.Resource.Properties.EnableNonSslPort.Value); TestUtilities.EndTest(); }
public void TryCreatingCache(string resourceGroupName, string cacheName, string location) { var redisClient = RedisCacheManagementTestUtilities.GetRedisManagementClient(_testBase); RedisCreateOrUpdateResponse createResponse = redisClient.Redis.CreateOrUpdate(resourceGroupName: resourceGroupName, name: cacheName, parameters: new RedisCreateOrUpdateParameters { Location = location, Properties = new RedisProperties { RedisVersion = "2.8", Sku = new Sku() { Name = SkuName.Basic, Family = SkuFamily.C, Capacity = 0 } } }); RedisGetResponse response = redisClient.Redis.Get(resourceGroupName: resourceGroupName, name: cacheName); ThrowIfTrue(!response.Resource.Id.Contains(cacheName), "Cache name not found inside Id."); ThrowIfTrue(!response.Resource.Name.Equals(cacheName), string.Format("Cache name is not equal to {0}", cacheName)); ThrowIfTrue(!response.Resource.Properties.HostName.Contains(cacheName), "Cache name not found inside host name."); // wait for maximum 30 minutes for cache to create for (int i = 0; i < 60; i++) { TestUtilities.Wait(new TimeSpan(0, 0, 30)); RedisGetResponse responseGet = redisClient.Redis.Get(resourceGroupName: resourceGroupName, name: cacheName); if ("succeeded".Equals(responseGet.Resource.Properties.ProvisioningState, StringComparison.InvariantCultureIgnoreCase)) { break; } ThrowIfTrue(i == 60, "Cache is not in succeeded state even after 30 min."); } }
public void CreateOrUpdate_BasicWithTagsAndConfig() { string responseString = (@" { ""id"" : ""/subscriptions/a559b6fd-3a84-40bb-a450-b0db5ed37dfe/resourceGroups/HydraTest07152014/providers/Microsoft.Cache/Redis/hydraradiscache"", ""location"" : ""North Europe"", ""name"" : ""hydraradiscache"", ""type"" : ""Microsoft.Cache/Redis"", ""tags"" : {""update"": ""done""}, ""properties"" : { ""provisioningState"" : ""creating"", ""sku"": { ""name"": ""Basic"", ""family"": ""C"", ""capacity"": 1 }, ""redisVersion"" : ""2.8"", ""redisConfiguration"": {""maxmemory-policy"": ""allkeys-lru""}, ""accessKeys"" : { ""primaryKey"" : ""aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa="", ""secondaryKey"" : ""bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb="" }, ""hostName"" : ""hydraradiscache.cache.icbbvt.windows-int.net"", ""port"" : 6379, ""sslPort"" : 6380 } } "); string requestIdHeader = "0d33aff8-8a4e-4565-b893-a10e52260de0"; RedisManagementClient client = Utility.GetRedisManagementClient(responseString, requestIdHeader, HttpStatusCode.Created); RedisCreateOrUpdateResponse response = client.Redis.CreateOrUpdate(resourceGroupName: "resource-group", name: "cachename", parameters: new RedisCreateOrUpdateParameters { Location = "North Europe", Properties = new RedisProperties { RedisVersion = "2.8", Sku = new Sku() { Name = SkuName.Basic, Family = SkuFamily.C, Capacity = 1 }, RedisConfiguration = new Dictionary <string, string>() { { "maxmemory-policy", "allkeys-lru" } } } }); Assert.Equal(requestIdHeader, response.RequestId); Assert.Equal("/subscriptions/a559b6fd-3a84-40bb-a450-b0db5ed37dfe/resourceGroups/HydraTest07152014/providers/Microsoft.Cache/Redis/hydraradiscache", response.Resource.Id); Assert.Equal("North Europe", response.Resource.Location); Assert.Equal("hydraradiscache", response.Resource.Name); Assert.Equal("Microsoft.Cache/Redis", response.Resource.Type); Assert.Equal("creating", response.Resource.Properties.ProvisioningState); Assert.Equal(SkuName.Basic, response.Resource.Properties.Sku.Name); Assert.Equal(SkuFamily.C, response.Resource.Properties.Sku.Family); Assert.Equal(1, response.Resource.Properties.Sku.Capacity); Assert.Equal("2.8", response.Resource.Properties.RedisVersion); Assert.Equal("allkeys-lru", response.Resource.Properties.RedisConfiguration["maxmemory-policy"]); Assert.NotNull(response.Resource.Properties.AccessKeys); Assert.Equal("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa=", response.Resource.Properties.AccessKeys.PrimaryKey); Assert.Equal("bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb=", response.Resource.Properties.AccessKeys.SecondaryKey); Assert.Equal("hydraradiscache.cache.icbbvt.windows-int.net", response.Resource.Properties.HostName); Assert.Equal(6379, response.Resource.Properties.Port); Assert.Equal(6380, response.Resource.Properties.SslPort); }
public void CreateUpdateDeleteTest() { TestUtilities.StartTest(); var _client = RedisCacheManagementTestUtilities.GetRedisManagementClient(this); RedisCreateOrUpdateResponse responseCreate = _client.Redis.CreateOrUpdate(resourceGroupName: fixture.ResourceGroupName, name: fixture.RedisCacheName, parameters: new RedisCreateOrUpdateParameters { Location = fixture.Location, Properties = new RedisProperties { RedisVersion = "2.8", Sku = new Sku() { Name = SkuName.Basic, Family = SkuFamily.C, Capacity = 0 } } }); Assert.NotNull(responseCreate.RequestId); Assert.Contains(fixture.RedisCacheName, responseCreate.Resource.Id); Assert.Equal(fixture.Location, responseCreate.Resource.Location); Assert.Equal(fixture.RedisCacheName, responseCreate.Resource.Name); Assert.Equal("Microsoft.Cache/Redis", responseCreate.Resource.Type); Assert.True("creating".Equals(responseCreate.Resource.Properties.ProvisioningState, StringComparison.InvariantCultureIgnoreCase)); Assert.Equal(SkuName.Basic, responseCreate.Resource.Properties.Sku.Name); Assert.Equal(SkuFamily.C, responseCreate.Resource.Properties.Sku.Family); Assert.Equal(0, responseCreate.Resource.Properties.Sku.Capacity); Assert.Contains("2.8", responseCreate.Resource.Properties.RedisVersion); Assert.Contains(fixture.RedisCacheName, responseCreate.Resource.Properties.HostName); Assert.Equal(6379, responseCreate.Resource.Properties.Port); Assert.Equal(6380, responseCreate.Resource.Properties.SslPort); Assert.False(responseCreate.Resource.Properties.EnableNonSslPort); // wait for maximum 30 minutes for cache to create for (int i = 0; i < 60; i++) { TestUtilities.Wait(new TimeSpan(0, 0, 30)); RedisGetResponse responseGet = _client.Redis.Get(resourceGroupName: fixture.ResourceGroupName, name: fixture.RedisCacheName); if ("succeeded".Equals(responseGet.Resource.Properties.ProvisioningState, StringComparison.InvariantCultureIgnoreCase)) { break; } Assert.False(i == 60, "Cache is not in succeeded state even after 30 min."); } RedisCreateOrUpdateResponse responseUpdate = _client.Redis.CreateOrUpdate(resourceGroupName: fixture.ResourceGroupName, name: fixture.RedisCacheName, parameters: new RedisCreateOrUpdateParameters { Location = fixture.Location, Properties = new RedisProperties { RedisVersion = "2.8", Sku = new Sku() { Name = SkuName.Basic, Family = SkuFamily.C, Capacity = 0 }, RedisConfiguration = new Dictionary <string, string>() { { "maxmemory-policy", "allkeys-lru" } }, EnableNonSslPort = true } }); Assert.NotNull(responseUpdate.RequestId); Assert.Contains(fixture.RedisCacheName, responseUpdate.Resource.Id); Assert.Equal(fixture.Location, responseUpdate.Resource.Location); Assert.Equal(fixture.RedisCacheName, responseUpdate.Resource.Name); Assert.Equal("Microsoft.Cache/Redis", responseUpdate.Resource.Type); Assert.Equal(SkuName.Basic, responseUpdate.Resource.Properties.Sku.Name); Assert.Equal(SkuFamily.C, responseUpdate.Resource.Properties.Sku.Family); Assert.Equal(0, responseUpdate.Resource.Properties.Sku.Capacity); Assert.Contains("2.8", responseUpdate.Resource.Properties.RedisVersion); Assert.Equal("allkeys-lru", responseUpdate.Resource.Properties.RedisConfiguration["maxmemory-policy"]); Assert.Contains(fixture.RedisCacheName, responseUpdate.Resource.Properties.HostName); Assert.Equal(6379, responseUpdate.Resource.Properties.Port); Assert.Equal(6380, responseUpdate.Resource.Properties.SslPort); Assert.True(responseUpdate.Resource.Properties.EnableNonSslPort); AzureOperationResponse responseDelete = _client.Redis.Delete(resourceGroupName: fixture.ResourceGroupName, name: fixture.RedisCacheName); List <HttpStatusCode> acceptedStatusCodes = new List <HttpStatusCode>(); acceptedStatusCodes.Add(HttpStatusCode.OK); acceptedStatusCodes.Add(HttpStatusCode.Accepted); acceptedStatusCodes.Add(HttpStatusCode.NotFound); Assert.Contains <HttpStatusCode>(responseDelete.StatusCode, acceptedStatusCodes); Assert.NotNull(responseDelete.RequestId); TestUtilities.EndTest(); }
public void CreateUpdateDeleteClusterCacheTest() { TestUtilities.StartTest(); var _client = RedisCacheManagementTestUtilities.GetRedisManagementClient(this); RedisCreateOrUpdateResponse responseCreate = _client.Redis.CreateOrUpdate(resourceGroupName: fixture.ResourceGroupName, name: fixture.RedisClusterCacheName, parameters: new RedisCreateOrUpdateParameters { Location = fixture.ClusterCacheLocation, Properties = new RedisProperties { RedisVersion = "3.0", Sku = new Sku() { Name = SkuName.Premium, Family = SkuFamily.P, Capacity = 1 }, ShardCount = 2, TenantSettings = new Dictionary <string, string>() { { "some-key", "some-value" } } } }); Assert.Contains(fixture.RedisClusterCacheName, responseCreate.Resource.Id); Assert.Equal(fixture.ClusterCacheLocation, responseCreate.Resource.Location); Assert.Equal(fixture.RedisClusterCacheName, responseCreate.Resource.Name); Assert.True("creating".Equals(responseCreate.Resource.Properties.ProvisioningState, StringComparison.InvariantCultureIgnoreCase)); Assert.Equal(SkuName.Premium, responseCreate.Resource.Properties.Sku.Name); Assert.Equal(SkuFamily.P, responseCreate.Resource.Properties.Sku.Family); Assert.Equal(1, responseCreate.Resource.Properties.Sku.Capacity); Assert.Contains(fixture.RedisClusterCacheName, responseCreate.Resource.Properties.HostName); Assert.Equal(6379, responseCreate.Resource.Properties.Port); Assert.Equal(6380, responseCreate.Resource.Properties.SslPort); Assert.False(responseCreate.Resource.Properties.EnableNonSslPort.Value); Assert.Equal(2, responseCreate.Resource.Properties.ShardCount.Value); Assert.Equal("some-value", responseCreate.Resource.Properties.TenantSettings["some-key"]); // wait for maximum 30 minutes for cache to create for (int i = 0; i < 60; i++) { TestUtilities.Wait(new TimeSpan(0, 0, 30)); RedisGetResponse responseGet = _client.Redis.Get(resourceGroupName: fixture.ResourceGroupName, name: fixture.RedisClusterCacheName); if ("succeeded".Equals(responseGet.Resource.Properties.ProvisioningState, StringComparison.InvariantCultureIgnoreCase)) { break; } Assert.False(i == 60, "Cache is not in succeeded state even after 30 min."); } RedisCreateOrUpdateResponse responseUpdate = _client.Redis.CreateOrUpdate(resourceGroupName: fixture.ResourceGroupName, name: fixture.RedisClusterCacheName, parameters: new RedisCreateOrUpdateParameters { Location = fixture.ClusterCacheLocation, Properties = new RedisProperties { Sku = new Sku() { Name = SkuName.Premium, Family = SkuFamily.P, Capacity = 1 }, TenantSettings = new Dictionary <string, string>() { { "some-key-1", "some-value-1" } } } }); Assert.Equal("some-value-1", responseUpdate.Resource.Properties.TenantSettings["some-key-1"]); AzureOperationResponse responseDelete = _client.Redis.Delete(resourceGroupName: fixture.ResourceGroupName, name: fixture.RedisClusterCacheName); List <HttpStatusCode> acceptedStatusCodes = new List <HttpStatusCode>(); acceptedStatusCodes.Add(HttpStatusCode.OK); acceptedStatusCodes.Add(HttpStatusCode.Accepted); acceptedStatusCodes.Add(HttpStatusCode.NotFound); Assert.Contains <HttpStatusCode>(responseDelete.StatusCode, acceptedStatusCodes); Assert.NotNull(responseDelete.RequestId); TestUtilities.EndTest(); }
public RedisCreateOrUpdateResponse CreateOrUpdateCache(string resourceGroupName, string cacheName, string location, string skuFamily, int skuCapacity, string skuName, Hashtable redisConfiguration, bool?enableNonSslPort, Hashtable tenantSettings, int?shardCount, string virtualNetwork, string subnet, string staticIP) { RedisCreateOrUpdateParameters parameters = new RedisCreateOrUpdateParameters { Location = location, Properties = new RedisProperties { Sku = new Sku() { Name = skuName, Family = skuFamily, Capacity = skuCapacity } } }; if (redisConfiguration != null) { parameters.Properties.RedisConfiguration = new Dictionary <string, string>(); foreach (object key in redisConfiguration.Keys) { parameters.Properties.RedisConfiguration.Add(key.ToString(), redisConfiguration[key].ToString()); } } if (enableNonSslPort.HasValue) { parameters.Properties.EnableNonSslPort = enableNonSslPort.Value; } if (tenantSettings != null) { parameters.Properties.TenantSettings = new Dictionary <string, string>(); foreach (object key in tenantSettings.Keys) { parameters.Properties.TenantSettings.Add(key.ToString(), tenantSettings[key].ToString()); } } parameters.Properties.ShardCount = shardCount; if (!string.IsNullOrWhiteSpace(virtualNetwork)) { parameters.Properties.VirtualNetwork = virtualNetwork; } if (!string.IsNullOrWhiteSpace(subnet)) { parameters.Properties.Subnet = subnet; } if (!string.IsNullOrWhiteSpace(staticIP)) { parameters.Properties.StaticIP = staticIP; } RedisCreateOrUpdateResponse response = _client.Redis.CreateOrUpdate(resourceGroupName: resourceGroupName, name: cacheName, parameters: parameters); return(response); }