private static void Main(string[] args) { _subscriptionId = args[0]; _thumbprint = args[1]; _alertEmailAddress = args[2]; _cloudServiceName = args[3]; _deploymentName = args[4]; SubscriptionCloudCredentials credentials = new CertificateCloudCredentials(_subscriptionId, GetStoreCertificate(_thumbprint)); var metricsClient = new MetricsClient(credentials); var resourceId = ResourceIdBuilder.BuildCloudServiceResourceId(_cloudServiceName, _deploymentName); Console.WriteLine("Resource Id: {0}", resourceId); GetMetricDefinitions(metricsClient, resourceId); var alertsClient = new AlertsClient(credentials); DisplayAzureAlertRules(alertsClient); var response = CreateAzureAlert(resourceId, alertsClient); Console.WriteLine("Create alert rule response: " + response.Result.StatusCode); Console.ReadLine(); }
public MetricValueListResponse GetMetricValues(string metricName, string metricNamespace) { var resourceId = ResourceIdBuilder.BuildCloudServiceResourceId(cloudServiceName, deploymentName); return(metricsClient.MetricValues.List(resourceId, new List <string> { metricName }, metricNamespace, TimeSpan.FromMinutes(5), DateTime.UtcNow.AddMinutes(-15), DateTime.UtcNow.AddMinutes(-5))); }
public MetricDefinitionListResponse GetMetrics() { var resourceId = ResourceIdBuilder.BuildCloudServiceResourceId(cloudServiceName, deploymentName); return(metricsClient.MetricDefinitions.List(resourceId, null, string.Empty)); }