/// <summary>
        /// Gets the list of configurations associated with the current subscription in scope.
        /// </summary>
        /// <param name="advisorClient">Advisor Client</param>
        /// <returns>List of PsAzureAdvisorResourceRecommendationBase</returns>
        public List <PsAzureAdvisorConfigurationData> GetAllConfiguratioFromClient(IAdvisorManagementClient advisorClient)
        {
            AzureOperationResponse <IPage <ConfigData> > configurationOperationResponse = null;
            List <ConfigData> entirePageLinkRecommendationData = new List <ConfigData>();
            string            nextPageLink = string.Empty;

            do
            {
                if (string.IsNullOrEmpty(nextPageLink))
                {
                    configurationOperationResponse = advisorClient.Configurations.ListBySubscriptionWithHttpMessagesAsync().Result;
                }
                else
                {
                    configurationOperationResponse = advisorClient.Configurations.ListBySubscriptionNextWithHttpMessagesAsync(nextPageLink).Result;
                }
                nextPageLink = configurationOperationResponse.Body.NextPageLink;

                // Add current page items to the List
                entirePageLinkRecommendationData.AddRange(configurationOperationResponse.Body.ToList());
            }while (!string.IsNullOrEmpty(nextPageLink));

            // Convert to PsAzureAdvisorResourceRecommendationBase list and return
            return(PsAzureAdvisorConfigurationData.GetFromConfigurationData(entirePageLinkRecommendationData));
        }
Exemple #2
0
        /// <summary>
        /// Gets the list of recommendations associated with the given resourceId. Default subscriptionId will be used to gather recommendation(s).
        /// </summary>
        /// <param name="advisorClient">Advisor Client</param>
        /// <param name="resourceId">ResourceId of recommendations</param>
        /// <returns>List of PsAzureAdvisorResourceRecommendationBase</returns>
        public List <PsAzureAdvisorResourceRecommendationBase> GetAllRecommendationsFromClient(IAdvisorManagementClient advisorClient, string resourceId)
        {
            AzureOperationResponse <IPage <ResourceRecommendationBase> > operationResponseRecommendation = null;
            List <ResourceRecommendationBase> entirePageLinkRecommendationData = new List <ResourceRecommendationBase>();
            string nextPageLink = string.Empty;

            do
            {
                if (string.IsNullOrEmpty(nextPageLink))
                {
                    operationResponseRecommendation = advisorClient.Recommendations.ListWithHttpMessagesAsync().Result;
                }
                else
                {
                    operationResponseRecommendation = advisorClient.Recommendations.ListNextWithHttpMessagesAsync(nextPageLink).Result;
                }
                nextPageLink = operationResponseRecommendation.Body.NextPageLink;

                // Add current page items to the List
                entirePageLinkRecommendationData.AddRange(operationResponseRecommendation.Body.ToList());
            }while (!string.IsNullOrEmpty(nextPageLink));

            // Convert to PsAzureAdvisorResourceRecommendationBase list and return
            return(RecommendationHelper.RecommendationFilterByResourceId(
                       PsAzureAdvisorResourceRecommendationBase.GetFromResourceRecommendationBase(entirePageLinkRecommendationData),
                       resourceId));
        }