Beispiel #1
0
        /// <summary>
        /// Clears the cache for current selected subscriptions
        /// </summary>
        /// <returns>True if cache refreshed successfully. Otherwise returns false</returns>
        public async Task <bool> ClearCacheAsync()
        {
            bool result = false;

            if (AzureResourceManager != null && AccountManager != null && AzureAccountManager != null)
            {
                try
                {
                    IEnumerable <IAzureUserAccountSubscriptionContext> subscriptions = await GetSubscriptionsAsync();

                    _cache.ClearCache(subscriptions.Select(x => x.Subscription.SubscriptionId));
                    result = true;
                }
                catch (Exception ex)
                {
                    TraceException(TraceEventType.Error, TraceId.AzureResource, ex, "Failed to refresh the cache");
                    result = false;
                }
            }

            return(result);
        }