in arm-templates/sqlDwAutoScaler/SqlDwAutoScaler/ScaleSqlDw/ScaleSqlDw.cs [152:181]
public static bool IsInsideScaleUpScheduleTime()
{
var scheduleStartTimeString = ConfigurationManager.AppSettings["ScaleUpScheduleStartTime"];
var scheduleEndTimeString = ConfigurationManager.AppSettings["ScaleUpScheduleEndTime"];
// If they are not found in app settings, return false
if (string.IsNullOrEmpty(scheduleStartTimeString) || string.IsNullOrEmpty(scheduleEndTimeString))
{
return false;
}
string[] startTime = scheduleStartTimeString.Split(':');
string[] endTime = scheduleEndTimeString.Split(':');
// This is the time in Azure relative to the WEBSITE_TIME_ZONE setting
var current = DateTime.Now;
var scheduleStartTime = new DateTime(current.Year, current.Month, current.Day, Convert.ToInt32(startTime[0]), Convert.ToInt32(startTime[1]), 0, DateTimeKind.Local);
var scheduleEndTime = new DateTime(current.Year, current.Month, current.Day, Convert.ToInt32(endTime[0]), Convert.ToInt32(endTime[1]), 0, DateTimeKind.Local);
_logger.Info($"Scale up schedule start time is {scheduleStartTime}");
_logger.Info($"Scale up schedule end time is {scheduleEndTime}");
_logger.Info($"Current time is {current}");
// If current time is between schedule start time and schedule end time
if (DateTime.Compare(current, scheduleStartTime) >= 0 && DateTime.Compare(current, scheduleEndTime) <= 0)
{
return true;
}
return false;
}