簡體   English   中英

Azure Auto Scaling管理API

[英]Azure Auto Scaling management API

我目前正在運行一個控制台應用程序來更新我的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);

現在,當我將配置文件加載到雲中時,這會顯示兩個配置文件,但它們在各方面都完全相同。 我想知道是不是因為我的日子重疊了。 我雖然這是可能的,因為您可以通過門戶手動設置日夜時間。 我錯過了像開關或設置這樣的東西。

顯然我把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);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM