azureazure-autoscaling-block

Azure Auto Scaling management API


I am currently running a console application to update auto scaling on my azure subscription however I am running into issues with day and night profiles.

I am have two profiles that run for night and day for weekdays. I threw it together to play around with the api but I am getting wierd results.

var weekDayProfile = new AutoscaleProfile
        {

            Capacity = new ScaleCapacity
            {
                Default = settings.Default.ToString(),
                Maximum = settings.Maximum.ToString(),
                Minimum = settings.Minimum.ToString()
            },
            Name = "Day",
            Recurrence = new Recurrence
            {
                Frequency = RecurrenceFrequency.Week,
                Schedule = new RecurrentSchedule
                {
                    Days = new List<String> { "Monday", "Tuesday", "Wednesday", "Thursday", "Friday" },
                    Hours = { 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 },
                    Minutes = new List<int> { 0 },
                    TimeZone = "Central Standard Time"
                }
            },
            Rules = GenerateScaleRules(cloudServiceName, roleName, isProduction, settings)
        };
        settings.SetProfileSettings(ProfileEnum.NonProdWeekNight);
        var weekNightProfile = new AutoscaleProfile
        {
            Capacity = new ScaleCapacity
            {
                Default = settings.Default.ToString(),
                Maximum = settings.Maximum.ToString(),
                Minimum = settings.Minimum.ToString()
            },
            Name = "Night",
            Recurrence = new Recurrence
            {
                Frequency = RecurrenceFrequency.Week,
                Schedule = new RecurrentSchedule
                {
                    Days = new List<String> { "Monday", "Tuesday", "Wednesday", "Thursday", "Friday" },
                    Hours = {0, 1, 2, 3, 4, 5, 6, 7, 21, 22, 23},
                    Minutes = new List<int> { 0 },
                    TimeZone = "Central Standard Time"
                }
            },
            Rules = GenerateScaleRules(cloudServiceName, roleName, isProduction, settings)
        };
        settings.SetProfileSettings(ProfileEnum.NonProdWeekEnd);

Now when I load the profile into the cloud this shows up two profile but both of them are the exact same in every way. I am wondering if it is because my days are overlapping. I though this was possible since you can set day and night hours manually through the portal. Am I missing something like a switch or a setting.


Solution

  • Apparently I messed up the json around the errors. I miss understood what the Hours actually meant.

    Ran the application to grab the manual profile to match it up with the one I generate it seems hours isn't really hourS. Anyone who is doing this through api it is good to just down the profile and match it.

    AutoscaleClient autoscaleClient = new AutoscaleClient(new CertificateCloudCredentials(publishSettings.Id, publishSettings.Certificate));
    AutoscaleSettingGetResponse get = autoscaleClient.Settings.Get(AutoscaleResourceIdBuilder.BuildCloudServiceResourceId("<clound name", "role name", true));
    AutoscaleSetting setting = get.Setting;
    string profileJson = JsonConvert.SerializeObject(setting);
    Console.WriteLine(profileJson);