Beispiel #1
0
        public static List <AzureResourceUsageMetric> GetUsageMetrics(string token, string subscriptionId, string resourceUri, string filter)
        {
            var result = new List <AzureResourceUsageMetric>();

            var            credentials = CredentialManager.GetCredentials(token, subscriptionId);
            InsightsClient client      = new InsightsClient(credentials);

            var usageMetrics = client.UsageMetricOperations.List(resourceUri, filter);

            foreach (var usageMetric in usageMetrics.UsageMetricCollection.Value)
            {
                result.Add(new AzureResourceUsageMetric(usageMetric));
            }

            return(result);
        }
Beispiel #2
0
        public static List <AzureResourceMetric> GetMetrics(string token, string subscriptionId, string resourceUri, string filter, List <MetricDefinition> metricDefinitions)
        {
            var result = new List <AzureResourceMetric>();

            var            credentials = CredentialManager.GetCredentials(token, subscriptionId);
            InsightsClient client      = new InsightsClient(credentials);

            var metrics = client.MetricOperations.GetMetrics(resourceUri, filter, metricDefinitions);

            foreach (var metric in metrics.MetricCollection.Value)
            {
                result.Add(new AzureResourceMetric(metric));
            }

            return(result);
        }
Beispiel #3
0
        public static List <AzureResourceMetricDefinition> GetMetricDefinitions(string token, string subscriptionId, string resourceUri)
        {
            var result = new List <AzureResourceMetricDefinition>();

            var            credentials = CredentialManager.GetCredentials(token, subscriptionId);
            InsightsClient client      = new InsightsClient(credentials);

            var metricDefinitions = client.MetricDefinitionOperations.GetMetricDefinitionsAsync(resourceUri, "").Result;

            foreach (var metricDefinition in metricDefinitions.MetricDefinitionCollection.Value)
            {
                result.Add(new AzureResourceMetricDefinition(metricDefinition));
            }

            return(result);
        }
Beispiel #4
0
        public static List <AzureResourceEventData> GetEventData(string token, string subscriptionId, string resourceUri, DateTime startTime, DateTime endTime)
        {
            var result = new List <AzureResourceEventData>();

            string filterString = FilterString.Generate <ListEventsForResourceParameters>(eventData => (eventData.EventTimestamp >= startTime) && (eventData.EventTimestamp <= endTime) && (eventData.ResourceUri == resourceUri));

            var            credentials = CredentialManager.GetCredentials(token, subscriptionId);
            InsightsClient client      = new InsightsClient(credentials);

            EventDataListResponse response = client.EventOperations.ListEvents(filterString, selectedProperties: null);

            foreach (var eventEntry in response.EventDataCollection.Value)
            {
                result.Add(new AzureResourceEventData(eventEntry));
            }

            return(result);
        }
Beispiel #5
0
        public static List <AzureResourceGroup> GetResourceGroups(string token, string subscriptionId)
        {
            var credentials = CredentialManager.GetCredentials(token, subscriptionId);

            return(GetResourceGroups(credentials));
        }
Beispiel #6
0
        public static List <AzureSubscription> GetSubscriptions(string token)
        {
            var credentials = CredentialManager.GetCredentials(token);

            return(GetSubscriptions(credentials));
        }