public override void ExecuteCmdlet() { RedisGetResponse response = CacheClient.GetCache(ResourceGroupName, Name); string skuName; string skuFamily; int skuCapacity; if (string.IsNullOrEmpty(Sku)) { skuName = response.Resource.Properties.Sku.Name; } else { skuName = Sku; } if (string.IsNullOrEmpty(Size)) { skuFamily = response.Resource.Properties.Sku.Family; skuCapacity = response.Resource.Properties.Sku.Capacity; } else { Size = SizeConverter.GetSizeInRedisSpecificFormat(Size); skuFamily = Size.Substring(0, 1); int.TryParse(Size.Substring(1), out skuCapacity); } WriteObject(new RedisCacheAttributesWithAccessKeys( CacheClient.CreateOrUpdateCache(ResourceGroupName, Name, response.Resource.Location, response.Resource.Properties.RedisVersion, skuFamily, skuCapacity, skuName, RedisConfiguration, EnableNonSslPort), ResourceGroupName)); }
public override void ExecuteCmdlet() { RedisGetResponse response = CacheClient.GetCache(ResourceGroupName, Name); WriteObject(new RedisCacheAttributesWithAccessKeys( CacheClient.CreateOrUpdateCache(ResourceGroupName, Name, response.Location, response.Properties.RedisVersion, response.Properties.Sku.Family, response.Properties.Sku.Capacity, response.Properties.Sku.Name, MaxMemoryPolicy), ResourceGroupName)); }
public override void ExecuteCmdlet() { string skuFamily; int skuCapacity = 1; if (string.IsNullOrEmpty(RedisVersion)) { RedisVersion = redisDefaultVersion; } if (string.IsNullOrEmpty(Size)) { Size = SizeConverter.C1String; } else { Size = SizeConverter.GetSizeInRedisSpecificFormat(Size); } // Size to SkuFamily and SkuCapacity conversion skuFamily = Size.Substring(0, 1); int.TryParse(Size.Substring(1), out skuCapacity); if (string.IsNullOrEmpty(Sku)) { Sku = SkuStrings.Standard; } // If Force flag is not avaliable than check if cache is already available or not try { RedisGetResponse availableCache = CacheClient.GetCache(ResourceGroupName, Name); if (availableCache != null) { throw new CloudException(string.Format(Resources.RedisCacheExists, Name)); } } catch (CloudException ex) { if (ex.Error.Code == "ResourceNotFound" || ex.Message.Contains("ResourceNotFound")) { // cache does not exists so go ahead and create one } else if (ex.Error.Code == "ResourceGroupNotFound" || ex.Message.Contains("ResourceGroupNotFound")) { // resource group not found, let create throw error don't throw from here } else { // all other exceptions should be thrown throw; } } WriteObject(new RedisCacheAttributesWithAccessKeys(CacheClient.CreateOrUpdateCache(ResourceGroupName, Name, Location, RedisVersion, skuFamily, skuCapacity, Sku, MaxMemoryPolicy, EnableNonSslPort), ResourceGroupName)); }
public override void ExecuteCmdlet() { Utility.ValidateResourceGroupAndResourceName(ResourceGroupName, Name); if (!string.IsNullOrEmpty(MaxMemoryPolicy)) { throw new ArgumentException(Resources.MaxMemoryPolicyException); } RedisResource response = CacheClient.GetCache(ResourceGroupName, Name); string skuName; string skuFamily; int skuCapacity; if (string.IsNullOrEmpty(Sku)) { skuName = response.Sku.Name; } else { skuName = Sku; } if (string.IsNullOrEmpty(Size)) { skuFamily = response.Sku.Family; skuCapacity = response.Sku.Capacity; } else { Size = SizeConverter.GetSizeInRedisSpecificFormat(Size, SkuStrings.Premium.Equals(Sku)); skuFamily = Size.Substring(0, 1); int.TryParse(Size.Substring(1), out skuCapacity); } if (!ShardCount.HasValue && response.ShardCount.HasValue) { ShardCount = response.ShardCount; } WriteObject(new RedisCacheAttributesWithAccessKeys( CacheClient.CreateOrUpdateCache(ResourceGroupName, Name, response.Location, skuFamily, skuCapacity, skuName, RedisConfiguration, EnableNonSslPort, TenantSettings, ShardCount, response.SubnetId, response.StaticIP, response.Tags), ResourceGroupName)); }
protected override void ProcessRecord() { if (!string.IsNullOrEmpty(MaxMemoryPolicy)) { throw new ArgumentException(Resources.MaxMemoryPolicyException); } RedisGetResponse response = CacheClient.GetCache(ResourceGroupName, Name); string skuName; string skuFamily; int skuCapacity; if (string.IsNullOrEmpty(Sku)) { skuName = response.Resource.Properties.Sku.Name; } else { skuName = Sku; } if (string.IsNullOrEmpty(Size)) { skuFamily = response.Resource.Properties.Sku.Family; skuCapacity = response.Resource.Properties.Sku.Capacity; } else { Size = SizeConverter.GetSizeInRedisSpecificFormat(Size); skuFamily = Size.Substring(0, 1); int.TryParse(Size.Substring(1), out skuCapacity); } WriteObject(new RedisCacheAttributesWithAccessKeys( CacheClient.CreateOrUpdateCache(ResourceGroupName, Name, response.Resource.Location, response.Resource.Properties.RedisVersion, skuFamily, skuCapacity, skuName, RedisConfiguration, EnableNonSslPort), ResourceGroupName)); }
public override void ExecuteCmdlet() { if (!string.IsNullOrEmpty(RedisVersion)) { WriteWarning("The RedisVersion parameter has been deprecated. As such, it is no longer necessary to provide this parameter and any value specified is ignored."); } if (!string.IsNullOrEmpty(MaxMemoryPolicy)) { throw new ArgumentException(Resources.MaxMemoryPolicyException); } if (string.IsNullOrEmpty(Sku)) { Sku = SkuStrings.Standard; } if (string.IsNullOrEmpty(Size)) { Size = SizeConverter.C1String; } else { Size = SizeConverter.GetSizeInRedisSpecificFormat(Size, SkuStrings.Premium.Equals(Sku)); } int skuCapacity = 1; // Size to SkuFamily and SkuCapacity conversion string skuFamily = Size.Substring(0, 1); int.TryParse(Size.Substring(1), out skuCapacity); // If Force flag is not avaliable than check if cache is already available or not try { RedisResource availableCache = CacheClient.GetCache(ResourceGroupName, Name); if (availableCache != null) { throw new CloudException(string.Format(Resources.RedisCacheExists, Name)); } } catch (CloudException ex) { if (ex.Body.Code == "ResourceNotFound" || ex.Message.Contains("ResourceNotFound")) { // cache does not exists so go ahead and create one } else if (ex.Body.Code == "ResourceGroupNotFound" || ex.Message.Contains("ResourceGroupNotFound")) { // resource group not found, let create throw error don't throw from here } else { // all other exceptions should be thrown throw; } } WriteObject( new RedisCacheAttributesWithAccessKeys( CacheClient.CreateOrUpdateCache(ResourceGroupName, Name, Location, skuFamily, skuCapacity, Sku, RedisConfiguration, EnableNonSslPort, TenantSettings, ShardCount, VirtualNetwork, Subnet, StaticIP), ResourceGroupName ) ); }