예제 #1
0
        public CloudServiceResource UpdateCacheService(string cacheServiceName, CacheServiceSkuType sku, string memory,
                                                       Action <bool, string, string, string, Action> ConfirmAction, bool force)
        {
            CloudServiceListResponse listResponse  = client.CloudServices.List();
            CloudServiceResource     cacheResource = null;
            string cloudServiceName = null;

            foreach (CloudServiceListResponse.CloudService cloudService in listResponse)
            {
                cacheResource = cloudService.Resources.FirstOrDefault(
                    p => { return(p.Name.Equals(cacheServiceName) && IsCachingResource(p.Type)); });
                if (cacheResource != null)
                {
                    cloudServiceName = cloudService.Name;
                    break;
                }
            }

            if (cacheResource == null)
            {
                throw new ArgumentException(string.Format(Properties.Resources.CacheServiceNotExisting, cacheServiceName));
            }

            CacheSkuCountConvert convert         = new CacheSkuCountConvert(sku);
            CacheServiceSkuType  existingSkuType = cacheResource.IntrinsicSettingsSection.CacheServiceInputSection.SkuType;
            int existingSkuCount = cacheResource.IntrinsicSettingsSection.CacheServiceInputSection.SkuCount;
            int newSkuCount      = convert.ToSkuCount(memory);

            if (existingSkuType == sku && existingSkuCount == newSkuCount)
            {
                WriteProgress("No update is needed as there is no change");
                return(cacheResource);
            }

            //We will prompt only if there is data loss
            string promptMessage = GetPromptMessgaeIfThereIsDataLoss(existingSkuType, sku, existingSkuCount, newSkuCount);

            if (string.IsNullOrEmpty(promptMessage))
            {
                force = true;
            }
            ConfirmAction(
                force,
                string.Format(Properties.Resources.UpdatingCacheService),
                promptMessage,
                cacheServiceName,
                () =>
            {
                cacheResource.IntrinsicSettingsSection.CacheServiceInputSection.SkuCount = convert.ToSkuCount(memory);
                cacheResource.IntrinsicSettingsSection.CacheServiceInputSection.SkuType  = sku;
                CacheServiceCreateParameters param = new CacheServiceCreateParameters();
                param.IntrinsicSettingsSection     = cacheResource.IntrinsicSettingsSection;
                param.ETag    = cacheResource.ETag;
                cacheResource = ProvisionCacheService(cloudServiceName, cacheResource.Name, param, false);
            });
            return(cacheResource);
        }
예제 #2
0
        private CloudServiceResource ProvisionCacheService(string cloudServiceName, 
            string cacheServiceName, 
            CacheServiceCreateParameters param, 
            bool createOrUpdate)
        {
            if (createOrUpdate)
            {
                WriteProgress(Properties.Resources.CreatingCacheService);
            }
            else
            {
                WriteProgress(Properties.Resources.UpdatingCacheService);
            }
            client.CacheServices.CreateCacheService(cloudServiceName, cacheServiceName, param);

            WriteProgress(Properties.Resources.WaitForCacheServiceReady);
            CloudServiceResource cacheResource = WaitForProvisionDone(cacheServiceName, cloudServiceName);
            return cacheResource;
        }
예제 #3
0
        private static CacheServiceCreateParameters InitializeParameters(string location, CacheServiceSkuType sku, string memorySize)
        {
            CacheServiceCreateParameters param    = new CacheServiceCreateParameters();
            IntrinsicSettings            settings = new IntrinsicSettings();

            IntrinsicSettings.CacheServiceInput input = new IntrinsicSettings.CacheServiceInput();
            settings.CacheServiceInputSection = input;
            param.Settings = settings;

            const int CacheMemoryObjectSize = 1024;

            Models.CacheSkuCountConvert convert = new Models.CacheSkuCountConvert(sku);
            input.Location          = location;
            input.SkuCount          = convert.ToSkuCount(memorySize);
            input.ServiceVersion    = "1.0.0";
            input.ObjectSizeInBytes = CacheMemoryObjectSize;
            input.SkuType           = sku;
            return(param);
        }
예제 #4
0
        public void RemoveNamedCache(string cacheServiceName, string namedCacheName, Action <bool, string, string, string, Action> ConfirmAction, bool force)
        {
            if ("default".Equals(namedCacheName))
            {
                throw new ArgumentException(string.Format(Properties.Resources.DoNotRemoveDefaultNamedCache));
            }

            string cloudServiceName            = null;
            CloudServiceResource cacheResource = FetchCloudServiceResource(cacheServiceName, out cloudServiceName);

            bool namedCacheFound = false;

            IntrinsicSettings.CacheServiceInput.NamedCache removeNamedCache = null;
            foreach (IntrinsicSettings.CacheServiceInput.NamedCache namedCache in cacheResource.IntrinsicSettingsSection.CacheServiceInputSection.NamedCaches)
            {
                if (namedCache.CacheName.Equals(namedCacheName))
                {
                    removeNamedCache = namedCache;
                    namedCacheFound  = true;
                    break;
                }
            }

            if (!namedCacheFound)
            {
                throw new ArgumentException(string.Format(Properties.Resources.NamedCacheDoNotExists, cacheServiceName, namedCacheName));
            }

            ConfirmAction(
                force,
                Properties.Resources.RemoveNamedCacheWarning,
                Properties.Resources.RemovingNamedCache,
                cacheServiceName,
                () =>
            {
                CacheServiceCreateParameters param = new CacheServiceCreateParameters();
                param.IntrinsicSettingsSection     = cacheResource.IntrinsicSettingsSection;
                param.ETag = cacheResource.ETag;
                param.IntrinsicSettingsSection.CacheServiceInputSection.NamedCaches.Remove(removeNamedCache);
                cacheResource = ProvisionCacheService(cloudServiceName, cacheResource.Name, param, false);
            });
        }
예제 #5
0
        private CloudServiceResource ProvisionCacheService(string cloudServiceName,
                                                           string cacheServiceName,
                                                           CacheServiceCreateParameters param,
                                                           bool createOrUpdate)
        {
            if (createOrUpdate)
            {
                WriteProgress(Properties.Resources.CreatingCacheService);
            }
            else
            {
                WriteProgress(Properties.Resources.UpdatingCacheService);
            }
            client.CacheServices.CreateCacheService(cloudServiceName, cacheServiceName, param);

            WriteProgress(Properties.Resources.WaitForCacheServiceReady);
            CloudServiceResource cacheResource = WaitForProvisionDone(cacheServiceName, cloudServiceName);

            return(cacheResource);
        }
예제 #6
0
        public CloudServiceResource AddNamedCache(string cacheServiceName, string namedCacheName, string expiryPolicy, int expiryTimeInMinutes,
                                                  bool noeviction, bool notifications, bool highAvailability)
        {
            string cloudServiceName            = null;
            CloudServiceResource cacheResource = FetchCloudServiceResource(cacheServiceName, out cloudServiceName);

            foreach (IntrinsicSettings.CacheServiceInput.NamedCache namedCache in cacheResource.IntrinsicSettingsSection.CacheServiceInputSection.NamedCaches)
            {
                if (namedCache.CacheName.Equals(namedCacheName))
                {
                    throw new ArgumentException(string.Format(Properties.Resources.NamedCacheExists, cacheServiceName, namedCacheName));
                }
            }

            if (cacheResource.IntrinsicSettingsSection.CacheServiceInputSection.SkuType == CacheServiceSkuType.Basic)
            {
                throw new ArgumentException(Properties.Resources.NoAddInBasicSku);
            }
            else if (cacheResource.IntrinsicSettingsSection.CacheServiceInputSection.NamedCaches.Count == MaxNamedCacheCount)
            {
                throw new ArgumentException(Properties.Resources.NoAddInAllSku);
            }

            IntrinsicSettings.CacheServiceInput.NamedCache newNamedCache = new IntrinsicSettings.CacheServiceInput.NamedCache();
            newNamedCache.CacheName                      = namedCacheName;
            newNamedCache.EvictionPolicy                 = noeviction ? "None" : "LeastRecentlyUsed";
            newNamedCache.ExpirationSettingsSection      = new IntrinsicSettings.CacheServiceInput.NamedCache.ExpirationSettings();
            newNamedCache.ExpirationSettingsSection.Type = expiryPolicy;
            newNamedCache.ExpirationSettingsSection.TimeToLiveInMinutes = expiryTimeInMinutes;
            newNamedCache.NotificationsEnabled    = notifications;
            newNamedCache.HighAvailabilityEnabled = highAvailability;

            CacheServiceCreateParameters param = new CacheServiceCreateParameters();

            param.IntrinsicSettingsSection = cacheResource.IntrinsicSettingsSection;
            param.ETag = cacheResource.ETag;
            param.IntrinsicSettingsSection.CacheServiceInputSection.NamedCaches.Add(newNamedCache);
            cacheResource = ProvisionCacheService(cloudServiceName, cacheResource.Name, param, false);

            return(cacheResource);
        }
예제 #7
0
        public CloudServiceResource UpdateCacheService(string cacheServiceName, CacheServiceSkuType sku, string memory,
                                                       Action <bool, string, string, string, Action> ConfirmAction, bool force)
        {
            string cloudServiceName            = null;
            CloudServiceResource cacheResource = FetchCloudServiceResource(cacheServiceName, out cloudServiceName);

            CacheSkuCountConvert convert         = new CacheSkuCountConvert(sku);
            CacheServiceSkuType  existingSkuType = cacheResource.IntrinsicSettingsSection.CacheServiceInputSection.SkuType;
            int existingSkuCount = cacheResource.IntrinsicSettingsSection.CacheServiceInputSection.SkuCount;
            int newSkuCount      = convert.ToSkuCount(memory);

            if (existingSkuType == sku && existingSkuCount == newSkuCount)
            {
                WriteProgress("No update is needed as there is no change");
                return(cacheResource);
            }

            //We will prompt only if there is data loss
            string promptMessage = GetPromptMessgaeIfThereIsDataLoss(existingSkuType, sku, existingSkuCount, newSkuCount);

            if (string.IsNullOrEmpty(promptMessage))
            {
                force = true;
            }
            ConfirmAction(
                force,
                string.Format(Properties.Resources.UpdatingCacheService),
                promptMessage,
                cacheServiceName,
                () =>
            {
                cacheResource.IntrinsicSettingsSection.CacheServiceInputSection.SkuCount = convert.ToSkuCount(memory);
                cacheResource.IntrinsicSettingsSection.CacheServiceInputSection.SkuType  = sku;
                CacheServiceCreateParameters param = new CacheServiceCreateParameters();
                param.IntrinsicSettingsSection     = cacheResource.IntrinsicSettingsSection;
                param.ETag    = cacheResource.ETag;
                cacheResource = ProvisionCacheService(cloudServiceName, cacheResource.Name, param, false);
            });
            return(cacheResource);
        }
예제 #8
0
        public CloudServiceResource CreateCacheService(
            string subscriptionID,
            string cacheServiceName,
            string location,
            CacheServiceSkuType sku,
            string memorySize)
        {
            WriteProgress(Properties.Resources.InitializingCacheParameters);
            CacheServiceCreateParameters param = InitializeParameters(location, sku, memorySize);

            WriteProgress(Properties.Resources.CreatingPrerequisites);
            string cloudServiceName = EnsureCloudServiceExists(subscriptionID, location);

            WriteProgress(Properties.Resources.VerifyingCacheServiceName);
            if (!(client.CacheServices.CheckNameAvailability(cloudServiceName, cacheServiceName).Available))
            {
                throw new ArgumentException(Properties.Resources.CacheServiceNameUnavailable);
            }

            CloudServiceResource cacheResource = ProvisionCacheService(cloudServiceName, cacheServiceName, param, true);

            return(cacheResource);
        }
예제 #9
0
        private static CacheServiceCreateParameters InitializeParameters(string location, CacheServiceSkuType sku, string memorySize)
        {
            CacheServiceCreateParameters param = new CacheServiceCreateParameters();
            IntrinsicSettings settings = new IntrinsicSettings();
            IntrinsicSettings.CacheServiceInput input = new IntrinsicSettings.CacheServiceInput();
            settings.CacheServiceInputSection = input;
            param.Settings = settings;

            const int CacheMemoryObjectSize = 1024;
            Models.CacheSkuCountConvert convert = new Models.CacheSkuCountConvert(sku);
            input.Location = location;
            input.SkuCount = convert.ToSkuCount(memorySize);
            input.ServiceVersion = "1.0.0";
            input.ObjectSizeInBytes = CacheMemoryObjectSize;
            input.SkuType = sku;
            return param;
        }
예제 #10
0
        public void RemoveNamedCache(string cacheServiceName, string namedCacheName, Action<bool, string, string, string, Action> ConfirmAction, bool force)
        {
            if ("default".Equals(namedCacheName))
            {
                throw new ArgumentException(string.Format(Properties.Resources.DoNotRemoveDefaultNamedCache));
            }

            string cloudServiceName = null;
            CloudServiceResource cacheResource = FetchCloudServiceResource(cacheServiceName, out cloudServiceName);

            bool namedCacheFound = false;
            IntrinsicSettings.CacheServiceInput.NamedCache removeNamedCache = null;
            foreach (IntrinsicSettings.CacheServiceInput.NamedCache namedCache in cacheResource.IntrinsicSettingsSection.CacheServiceInputSection.NamedCaches)
            {
                if (namedCache.CacheName.Equals(namedCacheName))
                {
                    removeNamedCache = namedCache;
                    namedCacheFound = true;
                    break;
                }
            }

            if (!namedCacheFound)
            {
                throw new ArgumentException(string.Format(Properties.Resources.NamedCacheDoNotExists, cacheServiceName, namedCacheName));
            }

            ConfirmAction(
               force,
               Properties.Resources.RemoveNamedCacheWarning,
               Properties.Resources.RemovingNamedCache,
               cacheServiceName,
               () =>
               {
                   CacheServiceCreateParameters param = new CacheServiceCreateParameters();
                   param.IntrinsicSettingsSection = cacheResource.IntrinsicSettingsSection;
                   param.ETag = cacheResource.ETag;
                   param.IntrinsicSettingsSection.CacheServiceInputSection.NamedCaches.Remove(removeNamedCache);
                   cacheResource = ProvisionCacheService(cloudServiceName, cacheResource.Name, param, false);
               });
        }
예제 #11
0
        public CloudServiceResource SetNamedCache(string cacheServiceName, string namedCacheName, string expiryPolicy, int expiryTimeInMinutes,
            bool noeviction, bool notifications, bool highAvailability, Action<bool, string, string, string, Action> ConfirmAction, bool force)
        {
            string cloudServiceName = null;
            CloudServiceResource cacheResource = FetchCloudServiceResource(cacheServiceName, out cloudServiceName);

            bool namedCacheFound = false;
            IntrinsicSettings.CacheServiceInput.NamedCache updateNamedCache = null;
            foreach (IntrinsicSettings.CacheServiceInput.NamedCache namedCache in cacheResource.IntrinsicSettingsSection.CacheServiceInputSection.NamedCaches)
            {
                if (namedCache.CacheName.Equals(namedCacheName))
                {
                    updateNamedCache = namedCache;
                    namedCacheFound = true;
                    break;
                }
            }

            if (!namedCacheFound)
            {
                throw new ArgumentException(string.Format(Properties.Resources.NamedCacheDoNotExists, cacheServiceName, namedCacheName));
            }

            if (cacheResource.IntrinsicSettingsSection.CacheServiceInputSection.SkuType == CacheServiceSkuType.Basic)
            {
                if (notifications)
                {
                    throw new ArgumentException(Properties.Resources.NotificationsNotAvailable);
                }

                if (highAvailability)
                {
                    throw new ArgumentException(Properties.Resources.HighAvailabilityNotAvailable);
                }
            }

            ConfirmAction(
               force,
               Properties.Resources.UpdateNamedCacheWarning,
               Properties.Resources.UpdatingNamedCache,
               cacheServiceName,
               () =>
               {
                   if (cacheResource.IntrinsicSettingsSection.CacheServiceInputSection.SkuType != CacheServiceSkuType.Basic)
                   {
                       updateNamedCache.NotificationsEnabled = notifications;
                       updateNamedCache.HighAvailabilityEnabled = highAvailability;
                   }
                   updateNamedCache.EvictionPolicy = noeviction ? "None" : "LeastRecentlyUsed";
                   if (updateNamedCache.ExpirationSettingsSection == null)
                   {
                       updateNamedCache.ExpirationSettingsSection = new IntrinsicSettings.CacheServiceInput.NamedCache.ExpirationSettings();
                   }
                   updateNamedCache.ExpirationSettingsSection.Type = expiryPolicy;
                   updateNamedCache.ExpirationSettingsSection.TimeToLiveInMinutes = expiryTimeInMinutes;

                   CacheServiceCreateParameters param = new CacheServiceCreateParameters();
                   param.IntrinsicSettingsSection = cacheResource.IntrinsicSettingsSection;
                   param.ETag = cacheResource.ETag;

                   cacheResource = ProvisionCacheService(cloudServiceName, cacheResource.Name, param, false);
               });
            return cacheResource;
        }
예제 #12
0
        public CloudServiceResource AddNamedCache(string cacheServiceName, string namedCacheName, string expiryPolicy, int expiryTimeInMinutes,
            bool noeviction, bool notifications, bool highAvailability)
        {
            string cloudServiceName = null;
            CloudServiceResource cacheResource = FetchCloudServiceResource(cacheServiceName, out cloudServiceName);

            foreach (IntrinsicSettings.CacheServiceInput.NamedCache namedCache in cacheResource.IntrinsicSettingsSection.CacheServiceInputSection.NamedCaches)
            {
                if (namedCache.CacheName.Equals(namedCacheName))
                {
                    throw new ArgumentException(string.Format(Properties.Resources.NamedCacheExists, cacheServiceName, namedCacheName));
                }
            }

            if (cacheResource.IntrinsicSettingsSection.CacheServiceInputSection.SkuType == CacheServiceSkuType.Basic)
            {
                throw new ArgumentException(Properties.Resources.NoAddInBasicSku);
            }
            else if (cacheResource.IntrinsicSettingsSection.CacheServiceInputSection.NamedCaches.Count == MaxNamedCacheCount)
            {
                throw new ArgumentException(Properties.Resources.NoAddInAllSku);
            }

            IntrinsicSettings.CacheServiceInput.NamedCache newNamedCache = new IntrinsicSettings.CacheServiceInput.NamedCache();
            newNamedCache.CacheName = namedCacheName;
            newNamedCache.EvictionPolicy = noeviction ? "None" : "LeastRecentlyUsed";
            newNamedCache.ExpirationSettingsSection = new IntrinsicSettings.CacheServiceInput.NamedCache.ExpirationSettings();
            newNamedCache.ExpirationSettingsSection.Type = expiryPolicy;
            newNamedCache.ExpirationSettingsSection.TimeToLiveInMinutes = expiryTimeInMinutes;
            newNamedCache.NotificationsEnabled = notifications;
            newNamedCache.HighAvailabilityEnabled = highAvailability;

            CacheServiceCreateParameters param = new CacheServiceCreateParameters();
            param.IntrinsicSettingsSection = cacheResource.IntrinsicSettingsSection;
            param.ETag = cacheResource.ETag;
            param.IntrinsicSettingsSection.CacheServiceInputSection.NamedCaches.Add(newNamedCache);
            cacheResource = ProvisionCacheService(cloudServiceName, cacheResource.Name, param, false);

            return cacheResource;
        }
예제 #13
0
        public CloudServiceResource UpdateCacheService(string cacheServiceName, CacheServiceSkuType sku, string memory,
            Action<bool, string, string, string, Action> ConfirmAction, bool force)
        {
            string cloudServiceName = null;
            CloudServiceResource cacheResource = FetchCloudServiceResource(cacheServiceName, out cloudServiceName);

            CacheSkuCountConvert convert = new CacheSkuCountConvert(sku);
            CacheServiceSkuType existingSkuType = cacheResource.IntrinsicSettingsSection.CacheServiceInputSection.SkuType;
            int existingSkuCount = cacheResource.IntrinsicSettingsSection.CacheServiceInputSection.SkuCount;
            int newSkuCount = convert.ToSkuCount(memory);
            if (existingSkuType == sku && existingSkuCount == newSkuCount)
            {
                WriteProgress("No update is needed as there is no change");
                return cacheResource;
            }

            //We will prompt only if there is data loss
            string promptMessage = GetPromptMessgaeIfThereIsDataLoss(existingSkuType, sku, existingSkuCount, newSkuCount);
            if (string.IsNullOrEmpty(promptMessage))
            {
                force = true;
            }
            ConfirmAction(
               force,
               string.Format(Properties.Resources.UpdatingCacheService),
               promptMessage,
               cacheServiceName,
               () =>
               {
                    cacheResource.IntrinsicSettingsSection.CacheServiceInputSection.SkuCount = convert.ToSkuCount(memory);
                    cacheResource.IntrinsicSettingsSection.CacheServiceInputSection.SkuType = sku;
                    CacheServiceCreateParameters param = new CacheServiceCreateParameters();
                    param.IntrinsicSettingsSection = cacheResource.IntrinsicSettingsSection;
                    param.ETag = cacheResource.ETag;
                    cacheResource = ProvisionCacheService(cloudServiceName, cacheResource.Name, param, false);
               });
            return cacheResource;
        }
예제 #14
0
        public CloudServiceResource UpdateCacheService(string cacheServiceName, CacheServiceSkuType sku, string memory,
            Action<bool, string, string, string, Action> ConfirmAction, bool force)
        {
            CloudServiceListResponse listResponse = client.CloudServices.List();
            CloudServiceResource cacheResource = null;
            string cloudServiceName = null;
            foreach (CloudServiceListResponse.CloudService cloudService in listResponse)
            {
                cacheResource = cloudService.Resources.FirstOrDefault(
                    p => { return p.Name.Equals(cacheServiceName) && p.Type == CacheResourceType; });
                if (cacheResource != null)
                {
                    cloudServiceName = cloudService.Name;
                    break;
                }
            }
            
            if (cacheResource==null)
            {
                throw new ArgumentException(string.Format(Properties.Resources.CacheServiceNotExisting, cacheServiceName));
            }

            CacheSkuCountConvert convert = new CacheSkuCountConvert(sku);
            CacheServiceSkuType existingSkuType = cacheResource.IntrinsicSettingsSection.CacheServiceInputSection.SkuType;
            int existingSkuCount = cacheResource.IntrinsicSettingsSection.CacheServiceInputSection.SkuCount;
            int newSkuCount = convert.ToSkuCount(memory);
            if (existingSkuType == sku && existingSkuCount == newSkuCount)
            {
                WriteProgress("No update is needed as there is no change");
                return cacheResource;
            }

            //We will prompt only if there is data loss
            string promptMessage = GetPromptMessgaeIfThereIsDataLoss(existingSkuType, sku, existingSkuCount, newSkuCount);
            if (string.IsNullOrEmpty(promptMessage))
            {
                force = true;
            }
            ConfirmAction(
               force,
               string.Format(Properties.Resources.UpdatingCacheService),
               promptMessage,
               cacheServiceName,
               () =>
               {
                    cacheResource.IntrinsicSettingsSection.CacheServiceInputSection.SkuCount = convert.ToSkuCount(memory);
                    cacheResource.IntrinsicSettingsSection.CacheServiceInputSection.SkuType = sku;
                    CacheServiceCreateParameters param = new CacheServiceCreateParameters();
                    param.IntrinsicSettingsSection = cacheResource.IntrinsicSettingsSection;
                    param.ETag = cacheResource.ETag;
                    cacheResource = ProvisionCacheService(cloudServiceName, cacheResource.Name, param, false);
               });
            return cacheResource;
        }
예제 #15
0
        public CloudServiceResource SetNamedCache(string cacheServiceName, string namedCacheName, string expiryPolicy, int expiryTimeInMinutes,
                                                  bool noeviction, bool notifications, bool highAvailability, Action <bool, string, string, string, Action> ConfirmAction, bool force)
        {
            string cloudServiceName            = null;
            CloudServiceResource cacheResource = FetchCloudServiceResource(cacheServiceName, out cloudServiceName);

            bool namedCacheFound = false;

            IntrinsicSettings.CacheServiceInput.NamedCache updateNamedCache = null;
            foreach (IntrinsicSettings.CacheServiceInput.NamedCache namedCache in cacheResource.IntrinsicSettingsSection.CacheServiceInputSection.NamedCaches)
            {
                if (namedCache.CacheName.Equals(namedCacheName))
                {
                    updateNamedCache = namedCache;
                    namedCacheFound  = true;
                    break;
                }
            }

            if (!namedCacheFound)
            {
                throw new ArgumentException(string.Format(Properties.Resources.NamedCacheDoNotExists, cacheServiceName, namedCacheName));
            }

            if (cacheResource.IntrinsicSettingsSection.CacheServiceInputSection.SkuType == CacheServiceSkuType.Basic)
            {
                if (notifications)
                {
                    throw new ArgumentException(Properties.Resources.NotificationsNotAvailable);
                }

                if (highAvailability)
                {
                    throw new ArgumentException(Properties.Resources.HighAvailabilityNotAvailable);
                }
            }

            ConfirmAction(
                force,
                Properties.Resources.UpdateNamedCacheWarning,
                Properties.Resources.UpdatingNamedCache,
                cacheServiceName,
                () =>
            {
                if (cacheResource.IntrinsicSettingsSection.CacheServiceInputSection.SkuType != CacheServiceSkuType.Basic)
                {
                    updateNamedCache.NotificationsEnabled    = notifications;
                    updateNamedCache.HighAvailabilityEnabled = highAvailability;
                }
                updateNamedCache.EvictionPolicy = noeviction ? "None" : "LeastRecentlyUsed";
                if (updateNamedCache.ExpirationSettingsSection == null)
                {
                    updateNamedCache.ExpirationSettingsSection = new IntrinsicSettings.CacheServiceInput.NamedCache.ExpirationSettings();
                }
                updateNamedCache.ExpirationSettingsSection.Type = expiryPolicy;
                updateNamedCache.ExpirationSettingsSection.TimeToLiveInMinutes = expiryTimeInMinutes;

                CacheServiceCreateParameters param = new CacheServiceCreateParameters();
                param.IntrinsicSettingsSection     = cacheResource.IntrinsicSettingsSection;
                param.ETag = cacheResource.ETag;

                cacheResource = ProvisionCacheService(cloudServiceName, cacheResource.Name, param, false);
            });
            return(cacheResource);
        }