/// <summary> /// Create an Autoscale setting rule based on the properties of the object /// </summary> /// <returns>A ScaleRule created based on the properties of the object</returns> public Management.Monitor.Management.Models.ScaleRule CreateSettingRule() { if (this.TimeWindow != default(TimeSpan) && this.TimeWindow < MinimumTimeWindow) { throw new ArgumentOutOfRangeException("TimeWindow", this.TimeWindow, ResourcesForAutoscaleCmdlets.MinimumTimeWindow1min); } if (this.TimeGrain < MinimumTimeGrain) { throw new ArgumentOutOfRangeException("TimeGrain", this.TimeGrain, ResourcesForAutoscaleCmdlets.MinimumTimeGrain1min); } var trigger = new Management.Monitor.Management.Models.MetricTrigger() { MetricName = this.MetricName, MetricResourceUri = this.MetricResourceId, OperatorProperty = this.Operator, Statistic = this.MetricStatistic, Threshold = this.Threshold, TimeAggregation = this.TimeAggregationOperator, TimeGrain = this.TimeGrain, TimeWindow = this.TimeWindow == default(TimeSpan) ? MinimumTimeWindow : this.TimeWindow, }; // Notice ChangeCount is (ScaleType)0, so this is the default in this version. It was the only value in the previous version. var action = new Management.Monitor.Management.Models.ScaleAction() { Cooldown = this.ScaleActionCooldown, Direction = this.ScaleActionDirection, Value = this.ScaleActionValue, Type = this.ScaleActionScaleType }; return(new Management.Monitor.Management.Models.ScaleRule(metricTrigger: trigger, scaleAction: action)); }
static public ScaleAction ConvertNamespace(Management.Monitor.Management.Models.ScaleAction scaleAction) { if (scaleAction == null) { return(null); } ScaleAction action = new ScaleAction( direction: ConvertNamespace(scaleAction.Direction), type: ConvertNamespace(scaleAction.Type), cooldown: scaleAction.Cooldown, value: scaleAction.Value); return(action); }