我目前正在运行一个控制台应用程序来更新我的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);
现在,当我将配置文件加载到云中时,这会显示两个配置文件,但它们在各方面都完全相同。我想知道是不是因为我的日子重叠了。我虽然这是可能的,因为您可以通过门户手动设置日夜时间。我错过了像开关或设置这样的东西。
答案 0 :(得分:0)
显然我把json搞砸了。我想念了小时的真正含义。
让应用程序抓住手动配置文件,将其与我生成的配置文件相匹配,似乎小时不是 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);