0

我目前正在运行一个控制台应用程序来更新我的 azure 订阅上的自动缩放,但是我遇到了日夜配置文件的问题。

我有两个配置文件,在工作日白天和晚上运行。我把它放在一起玩api,但我得到了奇怪的结果。

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);

现在,当我将配置文件加载到云中时,这会显示两个配置文件,但它们在各个方面都完全相同。我想知道是不是因为我的日子是重叠的。我认为这是可能的,因为您可以通过门户手动设置白天和黑夜时间。我是否缺少开关或设置之类的东西。

4

1 回答 1

0

显然我弄乱了错误周围的json。我想念时间的真正含义。

运行应用程序以获取手动配置文件以将其与我生成的配置文件相匹配,似乎 hours 并不是真正的 hour S。任何通过 api 执行此操作的人都可以将配置文件向下并匹配它。

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);
于 2015-02-19T17:51:26.637 回答