Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"autoscale_setting_resource_name": "{MyAutoscaleSettings}",
"location": "West US",
"tags": {},
"profiles": [
{
"name": "{AutoscaleProfile}",
"capacity": {
"minimum": "1",
"maximum": "5",
"default": "3"
},
"rules": [
{
"metric_trigger": {
"metric_name": "{name}",
"metric_resource_uri": "{FullyQualifiedAzureResourceID}",
"time_grain": "(duration in ISO8601 format)PT5M",
"statistic": "{Average|Min|Max|Sum}",
"time_window": "(duration in ISO8601 format)PT45M",
"time_aggregation": "{Average|Minimum|Maximum|Total|Count}",
"operator": "{Equals|NotEquals|GreaterThan|GreaterThanOrEqual|LessThan|LessThanOrEquals}",
"threshold": 100
},
"scale_action": {
"direction": "{None|Increase|Decrease}",
"type": "{ChangeCount|PercentChangeCount|ExactCount}",
"value": "2 (number of instances that are involved in the scaling)",
"cooldown": "(duration in ISO8601 format)PT20M"
}
}
]
}
],
"notifications": [],
"enabled": false,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same question: false or "false"?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

verified: this is a type bool

"target_resource_uri": "{FullyQualifiedAzureResourceID}"
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,14 @@
c.command('list', 'list_by_resource_group')
c.generic_update_command('update', 'get', 'create_or_update')

autoscale_settings_scaffold = create_service_adapter(
'azure.cli.command_modules.monitor.custom')

with ServiceGroup(__name__, get_monitor_autoscale_settings_operation,
autoscale_settings_scaffold) as s:
with s.group('monitor autoscale-settings') as c:
c.command('get-parameters-template', 'scaffold_autoscale_settings_parameters')


# DATA COMMANDS
event_categories_operations = create_service_adapter(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
# --------------------------------------------------------------------------------------------
from __future__ import print_function
import datetime
from azure.cli.core._util import CLIError
import os
from azure.cli.core._util import get_file_json, CLIError


# 1 hour in milliseconds
Expand Down Expand Up @@ -34,6 +35,7 @@ def _metric_names_filter_builder(metric_names=None):
return ' or '.join(filters)


# pylint: disable=too-many-arguments
def list_metrics(client, resource_id, time_grain,
start_time=None, end_time=None, metric_names=None):
'''Lists the metric values for a resource.
Expand Down Expand Up @@ -100,6 +102,7 @@ def _validate_start_time(start_time, end_time):
return result_time


# pylint: disable=too-many-arguments
def list_activity_logs(client, correlation_id=None, resource_group=None, resource_id=None,
resource_provider=None, start_time=None, end_time=None,
caller=None, status=None, max_events=50, select=None):
Expand Down Expand Up @@ -134,6 +137,7 @@ def list_activity_logs(client, correlation_id=None, resource_group=None, resourc
return _limit_results(activity_logs, max_events)


# pylint: disable=too-many-arguments
def _build_activity_logs_odata_filter(correlation_id=None, resource_group=None, resource_id=None,
resource_provider=None, start_time=None, end_time=None,
caller=None, status=None):
Expand Down Expand Up @@ -205,3 +209,21 @@ def _limit_results(paged, limit):
else:
break
return list(results)


def scaffold_autoscale_settings_parameters(client): # pylint: disable=unused-argument
'''Scaffold fully formed autoscale-settings' parameters as json template
'''
# Autoscale settings parameter scaffold file path
curr_dir = os.path.dirname(os.path.realpath(__file__))
autoscale_settings_parameter_file_path = os.path.join(
curr_dir, 'autoscale-parameters-template.json')

return _load_autoscale_settings_parameters(autoscale_settings_parameter_file_path)


def _load_autoscale_settings_parameters(file_path):
if not os.path.exists(file_path):
raise CLIError('File {} not found.'.format(file_path))

return get_file_json(file_path)
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@
c.expand('parameters', LogProfileProperties)

with ParametersContext(command='monitor autoscale-settings create') as c:
from azure.mgmt.monitor.models.autoscale_setting_resource import \
(AutoscaleSettingResource)

c.expand('parameters', AutoscaleSettingResource)
c.register('parameters', ('--parameters',),
type=json.loads,
help='JSON encoded parameters configuration. Use @{file} to load from a file.'
'Use az autoscale-settings get-parameters-template to export json template.')

with ParametersContext(command='monitor metric-definitions list') as c:
c.argument('metric_names', nargs='+')
Expand Down