private static AutoscaleSetting CreateAutoscaleSetting(string resourceUri, string metricName, string metricNamespace)
        {
            var capacity = new ScaleCapacity
            {
                Default = "1",
                Maximum = "100",
                Minimum = "1"
            };

            var fixedDate = new TimeWindow()
            {
                End = DateTime.Parse("2014-04-16T21:06:11.7882792Z"),
                Start = DateTime.Parse("2014-04-15T21:06:11.7882792Z"),
                TimeZone = TimeZoneInfo.Utc.Id.ToString()
            };

            var recurrence = new Recurrence()
            {
                Frequency = RecurrenceFrequency.Week,
                Schedule = new RecurrentSchedule()
                {
                    Days = new List<string> { "Monday" },
                    Hours = new List<int> { 0 },
                    Minutes = new int[] { 10 },
                    TimeZone = "UTC-11"
                }
            };

            var rules = new ScaleRule[]
            {
                new ScaleRule()
                {
                    MetricTrigger = new MetricTrigger
                    {
                        MetricName = metricName,
                        MetricNamespace = metricNamespace,
                        MetricResourceUri = resourceUri,
                        Operator = ComparisonOperationType.GreaterThan,
                        Statistic = MetricStatisticType.Average,
                        Threshold = 80.0,
                        TimeAggregation = TimeAggregationType.Maximum,
                        TimeGrain = TimeSpan.FromMinutes(1),
                        TimeWindow = TimeSpan.FromHours(1)
                    },
                    ScaleAction = new ScaleAction
                    {
                        Cooldown = TimeSpan.FromMinutes(20),
                        Direction = ScaleDirection.Increase,
                        Type = ScaleType.ExactCount,
                        Value = "10"
                    }
                }
            };

            AutoscaleSetting setting = new AutoscaleSetting
            {
                Name = "setting1",
                TargetResourceUri = resourceUri,
                Enabled = true,
                Profiles = new AutoscaleProfile[]
                {
                    new AutoscaleProfile()
                    {
                        Name = "Profile1",
                        Capacity = capacity,
                        FixedDate = fixedDate,
                        Recurrence = null,
                        Rules = rules
                    },
                    new AutoscaleProfile()
                    {
                        Name = "Profile2",
                        Capacity = capacity,
                        FixedDate = null,
                        Recurrence = recurrence,
                        Rules = rules
                    }
                }
            };

            return setting;
        }
Exemplo n.º 2
0
 /// <summary>
 /// Initializes a new instance of the AutoscaleProfile class.
 /// </summary>
 /// <param name="name">the name of the profile.</param>
 /// <param name="capacity">the number of instances that can be used
 /// during this profile.</param>
 /// <param name="rules">the collection of rules that provide the
 /// triggers and parameters for the scaling action. A maximum of 10
 /// rules can be specified.</param>
 /// <param name="fixedDate">the specific date-time for the profile.
 /// This element is not used if the Recurrence element is used.</param>
 /// <param name="recurrence">the repeating times at which this profile
 /// begins. This element is not used if the FixedDate element is
 /// used.</param>
 public AutoscaleProfile(string name, ScaleCapacity capacity, System.Collections.Generic.IList <ScaleRule> rules, TimeWindow fixedDate = default(TimeWindow), Recurrence recurrence = default(Recurrence))
 {
     Name       = name;
     Capacity   = capacity;
     Rules      = rules;
     FixedDate  = fixedDate;
     Recurrence = recurrence;
 }
 private static void AreEqual(Recurrence exp, Recurrence act)
 {
     if (exp != null)
     {
         Assert.Equal(exp.Frequency, act.Frequency);
         AreEqual(exp.Schedule, act.Schedule);
     }
 }