コード例 #1
0
        /// <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));
        }
コード例 #2
0
        static public MetricTrigger ConvertNamespace(Management.Monitor.Management.Models.MetricTrigger metricTrigger)
        {
            if (metricTrigger == null)
            {
                return(null);
            }

            MetricTrigger trigger = new MetricTrigger(
                metricName: metricTrigger.MetricName,
                metricResourceUri: metricTrigger.MetricResourceUri,
                timeGrain: metricTrigger.TimeGrain,
                statistic: ConvertNamespace(metricTrigger.Statistic),
                timeWindow: metricTrigger.TimeWindow,
                timeAggregation: ConvertNamespace(metricTrigger.TimeAggregation),
                operatorProperty: ConvertNamespace(metricTrigger.OperatorProperty),
                threshold: metricTrigger.Threshold);

            return(trigger);
        }