diff --git a/src/azure-cli/HISTORY.rst b/src/azure-cli/HISTORY.rst index 59fae05291c..7801ec4cecb 100644 --- a/src/azure-cli/HISTORY.rst +++ b/src/azure-cli/HISTORY.rst @@ -3,6 +3,13 @@ Release History =============== +Upcoming Release +++++++++++++++++ + +**Monitor** + +* `az monitor sli`: Add command group with `create`, `show`, `list`, `update`, and `delete` using `Microsoft.Monitor` preview API `2025-03-01-preview`. Only user-assigned managed identity is supported; system-assigned identity is not. Identity rotation is performed via `az monitor sli update --set 'identity.userAssignedIdentities={"":{}}'` plus matching `--set` updates on `destinationAmwAccounts[*].identity` and each `signalSources[*].sourceAmwAccountManagedIdentity`; see `az monitor sli update --help` for the full recipe. + 2.87.0 ++++++ diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/sli/__cmd_group.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/sli/__cmd_group.py new file mode 100644 index 00000000000..9eb555b1dce --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/sli/__cmd_group.py @@ -0,0 +1,40 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command_group( + "monitor sli", + is_preview=True, +) +class __CMDGroup(AAZCommandGroup): + """Manage Service Level Indicators (SLIs) in Azure Monitor. + + Identity model: SLIs only support user-assigned managed identities (UAMIs). + System-assigned identity is not supported by the service. A UAMI must be + referenced in three places that the service keeps in sync: + + 1. The ARM identity block (`identity.userAssignedIdentities`). + 2. Each destination AMW (`properties.destinationAmwAccounts[].identity`). + 3. Each signal source (`properties.sliProperties.{signals|goodSignals| + totalSignals}.signalSources[].sourceAmwAccountManagedIdentity`). + + The service rejects PUTs where these three sets disagree. To rotate a UAMI, + update all three surfaces in a single `az monitor sli update` call so the + PUT is atomic. See `az monitor sli update --help` for worked rotation + examples. Run `az monitor sli show` first to confirm the actual indices + and which signal slot (`signals` for window-based, `goodSignals` + + `totalSignals` for request-based) is populated. + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/sli/__init__.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/sli/__init__.py new file mode 100644 index 00000000000..754cbc4a253 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/sli/__init__.py @@ -0,0 +1,9 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa \ No newline at end of file diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/sli/_create.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/sli/_create.py new file mode 100644 index 00000000000..1048e254985 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/sli/_create.py @@ -0,0 +1,840 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor sli create", + is_preview=True, +) +class Create(AAZCommand): + """Create an SLI resource. + + A user-assigned managed identity is required and must match the identity + referenced by each destination AMW account and each signal source. Complex + object arguments (``--baseline-properties``, ``--destination-amw-accounts``, + ``--sli-properties``) are easiest to pass via JSON files using the + ``@filename.json`` syntax. + + :example: Create a window-based availability SLI from JSON payload files. + az monitor sli create --service-group-name MyServiceGroup --sli-name MySli --user-assigned --category Availability --evaluation-type WindowBased --description "API availability SLI" --baseline-properties @baseline.json --destination-amw-accounts @destinations.json --sli-properties @sli-properties.json + """ + + _aaz_info = { + "version": "2025-03-01-preview", + "resources": [ + ["mgmt-plane", "/providers/microsoft.management/servicegroups/{}/providers/microsoft.monitor/slis/{}", "2025-03-01-preview"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.service_group_name = AAZStrArg( + options=["--service-group-name"], + help="The name of the service group.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[A-Za-z0-9._()~-]{1,250}$", + ), + ) + _args_schema.sli_name = AAZStrArg( + options=["--sli-name"], + help="Name of the SLI that is given by the user.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9][a-zA-Z0-9_()~-]{2,63}$", + ), + ) + + # define Arg Group "Identity" + + _args_schema = cls._args_schema + _args_schema.mi_user_assigned = AAZListArg( + options=["--user-assigned", "--mi-user-assigned"], + arg_group="Identity", + help="Set the user managed identities. At least one user-assigned managed identity is required; system-assigned identity is not supported by this service.", + required=True, + blank=[], + ) + + mi_user_assigned = cls._args_schema.mi_user_assigned + mi_user_assigned.Element = AAZStrArg() + + # define Arg Group "Properties" + + _args_schema = cls._args_schema + _args_schema.baseline_properties = AAZObjectArg( + options=["--baseline-properties"], + arg_group="Properties", + help="Defines the SLO baseline associated with the SLI.", + ) + _args_schema.category = AAZStrArg( + options=["--category"], + arg_group="Properties", + help="Specifies the category of the SLI, used to classify signals such as Availability and Latency.", + enum={"Availability": "Availability", "Latency": "Latency"}, + ) + _args_schema.description = AAZStrArg( + options=["--description"], + arg_group="Properties", + help="A user-provided description of the SLI, with a maximum length of 1000 characters.", + fmt=AAZStrArgFormat( + pattern="^[\\s\\S]{0,1000}$", + ), + ) + _args_schema.destination_amw_accounts = AAZListArg( + options=["--destination-amw-accounts", "--amw-accounts"], + arg_group="Properties", + help="Destination AMW accounts.", + ) + _args_schema.enable_alert = AAZBoolArg( + options=["--enable-alert"], + arg_group="Properties", + help="A flag to determine whether alert is enabled.", + ) + _args_schema.evaluation_type = AAZStrArg( + options=["--evaluation-type"], + arg_group="Properties", + help="Determines how the SLI is evaluated—either based on request counts or time windows.", + enum={"RequestBased": "RequestBased", "WindowBased": "WindowBased"}, + ) + _args_schema.sli_properties = AAZObjectArg( + options=["--sli-properties"], + arg_group="Properties", + help="Defines the SLI properties associated with the SLI.", + ) + + baseline_properties = cls._args_schema.baseline_properties + baseline_properties.baseline = AAZObjectArg( + options=["baseline"], + help="Defines the baseline target, which is compared against the SLI value to determine compliance.", + required=True, + ) + + baseline = cls._args_schema.baseline_properties.baseline + baseline.evaluation_calculation_type = AAZStrArg( + options=["evaluation-calculation-type"], + help="Specifies how evaluation is calculated, either based on calendar days or a rolling window.", + required=True, + enum={"CalendarDays": "CalendarDays", "RollingDays": "RollingDays"}, + ) + baseline.evaluation_period_days = AAZIntArg( + options=["evaluation-period-days"], + help="The time frame (in days) used for SLI evaluation.", + required=True, + fmt=AAZIntArgFormat( + maximum=90, + minimum=1, + ), + ) + baseline.value = AAZFloatArg( + options=["value"], + help="The user-defined or Azure-defined target value used for comparison against the SLI value.", + required=True, + fmt=AAZFloatArgFormat( + maximum=100.0, + minimum=0.0, + ), + ) + + destination_amw_accounts = cls._args_schema.destination_amw_accounts + destination_amw_accounts.Element = AAZObjectArg() + + _element = cls._args_schema.destination_amw_accounts.Element + _element.identity = AAZResourceIdArg( + options=["identity"], + help="The ARM resource ID of the managed identity with access to the source account.", + required=True, + ) + _element.resource_id = AAZResourceIdArg( + options=["resource-id"], + help="The ARM resource ID of the account where metrics are emitted.", + required=True, + ) + + sli_properties = cls._args_schema.sli_properties + sli_properties.good_signals = AAZObjectArg( + options=["good-signals"], + help="Represents good signals used in request-based SLI calculations.", + ) + cls._build_args_signal_create(sli_properties.good_signals) + sli_properties.signals = AAZObjectArg( + options=["signals"], + help="Signals used for window-based SLI calculations.", + ) + cls._build_args_signal_create(sli_properties.signals) + sli_properties.total_signals = AAZObjectArg( + options=["total-signals"], + help="Represents total signals used in request-based SLI calculations.", + ) + cls._build_args_signal_create(sli_properties.total_signals) + sli_properties.window_uptime_criteria = AAZObjectArg( + options=["window-uptime-criteria"], + help="Defines the uptime criteria for window-based SLIs.", + ) + + window_uptime_criteria = cls._args_schema.sli_properties.window_uptime_criteria + window_uptime_criteria.comparator = AAZStrArg( + options=["comparator"], + help="Comparison operator used for uptime evaluation.", + required=True, + enum={"gt": "gt", "gte": "gte", "lt": "lt", "lte": "lte"}, + ) + window_uptime_criteria.target = AAZFloatArg( + options=["target"], + help="Threshold value used to determine uptime.", + required=True, + ) + return cls._args_schema + + _args_signal_create = None + + @classmethod + def _build_args_signal_create(cls, _schema): + if cls._args_signal_create is not None: + _schema.signal_formula = cls._args_signal_create.signal_formula + _schema.signal_sources = cls._args_signal_create.signal_sources + return + + cls._args_signal_create = AAZObjectArg() + + signal_create = cls._args_signal_create + signal_create.signal_formula = AAZStrArg( + options=["signal-formula"], + help="Mathematical formula used to combine multiple metrics.", + required=True, + ) + signal_create.signal_sources = AAZListArg( + options=["signal-sources"], + help="Sources of metrics used for SLIs.", + required=True, + ) + + signal_sources = cls._args_signal_create.signal_sources + signal_sources.Element = AAZObjectArg() + + _element = cls._args_signal_create.signal_sources.Element + _element.filters = AAZListArg( + options=["filters"], + help="Filters applied to modify signal values.", + required=True, + ) + _element.metric_name = AAZStrArg( + options=["metric-name"], + help="Name of the metric.", + required=True, + ) + _element.metric_namespace = AAZStrArg( + options=["metric-namespace"], + help="Namespace of the metric.", + required=True, + ) + _element.signal_source_id = AAZStrArg( + options=["signal-source-id"], + help="Unique identifier for the signal source.", + required=True, + ) + _element.source_amw_account_managed_identity = AAZResourceIdArg( + options=["source-amw-account-managed-identity"], + help="Managed identity for authenticating the signal source.", + required=True, + ) + _element.source_amw_account_resource_id = AAZResourceIdArg( + options=["source-amw-account-resource-id"], + help="Resource ID of the source AMW account.", + required=True, + ) + _element.spatial_aggregation = AAZObjectArg( + options=["spatial-aggregation"], + help="Defines how measurements are aggregated across multiple time series.", + required=True, + ) + _element.temporal_aggregation = AAZObjectArg( + options=["temporal-aggregation"], + help="Defines how measurements are aggregated over a specific time window within the same time series.", + required=True, + ) + + filters = cls._args_signal_create.signal_sources.Element.filters + filters.Element = AAZObjectArg() + + _element = cls._args_signal_create.signal_sources.Element.filters.Element + _element.dimension_name = AAZStrArg( + options=["dimension-name"], + help="Dimension name used in filtering.", + ) + _element.operator = AAZStrArg( + options=["operator"], + help="Operator used in the filtering condition.", + required=True, + enum={"contains": "contains", "eq": "eq", "gt": "gt", "gte": "gte", "in": "in", "lt": "lt", "lte": "lte", "ne": "ne", "notcontains": "notcontains", "notin": "notin", "notstartswith": "notstartswith", "startswith": "startswith"}, + ) + _element.sampling_type = AAZStrArg( + options=["sampling-type"], + help="Defines the sampling type.", + enum={"Average": "Average", "Count": "Count", "Max": "Max", "Min": "Min", "Sum": "Sum"}, + ) + _element.scalar_function = AAZStrArg( + options=["scalar-function"], + help="Scalar function applied for filtering.", + enum={"avg": "avg", "max": "max", "min": "min", "sum": "sum"}, + ) + _element.value = AAZStrArg( + options=["value"], + help="Value used in filtering.", + required=True, + ) + + spatial_aggregation = cls._args_signal_create.signal_sources.Element.spatial_aggregation + spatial_aggregation.dimensions = AAZListArg( + options=["dimensions"], + help="Dimensions considered for spatial aggregation.", + required=True, + ) + spatial_aggregation.type = AAZStrArg( + options=["type"], + help="Type of spatial aggregation.", + required=True, + enum={"Average": "Average", "Count": "Count", "Max": "Max", "Min": "Min", "Sum": "Sum"}, + ) + + dimensions = cls._args_signal_create.signal_sources.Element.spatial_aggregation.dimensions + dimensions.Element = AAZStrArg() + + temporal_aggregation = cls._args_signal_create.signal_sources.Element.temporal_aggregation + temporal_aggregation.type = AAZStrArg( + options=["type"], + help="Type of temporal aggregation.", + required=True, + enum={"Average": "Average", "Delta": "Delta", "IDelta": "IDelta", "IRate": "IRate", "Increase": "Increase", "Max": "Max", "Min": "Min", "Rate": "Rate", "Sum": "Sum"}, + ) + temporal_aggregation.window_size_minutes = AAZIntArg( + options=["window-size-minutes"], + help="Time window size for aggregation, in minutes.", + ) + + _schema.signal_formula = cls._args_signal_create.signal_formula + _schema.signal_sources = cls._args_signal_create.signal_sources + + def _execute_operations(self): + self.pre_operations() + self.SlisCreateOrUpdate(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class SlisCreateOrUpdate(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200, 201]: + return self.on_200_201(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Management/serviceGroups/{serviceGroupName}/providers/Microsoft.Monitor/slis/{sliName}", + **self.url_parameters + ) + + @property + def method(self): + return "PUT" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "serviceGroupName", self.ctx.args.service_group_name, + required=True, + ), + **self.serialize_url_param( + "sliName", self.ctx.args.sli_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2025-03-01-preview", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + typ=AAZObjectType, + typ_kwargs={"flags": {"required": True, "client_flatten": True}} + ) + _builder.set_prop("identity", AAZIdentityObjectType) + _builder.set_prop("properties", AAZObjectType) + + identity = _builder.get(".identity") + if identity is not None: + identity.set_prop("userAssigned", AAZListType, ".mi_user_assigned", typ_kwargs={"flags": {"action": "create"}}) + + user_assigned = _builder.get(".identity.userAssigned") + if user_assigned is not None: + user_assigned.set_elements(AAZStrType, ".") + + properties = _builder.get(".properties") + if properties is not None: + properties.set_prop("baselineProperties", AAZObjectType, ".baseline_properties", typ_kwargs={"flags": {"required": True}}) + properties.set_prop("category", AAZStrType, ".category", typ_kwargs={"flags": {"required": True}}) + properties.set_prop("description", AAZStrType, ".description", typ_kwargs={"flags": {"required": True}}) + properties.set_prop("destinationAmwAccounts", AAZListType, ".destination_amw_accounts", typ_kwargs={"flags": {"required": True}}) + properties.set_prop("enableAlert", AAZBoolType, ".enable_alert", typ_kwargs={"flags": {"required": True}}) + properties.set_prop("evaluationType", AAZStrType, ".evaluation_type", typ_kwargs={"flags": {"required": True}}) + properties.set_prop("sliProperties", AAZObjectType, ".sli_properties", typ_kwargs={"flags": {"required": True}}) + + baseline_properties = _builder.get(".properties.baselineProperties") + if baseline_properties is not None: + baseline_properties.set_prop("baseline", AAZObjectType, ".baseline", typ_kwargs={"flags": {"required": True}}) + + baseline = _builder.get(".properties.baselineProperties.baseline") + if baseline is not None: + baseline.set_prop("evaluationCalculationType", AAZStrType, ".evaluation_calculation_type", typ_kwargs={"flags": {"required": True}}) + baseline.set_prop("evaluationPeriodDays", AAZIntType, ".evaluation_period_days", typ_kwargs={"flags": {"required": True}}) + baseline.set_prop("value", AAZFloatType, ".value", typ_kwargs={"flags": {"required": True}}) + + destination_amw_accounts = _builder.get(".properties.destinationAmwAccounts") + if destination_amw_accounts is not None: + destination_amw_accounts.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".properties.destinationAmwAccounts[]") + if _elements is not None: + _elements.set_prop("identity", AAZStrType, ".identity", typ_kwargs={"flags": {"required": True}}) + _elements.set_prop("resourceId", AAZStrType, ".resource_id", typ_kwargs={"flags": {"required": True}}) + + sli_properties = _builder.get(".properties.sliProperties") + if sli_properties is not None: + _CreateHelper._build_schema_signal_create(sli_properties.set_prop("goodSignals", AAZObjectType, ".good_signals")) + _CreateHelper._build_schema_signal_create(sli_properties.set_prop("signals", AAZObjectType, ".signals")) + _CreateHelper._build_schema_signal_create(sli_properties.set_prop("totalSignals", AAZObjectType, ".total_signals")) + sli_properties.set_prop("windowUptimeCriteria", AAZObjectType, ".window_uptime_criteria") + + window_uptime_criteria = _builder.get(".properties.sliProperties.windowUptimeCriteria") + if window_uptime_criteria is not None: + window_uptime_criteria.set_prop("comparator", AAZStrType, ".comparator", typ_kwargs={"flags": {"required": True}}) + window_uptime_criteria.set_prop("target", AAZFloatType, ".target", typ_kwargs={"flags": {"required": True}}) + + return self.serialize_content(_content_value) + + def on_200_201(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200_201 + ) + + _schema_on_200_201 = None + + @classmethod + def _build_schema_on_200_201(cls): + if cls._schema_on_200_201 is not None: + return cls._schema_on_200_201 + + cls._schema_on_200_201 = AAZObjectType() + + _schema_on_200_201 = cls._schema_on_200_201 + _schema_on_200_201.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200_201.identity = AAZIdentityObjectType() + _schema_on_200_201.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200_201.properties = AAZObjectType() + _schema_on_200_201.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200_201.type = AAZStrType( + flags={"read_only": True}, + ) + + identity = cls._schema_on_200_201.identity + identity.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + identity.tenant_id = AAZStrType( + serialized_name="tenantId", + flags={"read_only": True}, + ) + identity.type = AAZStrType( + flags={"required": True}, + ) + identity.user_assigned_identities = AAZDictType( + serialized_name="userAssignedIdentities", + ) + + user_assigned_identities = cls._schema_on_200_201.identity.user_assigned_identities + user_assigned_identities.Element = AAZObjectType( + nullable=True, + ) + + _element = cls._schema_on_200_201.identity.user_assigned_identities.Element + _element.client_id = AAZStrType( + serialized_name="clientId", + flags={"read_only": True}, + ) + _element.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + + properties = cls._schema_on_200_201.properties + properties.baseline_properties = AAZObjectType( + serialized_name="baselineProperties", + flags={"required": True}, + ) + properties.category = AAZStrType( + flags={"required": True}, + ) + properties.description = AAZStrType( + flags={"required": True}, + ) + properties.destination_amw_accounts = AAZListType( + serialized_name="destinationAmwAccounts", + flags={"required": True}, + ) + properties.destination_metrics = AAZListType( + serialized_name="destinationMetrics", + flags={"read_only": True}, + ) + properties.enable_alert = AAZBoolType( + serialized_name="enableAlert", + flags={"required": True}, + ) + properties.evaluation_type = AAZStrType( + serialized_name="evaluationType", + flags={"required": True}, + ) + properties.execution_state = AAZObjectType( + serialized_name="executionState", + flags={"read_only": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.sli_properties = AAZObjectType( + serialized_name="sliProperties", + flags={"required": True}, + ) + properties.streaming_rule_id = AAZStrType( + serialized_name="streamingRuleId", + flags={"read_only": True}, + ) + properties.streaming_rule_last_updated_timestamp = AAZStrType( + serialized_name="streamingRuleLastUpdatedTimestamp", + flags={"read_only": True}, + ) + + baseline_properties = cls._schema_on_200_201.properties.baseline_properties + baseline_properties.baseline = AAZObjectType( + flags={"required": True}, + ) + + baseline = cls._schema_on_200_201.properties.baseline_properties.baseline + baseline.evaluation_calculation_type = AAZStrType( + serialized_name="evaluationCalculationType", + flags={"required": True}, + ) + baseline.evaluation_period_days = AAZIntType( + serialized_name="evaluationPeriodDays", + flags={"required": True}, + ) + baseline.value = AAZFloatType( + flags={"required": True}, + ) + + destination_amw_accounts = cls._schema_on_200_201.properties.destination_amw_accounts + destination_amw_accounts.Element = AAZObjectType() + + _element = cls._schema_on_200_201.properties.destination_amw_accounts.Element + _element.identity = AAZStrType( + flags={"required": True}, + ) + _element.resource_id = AAZStrType( + serialized_name="resourceId", + flags={"required": True}, + ) + + destination_metrics = cls._schema_on_200_201.properties.destination_metrics + destination_metrics.Element = AAZObjectType() + + _element = cls._schema_on_200_201.properties.destination_metrics.Element + _element.metric_name = AAZStrType( + serialized_name="metricName", + flags={"required": True}, + ) + _element.metric_namespace = AAZStrType( + serialized_name="metricNamespace", + flags={"required": True}, + ) + + execution_state = cls._schema_on_200_201.properties.execution_state + execution_state.message = AAZStrType() + execution_state.state = AAZStrType( + flags={"required": True}, + ) + + sli_properties = cls._schema_on_200_201.properties.sli_properties + sli_properties.good_signals = AAZObjectType( + serialized_name="goodSignals", + ) + _CreateHelper._build_schema_signal_read(sli_properties.good_signals) + sli_properties.signals = AAZObjectType() + _CreateHelper._build_schema_signal_read(sli_properties.signals) + sli_properties.total_signals = AAZObjectType( + serialized_name="totalSignals", + ) + _CreateHelper._build_schema_signal_read(sli_properties.total_signals) + sli_properties.window_uptime_criteria = AAZObjectType( + serialized_name="windowUptimeCriteria", + ) + + window_uptime_criteria = cls._schema_on_200_201.properties.sli_properties.window_uptime_criteria + window_uptime_criteria.comparator = AAZStrType( + flags={"required": True}, + ) + window_uptime_criteria.target = AAZFloatType( + flags={"required": True}, + ) + + system_data = cls._schema_on_200_201.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + return cls._schema_on_200_201 + + +class _CreateHelper: + """Helper class for Create""" + + @classmethod + def _build_schema_signal_create(cls, _builder): + if _builder is None: + return + _builder.set_prop("signalFormula", AAZStrType, ".signal_formula", typ_kwargs={"flags": {"required": True}}) + _builder.set_prop("signalSources", AAZListType, ".signal_sources", typ_kwargs={"flags": {"required": True}}) + + signal_sources = _builder.get(".signalSources") + if signal_sources is not None: + signal_sources.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".signalSources[]") + if _elements is not None: + _elements.set_prop("filters", AAZListType, ".filters", typ_kwargs={"flags": {"required": True}}) + _elements.set_prop("metricName", AAZStrType, ".metric_name", typ_kwargs={"flags": {"required": True}}) + _elements.set_prop("metricNamespace", AAZStrType, ".metric_namespace", typ_kwargs={"flags": {"required": True}}) + _elements.set_prop("signalSourceId", AAZStrType, ".signal_source_id", typ_kwargs={"flags": {"required": True}}) + _elements.set_prop("sourceAmwAccountManagedIdentity", AAZStrType, ".source_amw_account_managed_identity", typ_kwargs={"flags": {"required": True}}) + _elements.set_prop("sourceAmwAccountResourceId", AAZStrType, ".source_amw_account_resource_id", typ_kwargs={"flags": {"required": True}}) + _elements.set_prop("spatialAggregation", AAZObjectType, ".spatial_aggregation", typ_kwargs={"flags": {"required": True}}) + _elements.set_prop("temporalAggregation", AAZObjectType, ".temporal_aggregation", typ_kwargs={"flags": {"required": True}}) + + filters = _builder.get(".signalSources[].filters") + if filters is not None: + filters.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".signalSources[].filters[]") + if _elements is not None: + _elements.set_prop("dimensionName", AAZStrType, ".dimension_name") + _elements.set_prop("operator", AAZStrType, ".operator", typ_kwargs={"flags": {"required": True}}) + _elements.set_prop("samplingType", AAZStrType, ".sampling_type") + _elements.set_prop("scalarFunction", AAZStrType, ".scalar_function") + _elements.set_prop("value", AAZStrType, ".value", typ_kwargs={"flags": {"required": True}}) + + spatial_aggregation = _builder.get(".signalSources[].spatialAggregation") + if spatial_aggregation is not None: + spatial_aggregation.set_prop("dimensions", AAZListType, ".dimensions", typ_kwargs={"flags": {"required": True}}) + spatial_aggregation.set_prop("type", AAZStrType, ".type", typ_kwargs={"flags": {"required": True}}) + + dimensions = _builder.get(".signalSources[].spatialAggregation.dimensions") + if dimensions is not None: + dimensions.set_elements(AAZStrType, ".") + + temporal_aggregation = _builder.get(".signalSources[].temporalAggregation") + if temporal_aggregation is not None: + temporal_aggregation.set_prop("type", AAZStrType, ".type", typ_kwargs={"flags": {"required": True}}) + temporal_aggregation.set_prop("windowSizeMinutes", AAZIntType, ".window_size_minutes") + + _schema_signal_read = None + + @classmethod + def _build_schema_signal_read(cls, _schema): + if cls._schema_signal_read is not None: + _schema.signal_formula = cls._schema_signal_read.signal_formula + _schema.signal_sources = cls._schema_signal_read.signal_sources + return + + cls._schema_signal_read = _schema_signal_read = AAZObjectType() + + signal_read = _schema_signal_read + signal_read.signal_formula = AAZStrType( + serialized_name="signalFormula", + flags={"required": True}, + ) + signal_read.signal_sources = AAZListType( + serialized_name="signalSources", + flags={"required": True}, + ) + + signal_sources = _schema_signal_read.signal_sources + signal_sources.Element = AAZObjectType() + + _element = _schema_signal_read.signal_sources.Element + _element.filters = AAZListType( + flags={"required": True}, + ) + _element.metric_name = AAZStrType( + serialized_name="metricName", + flags={"required": True}, + ) + _element.metric_namespace = AAZStrType( + serialized_name="metricNamespace", + flags={"required": True}, + ) + _element.signal_source_id = AAZStrType( + serialized_name="signalSourceId", + flags={"required": True}, + ) + _element.source_amw_account_managed_identity = AAZStrType( + serialized_name="sourceAmwAccountManagedIdentity", + flags={"required": True}, + ) + _element.source_amw_account_resource_id = AAZStrType( + serialized_name="sourceAmwAccountResourceId", + flags={"required": True}, + ) + _element.spatial_aggregation = AAZObjectType( + serialized_name="spatialAggregation", + flags={"required": True}, + ) + _element.temporal_aggregation = AAZObjectType( + serialized_name="temporalAggregation", + flags={"required": True}, + ) + + filters = _schema_signal_read.signal_sources.Element.filters + filters.Element = AAZObjectType() + + _element = _schema_signal_read.signal_sources.Element.filters.Element + _element.dimension_name = AAZStrType( + serialized_name="dimensionName", + ) + _element.operator = AAZStrType( + flags={"required": True}, + ) + _element.sampling_type = AAZStrType( + serialized_name="samplingType", + ) + _element.scalar_function = AAZStrType( + serialized_name="scalarFunction", + ) + _element.value = AAZStrType( + flags={"required": True}, + ) + + spatial_aggregation = _schema_signal_read.signal_sources.Element.spatial_aggregation + spatial_aggregation.dimensions = AAZListType( + flags={"required": True}, + ) + spatial_aggregation.type = AAZStrType( + flags={"required": True}, + ) + + dimensions = _schema_signal_read.signal_sources.Element.spatial_aggregation.dimensions + dimensions.Element = AAZStrType() + + temporal_aggregation = _schema_signal_read.signal_sources.Element.temporal_aggregation + temporal_aggregation.type = AAZStrType( + flags={"required": True}, + ) + temporal_aggregation.window_size_minutes = AAZIntType( + serialized_name="windowSizeMinutes", + ) + + _schema.signal_formula = cls._schema_signal_read.signal_formula + _schema.signal_sources = cls._schema_signal_read.signal_sources + + +__all__ = ["Create"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/sli/_delete.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/sli/_delete.py new file mode 100644 index 00000000000..bb0e27f0cdc --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/sli/_delete.py @@ -0,0 +1,143 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor sli delete", + confirmation="Are you sure you want to perform this operation?", + is_preview=True, +) +class Delete(AAZCommand): + """Delete an SLI resource. + + :example: Delete an SLI without confirmation prompt. + az monitor sli delete --service-group-name MyServiceGroup --sli-name MySli --yes + """ + + _aaz_info = { + "version": "2025-03-01-preview", + "resources": [ + ["mgmt-plane", "/providers/microsoft.management/servicegroups/{}/providers/microsoft.monitor/slis/{}", "2025-03-01-preview"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return None + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.service_group_name = AAZStrArg( + options=["--service-group-name"], + help="The name of the service group.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[A-Za-z0-9._()~-]{1,250}$", + ), + ) + _args_schema.sli_name = AAZStrArg( + options=["--sli-name"], + help="Name of the SLI that is given by the user.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9][a-zA-Z0-9_()~-]{2,63}$", + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.SlisDelete(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + class SlisDelete(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + if session.http_response.status_code in [204]: + return self.on_204(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Management/serviceGroups/{serviceGroupName}/providers/Microsoft.Monitor/slis/{sliName}", + **self.url_parameters + ) + + @property + def method(self): + return "DELETE" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "serviceGroupName", self.ctx.args.service_group_name, + required=True, + ), + **self.serialize_url_param( + "sliName", self.ctx.args.sli_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2025-03-01-preview", + required=True, + ), + } + return parameters + + def on_200(self, session): + pass + + def on_204(self, session): + pass + + +class _DeleteHelper: + """Helper class for Delete""" + + +__all__ = ["Delete"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/sli/_list.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/sli/_list.py new file mode 100644 index 00000000000..cfb30814f56 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/sli/_list.py @@ -0,0 +1,454 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor sli list", + is_preview=True, +) +class List(AAZCommand): + """List all SLI resources under a parent resource. + + :example: List all SLIs in a service group. + az monitor sli list --service-group-name MyServiceGroup + """ + + _aaz_info = { + "version": "2025-03-01-preview", + "resources": [ + ["mgmt-plane", "/providers/microsoft.management/servicegroups/{}/providers/microsoft.monitor/slis", "2025-03-01-preview"], + ] + } + + AZ_SUPPORT_PAGINATION = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_paging(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.service_group_name = AAZStrArg( + options=["--service-group-name"], + help="The name of the service group.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[A-Za-z0-9._()~-]{1,250}$", + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.SlisListByParent(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance.value, client_flatten=True) + next_link = self.deserialize_output(self.ctx.vars.instance.next_link) + return result, next_link + + class SlisListByParent(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Management/serviceGroups/{serviceGroupName}/providers/Microsoft.Monitor/slis", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "serviceGroupName", self.ctx.args.service_group_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2025-03-01-preview", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + ) + _schema_on_200.value = AAZListType( + flags={"required": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.identity = AAZIdentityObjectType() + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType() + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + identity = cls._schema_on_200.value.Element.identity + identity.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + identity.tenant_id = AAZStrType( + serialized_name="tenantId", + flags={"read_only": True}, + ) + identity.type = AAZStrType( + flags={"required": True}, + ) + identity.user_assigned_identities = AAZDictType( + serialized_name="userAssignedIdentities", + ) + + user_assigned_identities = cls._schema_on_200.value.Element.identity.user_assigned_identities + user_assigned_identities.Element = AAZObjectType( + nullable=True, + ) + + _element = cls._schema_on_200.value.Element.identity.user_assigned_identities.Element + _element.client_id = AAZStrType( + serialized_name="clientId", + flags={"read_only": True}, + ) + _element.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.baseline_properties = AAZObjectType( + serialized_name="baselineProperties", + flags={"required": True}, + ) + properties.category = AAZStrType( + flags={"required": True}, + ) + properties.description = AAZStrType( + flags={"required": True}, + ) + properties.destination_amw_accounts = AAZListType( + serialized_name="destinationAmwAccounts", + flags={"required": True}, + ) + properties.destination_metrics = AAZListType( + serialized_name="destinationMetrics", + flags={"read_only": True}, + ) + properties.enable_alert = AAZBoolType( + serialized_name="enableAlert", + flags={"required": True}, + ) + properties.evaluation_type = AAZStrType( + serialized_name="evaluationType", + flags={"required": True}, + ) + properties.execution_state = AAZObjectType( + serialized_name="executionState", + flags={"read_only": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.sli_properties = AAZObjectType( + serialized_name="sliProperties", + flags={"required": True}, + ) + properties.streaming_rule_id = AAZStrType( + serialized_name="streamingRuleId", + flags={"read_only": True}, + ) + properties.streaming_rule_last_updated_timestamp = AAZStrType( + serialized_name="streamingRuleLastUpdatedTimestamp", + flags={"read_only": True}, + ) + + baseline_properties = cls._schema_on_200.value.Element.properties.baseline_properties + baseline_properties.baseline = AAZObjectType( + flags={"required": True}, + ) + + baseline = cls._schema_on_200.value.Element.properties.baseline_properties.baseline + baseline.evaluation_calculation_type = AAZStrType( + serialized_name="evaluationCalculationType", + flags={"required": True}, + ) + baseline.evaluation_period_days = AAZIntType( + serialized_name="evaluationPeriodDays", + flags={"required": True}, + ) + baseline.value = AAZFloatType( + flags={"required": True}, + ) + + destination_amw_accounts = cls._schema_on_200.value.Element.properties.destination_amw_accounts + destination_amw_accounts.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.destination_amw_accounts.Element + _element.identity = AAZStrType( + flags={"required": True}, + ) + _element.resource_id = AAZStrType( + serialized_name="resourceId", + flags={"required": True}, + ) + + destination_metrics = cls._schema_on_200.value.Element.properties.destination_metrics + destination_metrics.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.destination_metrics.Element + _element.metric_name = AAZStrType( + serialized_name="metricName", + flags={"required": True}, + ) + _element.metric_namespace = AAZStrType( + serialized_name="metricNamespace", + flags={"required": True}, + ) + + execution_state = cls._schema_on_200.value.Element.properties.execution_state + execution_state.message = AAZStrType() + execution_state.state = AAZStrType( + flags={"required": True}, + ) + + sli_properties = cls._schema_on_200.value.Element.properties.sli_properties + sli_properties.good_signals = AAZObjectType( + serialized_name="goodSignals", + ) + _ListHelper._build_schema_signal_read(sli_properties.good_signals) + sli_properties.signals = AAZObjectType() + _ListHelper._build_schema_signal_read(sli_properties.signals) + sli_properties.total_signals = AAZObjectType( + serialized_name="totalSignals", + ) + _ListHelper._build_schema_signal_read(sli_properties.total_signals) + sli_properties.window_uptime_criteria = AAZObjectType( + serialized_name="windowUptimeCriteria", + ) + + window_uptime_criteria = cls._schema_on_200.value.Element.properties.sli_properties.window_uptime_criteria + window_uptime_criteria.comparator = AAZStrType( + flags={"required": True}, + ) + window_uptime_criteria.target = AAZFloatType( + flags={"required": True}, + ) + + system_data = cls._schema_on_200.value.Element.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + return cls._schema_on_200 + + +class _ListHelper: + """Helper class for List""" + + _schema_signal_read = None + + @classmethod + def _build_schema_signal_read(cls, _schema): + if cls._schema_signal_read is not None: + _schema.signal_formula = cls._schema_signal_read.signal_formula + _schema.signal_sources = cls._schema_signal_read.signal_sources + return + + cls._schema_signal_read = _schema_signal_read = AAZObjectType() + + signal_read = _schema_signal_read + signal_read.signal_formula = AAZStrType( + serialized_name="signalFormula", + flags={"required": True}, + ) + signal_read.signal_sources = AAZListType( + serialized_name="signalSources", + flags={"required": True}, + ) + + signal_sources = _schema_signal_read.signal_sources + signal_sources.Element = AAZObjectType() + + _element = _schema_signal_read.signal_sources.Element + _element.filters = AAZListType( + flags={"required": True}, + ) + _element.metric_name = AAZStrType( + serialized_name="metricName", + flags={"required": True}, + ) + _element.metric_namespace = AAZStrType( + serialized_name="metricNamespace", + flags={"required": True}, + ) + _element.signal_source_id = AAZStrType( + serialized_name="signalSourceId", + flags={"required": True}, + ) + _element.source_amw_account_managed_identity = AAZStrType( + serialized_name="sourceAmwAccountManagedIdentity", + flags={"required": True}, + ) + _element.source_amw_account_resource_id = AAZStrType( + serialized_name="sourceAmwAccountResourceId", + flags={"required": True}, + ) + _element.spatial_aggregation = AAZObjectType( + serialized_name="spatialAggregation", + flags={"required": True}, + ) + _element.temporal_aggregation = AAZObjectType( + serialized_name="temporalAggregation", + flags={"required": True}, + ) + + filters = _schema_signal_read.signal_sources.Element.filters + filters.Element = AAZObjectType() + + _element = _schema_signal_read.signal_sources.Element.filters.Element + _element.dimension_name = AAZStrType( + serialized_name="dimensionName", + ) + _element.operator = AAZStrType( + flags={"required": True}, + ) + _element.sampling_type = AAZStrType( + serialized_name="samplingType", + ) + _element.scalar_function = AAZStrType( + serialized_name="scalarFunction", + ) + _element.value = AAZStrType( + flags={"required": True}, + ) + + spatial_aggregation = _schema_signal_read.signal_sources.Element.spatial_aggregation + spatial_aggregation.dimensions = AAZListType( + flags={"required": True}, + ) + spatial_aggregation.type = AAZStrType( + flags={"required": True}, + ) + + dimensions = _schema_signal_read.signal_sources.Element.spatial_aggregation.dimensions + dimensions.Element = AAZStrType() + + temporal_aggregation = _schema_signal_read.signal_sources.Element.temporal_aggregation + temporal_aggregation.type = AAZStrType( + flags={"required": True}, + ) + temporal_aggregation.window_size_minutes = AAZIntType( + serialized_name="windowSizeMinutes", + ) + + _schema.signal_formula = cls._schema_signal_read.signal_formula + _schema.signal_sources = cls._schema_signal_read.signal_sources + + +__all__ = ["List"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/sli/_show.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/sli/_show.py new file mode 100644 index 00000000000..3fa188c88ca --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/sli/_show.py @@ -0,0 +1,453 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor sli show", + is_preview=True, +) +class Show(AAZCommand): + """Get an SLI resource. + + :example: Show an SLI by name. + az monitor sli show --service-group-name MyServiceGroup --sli-name MySli + """ + + _aaz_info = { + "version": "2025-03-01-preview", + "resources": [ + ["mgmt-plane", "/providers/microsoft.management/servicegroups/{}/providers/microsoft.monitor/slis/{}", "2025-03-01-preview"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.service_group_name = AAZStrArg( + options=["--service-group-name"], + help="The name of the service group.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[A-Za-z0-9._()~-]{1,250}$", + ), + ) + _args_schema.sli_name = AAZStrArg( + options=["--sli-name"], + help="Name of the SLI that is given by the user.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9][a-zA-Z0-9_()~-]{2,63}$", + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.SlisGet(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class SlisGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Management/serviceGroups/{serviceGroupName}/providers/Microsoft.Monitor/slis/{sliName}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "serviceGroupName", self.ctx.args.service_group_name, + required=True, + ), + **self.serialize_url_param( + "sliName", self.ctx.args.sli_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2025-03-01-preview", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.identity = AAZIdentityObjectType() + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType() + _schema_on_200.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + identity = cls._schema_on_200.identity + identity.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + identity.tenant_id = AAZStrType( + serialized_name="tenantId", + flags={"read_only": True}, + ) + identity.type = AAZStrType( + flags={"required": True}, + ) + identity.user_assigned_identities = AAZDictType( + serialized_name="userAssignedIdentities", + ) + + user_assigned_identities = cls._schema_on_200.identity.user_assigned_identities + user_assigned_identities.Element = AAZObjectType( + nullable=True, + ) + + _element = cls._schema_on_200.identity.user_assigned_identities.Element + _element.client_id = AAZStrType( + serialized_name="clientId", + flags={"read_only": True}, + ) + _element.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.baseline_properties = AAZObjectType( + serialized_name="baselineProperties", + flags={"required": True}, + ) + properties.category = AAZStrType( + flags={"required": True}, + ) + properties.description = AAZStrType( + flags={"required": True}, + ) + properties.destination_amw_accounts = AAZListType( + serialized_name="destinationAmwAccounts", + flags={"required": True}, + ) + properties.destination_metrics = AAZListType( + serialized_name="destinationMetrics", + flags={"read_only": True}, + ) + properties.enable_alert = AAZBoolType( + serialized_name="enableAlert", + flags={"required": True}, + ) + properties.evaluation_type = AAZStrType( + serialized_name="evaluationType", + flags={"required": True}, + ) + properties.execution_state = AAZObjectType( + serialized_name="executionState", + flags={"read_only": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.sli_properties = AAZObjectType( + serialized_name="sliProperties", + flags={"required": True}, + ) + properties.streaming_rule_id = AAZStrType( + serialized_name="streamingRuleId", + flags={"read_only": True}, + ) + properties.streaming_rule_last_updated_timestamp = AAZStrType( + serialized_name="streamingRuleLastUpdatedTimestamp", + flags={"read_only": True}, + ) + + baseline_properties = cls._schema_on_200.properties.baseline_properties + baseline_properties.baseline = AAZObjectType( + flags={"required": True}, + ) + + baseline = cls._schema_on_200.properties.baseline_properties.baseline + baseline.evaluation_calculation_type = AAZStrType( + serialized_name="evaluationCalculationType", + flags={"required": True}, + ) + baseline.evaluation_period_days = AAZIntType( + serialized_name="evaluationPeriodDays", + flags={"required": True}, + ) + baseline.value = AAZFloatType( + flags={"required": True}, + ) + + destination_amw_accounts = cls._schema_on_200.properties.destination_amw_accounts + destination_amw_accounts.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.destination_amw_accounts.Element + _element.identity = AAZStrType( + flags={"required": True}, + ) + _element.resource_id = AAZStrType( + serialized_name="resourceId", + flags={"required": True}, + ) + + destination_metrics = cls._schema_on_200.properties.destination_metrics + destination_metrics.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.destination_metrics.Element + _element.metric_name = AAZStrType( + serialized_name="metricName", + flags={"required": True}, + ) + _element.metric_namespace = AAZStrType( + serialized_name="metricNamespace", + flags={"required": True}, + ) + + execution_state = cls._schema_on_200.properties.execution_state + execution_state.message = AAZStrType() + execution_state.state = AAZStrType( + flags={"required": True}, + ) + + sli_properties = cls._schema_on_200.properties.sli_properties + sli_properties.good_signals = AAZObjectType( + serialized_name="goodSignals", + ) + _ShowHelper._build_schema_signal_read(sli_properties.good_signals) + sli_properties.signals = AAZObjectType() + _ShowHelper._build_schema_signal_read(sli_properties.signals) + sli_properties.total_signals = AAZObjectType( + serialized_name="totalSignals", + ) + _ShowHelper._build_schema_signal_read(sli_properties.total_signals) + sli_properties.window_uptime_criteria = AAZObjectType( + serialized_name="windowUptimeCriteria", + ) + + window_uptime_criteria = cls._schema_on_200.properties.sli_properties.window_uptime_criteria + window_uptime_criteria.comparator = AAZStrType( + flags={"required": True}, + ) + window_uptime_criteria.target = AAZFloatType( + flags={"required": True}, + ) + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + return cls._schema_on_200 + + +class _ShowHelper: + """Helper class for Show""" + + _schema_signal_read = None + + @classmethod + def _build_schema_signal_read(cls, _schema): + if cls._schema_signal_read is not None: + _schema.signal_formula = cls._schema_signal_read.signal_formula + _schema.signal_sources = cls._schema_signal_read.signal_sources + return + + cls._schema_signal_read = _schema_signal_read = AAZObjectType() + + signal_read = _schema_signal_read + signal_read.signal_formula = AAZStrType( + serialized_name="signalFormula", + flags={"required": True}, + ) + signal_read.signal_sources = AAZListType( + serialized_name="signalSources", + flags={"required": True}, + ) + + signal_sources = _schema_signal_read.signal_sources + signal_sources.Element = AAZObjectType() + + _element = _schema_signal_read.signal_sources.Element + _element.filters = AAZListType( + flags={"required": True}, + ) + _element.metric_name = AAZStrType( + serialized_name="metricName", + flags={"required": True}, + ) + _element.metric_namespace = AAZStrType( + serialized_name="metricNamespace", + flags={"required": True}, + ) + _element.signal_source_id = AAZStrType( + serialized_name="signalSourceId", + flags={"required": True}, + ) + _element.source_amw_account_managed_identity = AAZStrType( + serialized_name="sourceAmwAccountManagedIdentity", + flags={"required": True}, + ) + _element.source_amw_account_resource_id = AAZStrType( + serialized_name="sourceAmwAccountResourceId", + flags={"required": True}, + ) + _element.spatial_aggregation = AAZObjectType( + serialized_name="spatialAggregation", + flags={"required": True}, + ) + _element.temporal_aggregation = AAZObjectType( + serialized_name="temporalAggregation", + flags={"required": True}, + ) + + filters = _schema_signal_read.signal_sources.Element.filters + filters.Element = AAZObjectType() + + _element = _schema_signal_read.signal_sources.Element.filters.Element + _element.dimension_name = AAZStrType( + serialized_name="dimensionName", + ) + _element.operator = AAZStrType( + flags={"required": True}, + ) + _element.sampling_type = AAZStrType( + serialized_name="samplingType", + ) + _element.scalar_function = AAZStrType( + serialized_name="scalarFunction", + ) + _element.value = AAZStrType( + flags={"required": True}, + ) + + spatial_aggregation = _schema_signal_read.signal_sources.Element.spatial_aggregation + spatial_aggregation.dimensions = AAZListType( + flags={"required": True}, + ) + spatial_aggregation.type = AAZStrType( + flags={"required": True}, + ) + + dimensions = _schema_signal_read.signal_sources.Element.spatial_aggregation.dimensions + dimensions.Element = AAZStrType() + + temporal_aggregation = _schema_signal_read.signal_sources.Element.temporal_aggregation + temporal_aggregation.type = AAZStrType( + flags={"required": True}, + ) + temporal_aggregation.window_size_minutes = AAZIntType( + serialized_name="windowSizeMinutes", + ) + + _schema.signal_formula = cls._schema_signal_read.signal_formula + _schema.signal_sources = cls._schema_signal_read.signal_sources + + +__all__ = ["Show"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/sli/_update.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/sli/_update.py new file mode 100644 index 00000000000..47440eaff86 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/sli/_update.py @@ -0,0 +1,974 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor sli update", + is_preview=True, +) +class Update(AAZCommand): + """Update an SLI resource. + + Managed-identity changes must be applied to all three surfaces in a single + PUT, because the service validates set-equality across them: + + 1. ``identity.userAssignedIdentities`` (top-level ARM identity dictionary). + 2. ``properties.destinationAmwAccounts[].identity``. + 3. ``properties.sliProperties.{signals|goodSignals|totalSignals}.signalSources[].sourceAmwAccountManagedIdentity``. + + Window-based SLIs populate the ``signals`` slot; request-based SLIs populate + ``goodSignals`` and ``totalSignals``. Run ``az monitor sli show`` first to + confirm the destination/signal-source indices and which slot is in use. + The examples below assume the window-based ``signals`` slot with one + destination AMW and one signal source. + + Note: UAMI ARM IDs contain ``.`` (for example ``Microsoft.ManagedIdentity``), + so they cannot be addressed as path segments by ``--set/--remove`` (azure-cli + splits the path on ``.``). To change ``identity.userAssignedIdentities``, + replace the whole map by passing a JSON value rooted at ``identity.userAssignedIdentities``. + + :example: Update the description. + az monitor sli update --service-group-name MyServiceGroup --sli-name MySli --set properties.description="Updated API availability SLI" + + :example: Rotate the source-AMW managed identity (signal source 0) to a new UAMI. + az monitor sli update --service-group-name MyServiceGroup --sli-name MySli --set 'identity.userAssignedIdentities={"":{}}' --set 'properties.sliProperties.signals.signalSources[0].sourceAmwAccountManagedIdentity=' + + :example: Rotate the destination-AMW managed identity (destination 0) to a new UAMI. + az monitor sli update --service-group-name MyServiceGroup --sli-name MySli --set 'identity.userAssignedIdentities={"":{}}' --set 'properties.destinationAmwAccounts[0].identity=' + + :example: Rotate the source-AMW and destination-AMW managed identities together in a single update (single UAMI used for both). + az monitor sli update --service-group-name MyServiceGroup --sli-name MySli --set 'identity.userAssignedIdentities={"":{}}' --set 'properties.destinationAmwAccounts[0].identity=' --set 'properties.sliProperties.signals.signalSources[0].sourceAmwAccountManagedIdentity=' + """ + + _aaz_info = { + "version": "2025-03-01-preview", + "resources": [ + ["mgmt-plane", "/providers/microsoft.management/servicegroups/{}/providers/microsoft.monitor/slis/{}", "2025-03-01-preview"], + ] + } + + AZ_SUPPORT_GENERIC_UPDATE = True + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.service_group_name = AAZStrArg( + options=["--service-group-name"], + help="The name of the service group.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[A-Za-z0-9._()~-]{1,250}$", + ), + ) + _args_schema.sli_name = AAZStrArg( + options=["--sli-name"], + help="Name of the SLI that is given by the user.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9][a-zA-Z0-9_()~-]{2,63}$", + ), + ) + + # define Arg Group "Identity" + + # define Arg Group "Properties" + + _args_schema = cls._args_schema + _args_schema.baseline_properties = AAZObjectArg( + options=["--baseline-properties"], + arg_group="Properties", + help="Defines the SLO baseline associated with the SLI.", + ) + _args_schema.category = AAZStrArg( + options=["--category"], + arg_group="Properties", + help="Specifies the category of the SLI, used to classify signals such as Availability and Latency.", + enum={"Availability": "Availability", "Latency": "Latency"}, + ) + _args_schema.description = AAZStrArg( + options=["--description"], + arg_group="Properties", + help="A user-provided description of the SLI, with a maximum length of 1000 characters.", + fmt=AAZStrArgFormat( + pattern="^[\\s\\S]{0,1000}$", + ), + ) + _args_schema.destination_amw_accounts = AAZListArg( + options=["--destination-amw-accounts", "--amw-accounts"], + arg_group="Properties", + help="Destination AMW accounts.", + ) + _args_schema.enable_alert = AAZBoolArg( + options=["--enable-alert"], + arg_group="Properties", + help="A flag to determine whether alert is enabled.", + ) + _args_schema.evaluation_type = AAZStrArg( + options=["--evaluation-type"], + arg_group="Properties", + help="Determines how the SLI is evaluated—either based on request counts or time windows.", + enum={"RequestBased": "RequestBased", "WindowBased": "WindowBased"}, + ) + _args_schema.sli_properties = AAZObjectArg( + options=["--sli-properties"], + arg_group="Properties", + help="Defines the SLI properties associated with the SLI.", + ) + + baseline_properties = cls._args_schema.baseline_properties + baseline_properties.baseline = AAZObjectArg( + options=["baseline"], + help="Defines the baseline target, which is compared against the SLI value to determine compliance.", + ) + + baseline = cls._args_schema.baseline_properties.baseline + baseline.evaluation_calculation_type = AAZStrArg( + options=["evaluation-calculation-type"], + help="Specifies how evaluation is calculated, either based on calendar days or a rolling window.", + enum={"CalendarDays": "CalendarDays", "RollingDays": "RollingDays"}, + ) + baseline.evaluation_period_days = AAZIntArg( + options=["evaluation-period-days"], + help="The time frame (in days) used for SLI evaluation.", + fmt=AAZIntArgFormat( + maximum=90, + minimum=1, + ), + ) + baseline.value = AAZFloatArg( + options=["value"], + help="The user-defined or Azure-defined target value used for comparison against the SLI value.", + fmt=AAZFloatArgFormat( + maximum=100.0, + minimum=0.0, + ), + ) + + destination_amw_accounts = cls._args_schema.destination_amw_accounts + destination_amw_accounts.Element = AAZObjectArg( + nullable=True, + ) + + _element = cls._args_schema.destination_amw_accounts.Element + _element.identity = AAZResourceIdArg( + options=["identity"], + help="The ARM resource ID of the managed identity with access to the source account.", + ) + _element.resource_id = AAZResourceIdArg( + options=["resource-id"], + help="The ARM resource ID of the account where metrics are emitted.", + ) + + sli_properties = cls._args_schema.sli_properties + sli_properties.good_signals = AAZObjectArg( + options=["good-signals"], + help="Represents good signals used in request-based SLI calculations.", + nullable=True, + ) + cls._build_args_signal_update(sli_properties.good_signals) + sli_properties.signals = AAZObjectArg( + options=["signals"], + help="Signals used for window-based SLI calculations.", + nullable=True, + ) + cls._build_args_signal_update(sli_properties.signals) + sli_properties.total_signals = AAZObjectArg( + options=["total-signals"], + help="Represents total signals used in request-based SLI calculations.", + nullable=True, + ) + cls._build_args_signal_update(sli_properties.total_signals) + sli_properties.window_uptime_criteria = AAZObjectArg( + options=["window-uptime-criteria"], + help="Defines the uptime criteria for window-based SLIs.", + nullable=True, + ) + + window_uptime_criteria = cls._args_schema.sli_properties.window_uptime_criteria + window_uptime_criteria.comparator = AAZStrArg( + options=["comparator"], + help="Comparison operator used for uptime evaluation.", + enum={"gt": "gt", "gte": "gte", "lt": "lt", "lte": "lte"}, + ) + window_uptime_criteria.target = AAZFloatArg( + options=["target"], + help="Threshold value used to determine uptime.", + ) + return cls._args_schema + + _args_signal_update = None + + @classmethod + def _build_args_signal_update(cls, _schema): + if cls._args_signal_update is not None: + _schema.signal_formula = cls._args_signal_update.signal_formula + _schema.signal_sources = cls._args_signal_update.signal_sources + return + + cls._args_signal_update = AAZObjectArg( + nullable=True, + ) + + signal_update = cls._args_signal_update + signal_update.signal_formula = AAZStrArg( + options=["signal-formula"], + help="Mathematical formula used to combine multiple metrics.", + ) + signal_update.signal_sources = AAZListArg( + options=["signal-sources"], + help="Sources of metrics used for SLIs.", + ) + + signal_sources = cls._args_signal_update.signal_sources + signal_sources.Element = AAZObjectArg( + nullable=True, + ) + + _element = cls._args_signal_update.signal_sources.Element + _element.filters = AAZListArg( + options=["filters"], + help="Filters applied to modify signal values.", + ) + _element.metric_name = AAZStrArg( + options=["metric-name"], + help="Name of the metric.", + ) + _element.metric_namespace = AAZStrArg( + options=["metric-namespace"], + help="Namespace of the metric.", + ) + _element.signal_source_id = AAZStrArg( + options=["signal-source-id"], + help="Unique identifier for the signal source.", + ) + _element.source_amw_account_managed_identity = AAZResourceIdArg( + options=["source-amw-account-managed-identity"], + help="Managed identity for authenticating the signal source.", + ) + _element.source_amw_account_resource_id = AAZResourceIdArg( + options=["source-amw-account-resource-id"], + help="Resource ID of the source AMW account.", + ) + _element.spatial_aggregation = AAZObjectArg( + options=["spatial-aggregation"], + help="Defines how measurements are aggregated across multiple time series.", + ) + _element.temporal_aggregation = AAZObjectArg( + options=["temporal-aggregation"], + help="Defines how measurements are aggregated over a specific time window within the same time series.", + ) + + filters = cls._args_signal_update.signal_sources.Element.filters + filters.Element = AAZObjectArg( + nullable=True, + ) + + _element = cls._args_signal_update.signal_sources.Element.filters.Element + _element.dimension_name = AAZStrArg( + options=["dimension-name"], + help="Dimension name used in filtering.", + nullable=True, + ) + _element.operator = AAZStrArg( + options=["operator"], + help="Operator used in the filtering condition.", + enum={"contains": "contains", "eq": "eq", "gt": "gt", "gte": "gte", "in": "in", "lt": "lt", "lte": "lte", "ne": "ne", "notcontains": "notcontains", "notin": "notin", "notstartswith": "notstartswith", "startswith": "startswith"}, + ) + _element.sampling_type = AAZStrArg( + options=["sampling-type"], + help="Defines the sampling type.", + nullable=True, + enum={"Average": "Average", "Count": "Count", "Max": "Max", "Min": "Min", "Sum": "Sum"}, + ) + _element.scalar_function = AAZStrArg( + options=["scalar-function"], + help="Scalar function applied for filtering.", + nullable=True, + enum={"avg": "avg", "max": "max", "min": "min", "sum": "sum"}, + ) + _element.value = AAZStrArg( + options=["value"], + help="Value used in filtering.", + ) + + spatial_aggregation = cls._args_signal_update.signal_sources.Element.spatial_aggregation + spatial_aggregation.dimensions = AAZListArg( + options=["dimensions"], + help="Dimensions considered for spatial aggregation.", + ) + spatial_aggregation.type = AAZStrArg( + options=["type"], + help="Type of spatial aggregation.", + enum={"Average": "Average", "Count": "Count", "Max": "Max", "Min": "Min", "Sum": "Sum"}, + ) + + dimensions = cls._args_signal_update.signal_sources.Element.spatial_aggregation.dimensions + dimensions.Element = AAZStrArg( + nullable=True, + ) + + temporal_aggregation = cls._args_signal_update.signal_sources.Element.temporal_aggregation + temporal_aggregation.type = AAZStrArg( + options=["type"], + help="Type of temporal aggregation.", + enum={"Average": "Average", "Delta": "Delta", "IDelta": "IDelta", "IRate": "IRate", "Increase": "Increase", "Max": "Max", "Min": "Min", "Rate": "Rate", "Sum": "Sum"}, + ) + temporal_aggregation.window_size_minutes = AAZIntArg( + options=["window-size-minutes"], + help="Time window size for aggregation, in minutes.", + nullable=True, + ) + + _schema.signal_formula = cls._args_signal_update.signal_formula + _schema.signal_sources = cls._args_signal_update.signal_sources + + def _execute_operations(self): + self.pre_operations() + self.SlisGet(ctx=self.ctx)() + self.pre_instance_update(self.ctx.vars.instance) + self.InstanceUpdateByJson(ctx=self.ctx)() + self.InstanceUpdateByGeneric(ctx=self.ctx)() + self.post_instance_update(self.ctx.vars.instance) + self.SlisCreateOrUpdate(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + @register_callback + def pre_instance_update(self, instance): + pass + + @register_callback + def post_instance_update(self, instance): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class SlisGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Management/serviceGroups/{serviceGroupName}/providers/Microsoft.Monitor/slis/{sliName}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "serviceGroupName", self.ctx.args.service_group_name, + required=True, + ), + **self.serialize_url_param( + "sliName", self.ctx.args.sli_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2025-03-01-preview", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + _UpdateHelper._build_schema_sli_read(cls._schema_on_200) + + return cls._schema_on_200 + + class SlisCreateOrUpdate(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200, 201]: + return self.on_200_201(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Management/serviceGroups/{serviceGroupName}/providers/Microsoft.Monitor/slis/{sliName}", + **self.url_parameters + ) + + @property + def method(self): + return "PUT" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "serviceGroupName", self.ctx.args.service_group_name, + required=True, + ), + **self.serialize_url_param( + "sliName", self.ctx.args.sli_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2025-03-01-preview", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + value=self.ctx.vars.instance, + ) + + return self.serialize_content(_content_value) + + def on_200_201(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200_201 + ) + + _schema_on_200_201 = None + + @classmethod + def _build_schema_on_200_201(cls): + if cls._schema_on_200_201 is not None: + return cls._schema_on_200_201 + + cls._schema_on_200_201 = AAZObjectType() + _UpdateHelper._build_schema_sli_read(cls._schema_on_200_201) + + return cls._schema_on_200_201 + + class InstanceUpdateByJson(AAZJsonInstanceUpdateOperation): + + def __call__(self, *args, **kwargs): + self._update_instance(self.ctx.vars.instance) + + def _update_instance(self, instance): + _instance_value, _builder = self.new_content_builder( + self.ctx.args, + value=instance, + typ=AAZObjectType + ) + _builder.set_prop("identity", AAZIdentityObjectType) + _builder.set_prop("properties", AAZObjectType) + + properties = _builder.get(".properties") + if properties is not None: + properties.set_prop("baselineProperties", AAZObjectType, ".baseline_properties", typ_kwargs={"flags": {"required": True}}) + properties.set_prop("category", AAZStrType, ".category", typ_kwargs={"flags": {"required": True}}) + properties.set_prop("description", AAZStrType, ".description", typ_kwargs={"flags": {"required": True}}) + properties.set_prop("destinationAmwAccounts", AAZListType, ".destination_amw_accounts", typ_kwargs={"flags": {"required": True}}) + properties.set_prop("enableAlert", AAZBoolType, ".enable_alert", typ_kwargs={"flags": {"required": True}}) + properties.set_prop("evaluationType", AAZStrType, ".evaluation_type", typ_kwargs={"flags": {"required": True}}) + properties.set_prop("sliProperties", AAZObjectType, ".sli_properties", typ_kwargs={"flags": {"required": True}}) + + baseline_properties = _builder.get(".properties.baselineProperties") + if baseline_properties is not None: + baseline_properties.set_prop("baseline", AAZObjectType, ".baseline", typ_kwargs={"flags": {"required": True}}) + + baseline = _builder.get(".properties.baselineProperties.baseline") + if baseline is not None: + baseline.set_prop("evaluationCalculationType", AAZStrType, ".evaluation_calculation_type", typ_kwargs={"flags": {"required": True}}) + baseline.set_prop("evaluationPeriodDays", AAZIntType, ".evaluation_period_days", typ_kwargs={"flags": {"required": True}}) + baseline.set_prop("value", AAZFloatType, ".value", typ_kwargs={"flags": {"required": True}}) + + destination_amw_accounts = _builder.get(".properties.destinationAmwAccounts") + if destination_amw_accounts is not None: + destination_amw_accounts.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".properties.destinationAmwAccounts[]") + if _elements is not None: + _elements.set_prop("identity", AAZStrType, ".identity", typ_kwargs={"flags": {"required": True}}) + _elements.set_prop("resourceId", AAZStrType, ".resource_id", typ_kwargs={"flags": {"required": True}}) + + sli_properties = _builder.get(".properties.sliProperties") + if sli_properties is not None: + _UpdateHelper._build_schema_signal_update(sli_properties.set_prop("goodSignals", AAZObjectType, ".good_signals")) + _UpdateHelper._build_schema_signal_update(sli_properties.set_prop("signals", AAZObjectType, ".signals")) + _UpdateHelper._build_schema_signal_update(sli_properties.set_prop("totalSignals", AAZObjectType, ".total_signals")) + sli_properties.set_prop("windowUptimeCriteria", AAZObjectType, ".window_uptime_criteria") + + window_uptime_criteria = _builder.get(".properties.sliProperties.windowUptimeCriteria") + if window_uptime_criteria is not None: + window_uptime_criteria.set_prop("comparator", AAZStrType, ".comparator", typ_kwargs={"flags": {"required": True}}) + window_uptime_criteria.set_prop("target", AAZFloatType, ".target", typ_kwargs={"flags": {"required": True}}) + + return _instance_value + + class InstanceUpdateByGeneric(AAZGenericInstanceUpdateOperation): + + def __call__(self, *args, **kwargs): + self._update_instance_by_generic( + self.ctx.vars.instance, + self.ctx.generic_update_args + ) + + +class _UpdateHelper: + """Helper class for Update""" + + @classmethod + def _build_schema_signal_update(cls, _builder): + if _builder is None: + return + _builder.set_prop("signalFormula", AAZStrType, ".signal_formula", typ_kwargs={"flags": {"required": True}}) + _builder.set_prop("signalSources", AAZListType, ".signal_sources", typ_kwargs={"flags": {"required": True}}) + + signal_sources = _builder.get(".signalSources") + if signal_sources is not None: + signal_sources.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".signalSources[]") + if _elements is not None: + _elements.set_prop("filters", AAZListType, ".filters", typ_kwargs={"flags": {"required": True}}) + _elements.set_prop("metricName", AAZStrType, ".metric_name", typ_kwargs={"flags": {"required": True}}) + _elements.set_prop("metricNamespace", AAZStrType, ".metric_namespace", typ_kwargs={"flags": {"required": True}}) + _elements.set_prop("signalSourceId", AAZStrType, ".signal_source_id", typ_kwargs={"flags": {"required": True}}) + _elements.set_prop("sourceAmwAccountManagedIdentity", AAZStrType, ".source_amw_account_managed_identity", typ_kwargs={"flags": {"required": True}}) + _elements.set_prop("sourceAmwAccountResourceId", AAZStrType, ".source_amw_account_resource_id", typ_kwargs={"flags": {"required": True}}) + _elements.set_prop("spatialAggregation", AAZObjectType, ".spatial_aggregation", typ_kwargs={"flags": {"required": True}}) + _elements.set_prop("temporalAggregation", AAZObjectType, ".temporal_aggregation", typ_kwargs={"flags": {"required": True}}) + + filters = _builder.get(".signalSources[].filters") + if filters is not None: + filters.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".signalSources[].filters[]") + if _elements is not None: + _elements.set_prop("dimensionName", AAZStrType, ".dimension_name") + _elements.set_prop("operator", AAZStrType, ".operator", typ_kwargs={"flags": {"required": True}}) + _elements.set_prop("samplingType", AAZStrType, ".sampling_type") + _elements.set_prop("scalarFunction", AAZStrType, ".scalar_function") + _elements.set_prop("value", AAZStrType, ".value", typ_kwargs={"flags": {"required": True}}) + + spatial_aggregation = _builder.get(".signalSources[].spatialAggregation") + if spatial_aggregation is not None: + spatial_aggregation.set_prop("dimensions", AAZListType, ".dimensions", typ_kwargs={"flags": {"required": True}}) + spatial_aggregation.set_prop("type", AAZStrType, ".type", typ_kwargs={"flags": {"required": True}}) + + dimensions = _builder.get(".signalSources[].spatialAggregation.dimensions") + if dimensions is not None: + dimensions.set_elements(AAZStrType, ".") + + temporal_aggregation = _builder.get(".signalSources[].temporalAggregation") + if temporal_aggregation is not None: + temporal_aggregation.set_prop("type", AAZStrType, ".type", typ_kwargs={"flags": {"required": True}}) + temporal_aggregation.set_prop("windowSizeMinutes", AAZIntType, ".window_size_minutes") + + _schema_signal_read = None + + @classmethod + def _build_schema_signal_read(cls, _schema): + if cls._schema_signal_read is not None: + _schema.signal_formula = cls._schema_signal_read.signal_formula + _schema.signal_sources = cls._schema_signal_read.signal_sources + return + + cls._schema_signal_read = _schema_signal_read = AAZObjectType() + + signal_read = _schema_signal_read + signal_read.signal_formula = AAZStrType( + serialized_name="signalFormula", + flags={"required": True}, + ) + signal_read.signal_sources = AAZListType( + serialized_name="signalSources", + flags={"required": True}, + ) + + signal_sources = _schema_signal_read.signal_sources + signal_sources.Element = AAZObjectType() + + _element = _schema_signal_read.signal_sources.Element + _element.filters = AAZListType( + flags={"required": True}, + ) + _element.metric_name = AAZStrType( + serialized_name="metricName", + flags={"required": True}, + ) + _element.metric_namespace = AAZStrType( + serialized_name="metricNamespace", + flags={"required": True}, + ) + _element.signal_source_id = AAZStrType( + serialized_name="signalSourceId", + flags={"required": True}, + ) + _element.source_amw_account_managed_identity = AAZStrType( + serialized_name="sourceAmwAccountManagedIdentity", + flags={"required": True}, + ) + _element.source_amw_account_resource_id = AAZStrType( + serialized_name="sourceAmwAccountResourceId", + flags={"required": True}, + ) + _element.spatial_aggregation = AAZObjectType( + serialized_name="spatialAggregation", + flags={"required": True}, + ) + _element.temporal_aggregation = AAZObjectType( + serialized_name="temporalAggregation", + flags={"required": True}, + ) + + filters = _schema_signal_read.signal_sources.Element.filters + filters.Element = AAZObjectType() + + _element = _schema_signal_read.signal_sources.Element.filters.Element + _element.dimension_name = AAZStrType( + serialized_name="dimensionName", + ) + _element.operator = AAZStrType( + flags={"required": True}, + ) + _element.sampling_type = AAZStrType( + serialized_name="samplingType", + ) + _element.scalar_function = AAZStrType( + serialized_name="scalarFunction", + ) + _element.value = AAZStrType( + flags={"required": True}, + ) + + spatial_aggregation = _schema_signal_read.signal_sources.Element.spatial_aggregation + spatial_aggregation.dimensions = AAZListType( + flags={"required": True}, + ) + spatial_aggregation.type = AAZStrType( + flags={"required": True}, + ) + + dimensions = _schema_signal_read.signal_sources.Element.spatial_aggregation.dimensions + dimensions.Element = AAZStrType() + + temporal_aggregation = _schema_signal_read.signal_sources.Element.temporal_aggregation + temporal_aggregation.type = AAZStrType( + flags={"required": True}, + ) + temporal_aggregation.window_size_minutes = AAZIntType( + serialized_name="windowSizeMinutes", + ) + + _schema.signal_formula = cls._schema_signal_read.signal_formula + _schema.signal_sources = cls._schema_signal_read.signal_sources + + _schema_sli_read = None + + @classmethod + def _build_schema_sli_read(cls, _schema): + if cls._schema_sli_read is not None: + _schema.id = cls._schema_sli_read.id + _schema.identity = cls._schema_sli_read.identity + _schema.name = cls._schema_sli_read.name + _schema.properties = cls._schema_sli_read.properties + _schema.system_data = cls._schema_sli_read.system_data + _schema.type = cls._schema_sli_read.type + return + + cls._schema_sli_read = _schema_sli_read = AAZObjectType() + + sli_read = _schema_sli_read + sli_read.id = AAZStrType( + flags={"read_only": True}, + ) + sli_read.identity = AAZIdentityObjectType() + sli_read.name = AAZStrType( + flags={"read_only": True}, + ) + sli_read.properties = AAZObjectType() + sli_read.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + sli_read.type = AAZStrType( + flags={"read_only": True}, + ) + + identity = _schema_sli_read.identity + identity.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + identity.tenant_id = AAZStrType( + serialized_name="tenantId", + flags={"read_only": True}, + ) + identity.type = AAZStrType( + flags={"required": True}, + ) + identity.user_assigned_identities = AAZDictType( + serialized_name="userAssignedIdentities", + ) + + user_assigned_identities = _schema_sli_read.identity.user_assigned_identities + user_assigned_identities.Element = AAZObjectType( + nullable=True, + ) + + _element = _schema_sli_read.identity.user_assigned_identities.Element + _element.client_id = AAZStrType( + serialized_name="clientId", + flags={"read_only": True}, + ) + _element.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + + properties = _schema_sli_read.properties + properties.baseline_properties = AAZObjectType( + serialized_name="baselineProperties", + flags={"required": True}, + ) + properties.category = AAZStrType( + flags={"required": True}, + ) + properties.description = AAZStrType( + flags={"required": True}, + ) + properties.destination_amw_accounts = AAZListType( + serialized_name="destinationAmwAccounts", + flags={"required": True}, + ) + properties.destination_metrics = AAZListType( + serialized_name="destinationMetrics", + flags={"read_only": True}, + ) + properties.enable_alert = AAZBoolType( + serialized_name="enableAlert", + flags={"required": True}, + ) + properties.evaluation_type = AAZStrType( + serialized_name="evaluationType", + flags={"required": True}, + ) + properties.execution_state = AAZObjectType( + serialized_name="executionState", + flags={"read_only": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.sli_properties = AAZObjectType( + serialized_name="sliProperties", + flags={"required": True}, + ) + properties.streaming_rule_id = AAZStrType( + serialized_name="streamingRuleId", + flags={"read_only": True}, + ) + properties.streaming_rule_last_updated_timestamp = AAZStrType( + serialized_name="streamingRuleLastUpdatedTimestamp", + flags={"read_only": True}, + ) + + baseline_properties = _schema_sli_read.properties.baseline_properties + baseline_properties.baseline = AAZObjectType( + flags={"required": True}, + ) + + baseline = _schema_sli_read.properties.baseline_properties.baseline + baseline.evaluation_calculation_type = AAZStrType( + serialized_name="evaluationCalculationType", + flags={"required": True}, + ) + baseline.evaluation_period_days = AAZIntType( + serialized_name="evaluationPeriodDays", + flags={"required": True}, + ) + baseline.value = AAZFloatType( + flags={"required": True}, + ) + + destination_amw_accounts = _schema_sli_read.properties.destination_amw_accounts + destination_amw_accounts.Element = AAZObjectType() + + _element = _schema_sli_read.properties.destination_amw_accounts.Element + _element.identity = AAZStrType( + flags={"required": True}, + ) + _element.resource_id = AAZStrType( + serialized_name="resourceId", + flags={"required": True}, + ) + + destination_metrics = _schema_sli_read.properties.destination_metrics + destination_metrics.Element = AAZObjectType() + + _element = _schema_sli_read.properties.destination_metrics.Element + _element.metric_name = AAZStrType( + serialized_name="metricName", + flags={"required": True}, + ) + _element.metric_namespace = AAZStrType( + serialized_name="metricNamespace", + flags={"required": True}, + ) + + execution_state = _schema_sli_read.properties.execution_state + execution_state.message = AAZStrType() + execution_state.state = AAZStrType( + flags={"required": True}, + ) + + sli_properties = _schema_sli_read.properties.sli_properties + sli_properties.good_signals = AAZObjectType( + serialized_name="goodSignals", + ) + cls._build_schema_signal_read(sli_properties.good_signals) + sli_properties.signals = AAZObjectType() + cls._build_schema_signal_read(sli_properties.signals) + sli_properties.total_signals = AAZObjectType( + serialized_name="totalSignals", + ) + cls._build_schema_signal_read(sli_properties.total_signals) + sli_properties.window_uptime_criteria = AAZObjectType( + serialized_name="windowUptimeCriteria", + ) + + window_uptime_criteria = _schema_sli_read.properties.sli_properties.window_uptime_criteria + window_uptime_criteria.comparator = AAZStrType( + flags={"required": True}, + ) + window_uptime_criteria.target = AAZFloatType( + flags={"required": True}, + ) + + system_data = _schema_sli_read.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + _schema.id = cls._schema_sli_read.id + _schema.identity = cls._schema_sli_read.identity + _schema.name = cls._schema_sli_read.name + _schema.properties = cls._schema_sli_read.properties + _schema.system_data = cls._schema_sli_read.system_data + _schema.type = cls._schema_sli_read.type + + +__all__ = ["Update"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/tests/latest/recordings/test_monitor_sli_crud.yaml b/src/azure-cli/azure/cli/command_modules/monitor/tests/latest/recordings/test_monitor_sli_crud.yaml new file mode 100644 index 00000000000..da880f1321e --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/tests/latest/recordings/test_monitor_sli_crud.yaml @@ -0,0 +1,500 @@ +interactions: +- request: + body: '{"identity": {"userAssignedIdentities": {"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli-test-sli-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/cli-test-sli-uami": + {}}, "type": "UserAssigned"}, "properties": {"baselineProperties": {"baseline": + {"evaluationCalculationType": "CalendarDays", "evaluationPeriodDays": 30, "value": + 50.0}}, "category": "Latency", "description": "CLI SLI scenario test", "destinationAmwAccounts": + [{"identity": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli-test-sli-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/cli-test-sli-uami", + "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli-test-sli-rg/providers/microsoft.monitor/accounts/cli-test-sli-amw"}], + "enableAlert": false, "evaluationType": "RequestBased", "sliProperties": {"goodSignals": + {"signalFormula": "A", "signalSources": [{"filters": [{"dimensionName": "dimName1", + "operator": "eq", "samplingType": "Count", "value": "GetContosoUsers"}], "metricName": + "cliTestMetric1", "metricNamespace": "cliTestNamespace", "signalSourceId": + "A", "sourceAmwAccountManagedIdentity": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli-test-sli-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/cli-test-sli-uami", + "sourceAmwAccountResourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli-test-sli-rg/providers/microsoft.monitor/accounts/cli-test-sli-amw", + "spatialAggregation": {"dimensions": ["dimName1"], "type": "Count"}, "temporalAggregation": + {"type": "Max"}}]}, "totalSignals": {"signalFormula": "A", "signalSources": + [{"filters": [{"dimensionName": "dimName1", "operator": "eq", "samplingType": + "Count", "value": "GetContosoUsers"}], "metricName": "cliTestMetric1", "metricNamespace": + "cliTestNamespace", "signalSourceId": "A", "sourceAmwAccountManagedIdentity": + "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli-test-sli-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/cli-test-sli-uami", + "sourceAmwAccountResourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli-test-sli-rg/providers/microsoft.monitor/accounts/cli-test-sli-amw", + "spatialAggregation": {"dimensions": ["dimName1"], "type": "Count"}, "temporalAggregation": + {"type": "Max"}}]}}}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - monitor sli create + Connection: + - keep-alive + Content-Length: + - '2426' + Content-Type: + - application/json + ParameterSetName: + - --service-group-name --sli-name --category --evaluation-type --description + --enable-alert --user-assigned --destination-amw-accounts --baseline-properties + --sli-properties + User-Agent: + - AZURECLI/2.86.0 azsdk-python-core/1.39.0 Python/3.11.9 (Windows-10-10.0.26200-SP0) + method: PUT + uri: https://management.azure.com/providers/Microsoft.Management/serviceGroups/cli-test-sli-sg/providers/Microsoft.Monitor/slis/clisli000001?api-version=2025-03-01-preview + response: + body: + string: '{"id":"/providers/Microsoft.Management/serviceGroups/cli-test-sli-sg/providers/Microsoft.Monitor/slis/clisli000001","name":"clisli000001","type":"microsoft.monitor/slis","systemData":{"createdBy":"test@example.com","createdByType":"User","createdAt":"2026-05-23T17:57:14.7445149Z","lastModifiedBy":"test@example.com","lastModifiedByType":"User","lastModifiedAt":"2026-05-23T17:57:14.7445149Z"},"identity":{"type":"UserAssigned","userAssignedIdentities":{"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli-test-sli-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/cli-test-sli-uami":{"clientId":"c355a8a2-2d6b-491e-86f6-42b11846b324","principalId":"f9ac6c44-5c1c-4bd5-9f89-90e804c3fa6f"}}},"properties":{"description":"CLI + SLI scenario test","category":"Latency","evaluationType":"RequestBased","provisioningState":"Succeeded","executionState":{"message":null,"state":"Pending"},"destinationAmwAccounts":[{"resourceId":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli-test-sli-rg/providers/microsoft.monitor/accounts/cli-test-sli-amw","identity":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli-test-sli-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/cli-test-sli-uami"}],"destinationMetrics":[{"metricName":"clisli000001:Good","metricNamespace":"cli-test-sli-sg"},{"metricName":"clisli000001:Total","metricNamespace":"cli-test-sli-sg"},{"metricName":"clisli000001:Value","metricNamespace":"cli-test-sli-sg"}],"baselineProperties":{"baseline":{"value":50.0,"evaluationCalculationType":"CalendarDays","evaluationPeriodDays":30}},"streamingRuleId":"72f988bf-86f1-41af-91ab-2d7cd011db47_global_bb0fbe78-c966-45c1-af84-b7220c084dd0","streamingRuleLastUpdatedTimestamp":"2026-05-23T17:57:18.5824099Z","enableAlert":false,"sliProperties":{"goodSignals":{"signalFormula":"A","signalSources":[{"signalSourceId":"A","sourceAmwAccountManagedIdentity":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli-test-sli-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/cli-test-sli-uami","sourceAmwAccountResourceId":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli-test-sli-rg/providers/microsoft.monitor/accounts/cli-test-sli-amw","metricNamespace":"cliTestNamespace","metricName":"cliTestMetric1","filters":[{"dimensionName":"dimName1","operator":"eq","value":"GetContosoUsers"}],"spatialAggregation":{"type":"Count","dimensions":["dimName1"]},"temporalAggregation":{"type":"Max"}}]},"totalSignals":{"signalFormula":"A","signalSources":[{"signalSourceId":"A","sourceAmwAccountManagedIdentity":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli-test-sli-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/cli-test-sli-uami","sourceAmwAccountResourceId":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli-test-sli-rg/providers/microsoft.monitor/accounts/cli-test-sli-amw","metricNamespace":"cliTestNamespace","metricName":"cliTestMetric1","filters":[{"dimensionName":"dimName1","operator":"eq","value":"GetContosoUsers"}],"spatialAggregation":{"type":"Count","dimensions":["dimName1"]},"temporalAggregation":{"type":"Max"}}]}}}}' + headers: + accept-ranges: + - bytes + cache-control: + - no-cache + content-length: + - '3279' + content-type: + - application/json; charset=utf-8 + date: + - Sat, 23 May 2026 17:57:18 GMT + etag: + - '"c00229ec-0000-0a00-0000-6a11ea7e0000"' + expires: + - '-1' + mise-correlation-id: + - d2b4de8d-eaa6-4c80-b9f8-da798e781f79 + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-azure-ref: + - 20260523T175715Z-1646496db66scv25hC1CO16cq400000006hg000000001vbn + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-ms-operation-identifier: + - '' + x-ms-providerhub-traffic: + - 'True' + x-ms-ratelimit-remaining-tenant-writes: + - '799' + x-msedge-ref: + - 'Ref A: 8E693854940B4EB5A72A0C774130AD31 Ref B: MWH011020809060 Ref C: 2026-05-23T17:57:14Z' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - monitor sli show + Connection: + - keep-alive + ParameterSetName: + - --service-group-name --sli-name + User-Agent: + - AZURECLI/2.86.0 azsdk-python-core/1.39.0 Python/3.11.9 (Windows-10-10.0.26200-SP0) + method: GET + uri: https://management.azure.com/providers/Microsoft.Management/serviceGroups/cli-test-sli-sg/providers/Microsoft.Monitor/slis/clisli000001?api-version=2025-03-01-preview + response: + body: + string: '{"id":"/providers/Microsoft.Management/serviceGroups/cli-test-sli-sg/providers/Microsoft.Monitor/slis/clisli000001","name":"clisli000001","type":"microsoft.monitor/slis","systemData":{"createdBy":"test@example.com","createdByType":"User","createdAt":"2026-05-23T17:57:14.7445149Z","lastModifiedBy":"test@example.com","lastModifiedByType":"User","lastModifiedAt":"2026-05-23T17:57:14.7445149Z"},"identity":{"type":"UserAssigned","userAssignedIdentities":{"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli-test-sli-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/cli-test-sli-uami":{"clientId":"c355a8a2-2d6b-491e-86f6-42b11846b324","principalId":"f9ac6c44-5c1c-4bd5-9f89-90e804c3fa6f"}}},"properties":{"description":"CLI + SLI scenario test","category":"Latency","evaluationType":"RequestBased","provisioningState":"Succeeded","executionState":{"message":null,"state":"Pending"},"destinationAmwAccounts":[{"resourceId":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli-test-sli-rg/providers/microsoft.monitor/accounts/cli-test-sli-amw","identity":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli-test-sli-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/cli-test-sli-uami"}],"destinationMetrics":[{"metricName":"clisli000001:Good","metricNamespace":"cli-test-sli-sg"},{"metricName":"clisli000001:Total","metricNamespace":"cli-test-sli-sg"},{"metricName":"clisli000001:Value","metricNamespace":"cli-test-sli-sg"}],"baselineProperties":{"baseline":{"value":50,"evaluationCalculationType":"CalendarDays","evaluationPeriodDays":30}},"streamingRuleId":"72f988bf-86f1-41af-91ab-2d7cd011db47_global_bb0fbe78-c966-45c1-af84-b7220c084dd0","streamingRuleLastUpdatedTimestamp":"2026-05-23T17:57:18.5824099Z","enableAlert":false,"sliProperties":{"goodSignals":{"signalFormula":"A","signalSources":[{"signalSourceId":"A","sourceAmwAccountManagedIdentity":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli-test-sli-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/cli-test-sli-uami","sourceAmwAccountResourceId":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli-test-sli-rg/providers/microsoft.monitor/accounts/cli-test-sli-amw","metricNamespace":"cliTestNamespace","metricName":"cliTestMetric1","filters":[{"dimensionName":"dimName1","operator":"eq","value":"GetContosoUsers"}],"spatialAggregation":{"type":"Count","dimensions":["dimName1"]},"temporalAggregation":{"type":"Max"}}]},"totalSignals":{"signalFormula":"A","signalSources":[{"signalSourceId":"A","sourceAmwAccountManagedIdentity":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli-test-sli-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/cli-test-sli-uami","sourceAmwAccountResourceId":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli-test-sli-rg/providers/microsoft.monitor/accounts/cli-test-sli-amw","metricNamespace":"cliTestNamespace","metricName":"cliTestMetric1","filters":[{"dimensionName":"dimName1","operator":"eq","value":"GetContosoUsers"}],"spatialAggregation":{"type":"Count","dimensions":["dimName1"]},"temporalAggregation":{"type":"Max"}}]}}}}' + headers: + cache-control: + - no-cache + content-length: + - '3277' + content-type: + - application/json; charset=utf-8 + date: + - Sat, 23 May 2026 17:57:19 GMT + etag: + - '"c00229ec-0000-0a00-0000-6a11ea7e0000"' + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-ms-operation-identifier: + - '' + x-ms-providerhub-traffic: + - 'True' + x-msedge-ref: + - 'Ref A: 31356D16902B479ABA7B945BBBF258DA Ref B: CO6AA3150218019 Ref C: 2026-05-23T17:57:19Z' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - monitor sli list + Connection: + - keep-alive + ParameterSetName: + - --service-group-name + User-Agent: + - AZURECLI/2.86.0 azsdk-python-core/1.39.0 Python/3.11.9 (Windows-10-10.0.26200-SP0) + method: GET + uri: https://management.azure.com/providers/Microsoft.Management/serviceGroups/cli-test-sli-sg/providers/Microsoft.Monitor/slis?api-version=2025-03-01-preview + response: + body: + string: '{"value":[{"id":"/providers/Microsoft.Management/serviceGroups/cli-test-sli-sg/providers/Microsoft.Monitor/slis/clisli000001","name":"clisli000001","type":"microsoft.monitor/slis","systemData":{"createdBy":"test@example.com","createdByType":"User","createdAt":"2026-05-23T17:57:14.7445149Z","lastModifiedBy":"test@example.com","lastModifiedByType":"User","lastModifiedAt":"2026-05-23T17:57:14.7445149Z"},"identity":{"type":"UserAssigned","userAssignedIdentities":{"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli-test-sli-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/cli-test-sli-uami":{"clientId":"c355a8a2-2d6b-491e-86f6-42b11846b324","principalId":"f9ac6c44-5c1c-4bd5-9f89-90e804c3fa6f"}}},"properties":{"description":"CLI + SLI scenario test","category":"Latency","evaluationType":"RequestBased","provisioningState":"Succeeded","executionState":{"state":"Pending"},"destinationAmwAccounts":[{"resourceId":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli-test-sli-rg/providers/microsoft.monitor/accounts/cli-test-sli-amw","identity":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli-test-sli-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/cli-test-sli-uami"}],"destinationMetrics":[{"metricName":"clisli000001:Good","metricNamespace":"cli-test-sli-sg"},{"metricName":"clisli000001:Total","metricNamespace":"cli-test-sli-sg"},{"metricName":"clisli000001:Value","metricNamespace":"cli-test-sli-sg"}],"baselineProperties":{"baseline":{"value":50,"evaluationCalculationType":"CalendarDays","evaluationPeriodDays":30}},"streamingRuleId":"72f988bf-86f1-41af-91ab-2d7cd011db47_global_bb0fbe78-c966-45c1-af84-b7220c084dd0","streamingRuleLastUpdatedTimestamp":"2026-05-23T17:57:18.5824099Z","enableAlert":false,"sliProperties":{"goodSignals":{"signalFormula":"A","signalSources":[{"signalSourceId":"A","sourceAmwAccountManagedIdentity":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli-test-sli-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/cli-test-sli-uami","sourceAmwAccountResourceId":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli-test-sli-rg/providers/microsoft.monitor/accounts/cli-test-sli-amw","metricNamespace":"cliTestNamespace","metricName":"cliTestMetric1","filters":[{"dimensionName":"dimName1","operator":"eq","value":"GetContosoUsers"}],"spatialAggregation":{"type":"Count","dimensions":["dimName1"]},"temporalAggregation":{"type":"Max"}}]},"totalSignals":{"signalFormula":"A","signalSources":[{"signalSourceId":"A","sourceAmwAccountManagedIdentity":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli-test-sli-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/cli-test-sli-uami","sourceAmwAccountResourceId":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli-test-sli-rg/providers/microsoft.monitor/accounts/cli-test-sli-amw","metricNamespace":"cliTestNamespace","metricName":"cliTestMetric1","filters":[{"dimensionName":"dimName1","operator":"eq","value":"GetContosoUsers"}],"spatialAggregation":{"type":"Count","dimensions":["dimName1"]},"temporalAggregation":{"type":"Max"}}]}}}}]}' + headers: + cache-control: + - no-cache + content-length: + - '3274' + content-type: + - application/json; charset=utf-8 + date: + - Sat, 23 May 2026 17:57:20 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-ms-operation-identifier: + - '' + x-ms-providerhub-traffic: + - 'True' + x-msedge-ref: + - 'Ref A: AC2624F6B2324B72A7EE3F804ED42BA4 Ref B: CO6AA3150218019 Ref C: 2026-05-23T17:57:20Z' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - monitor sli update + Connection: + - keep-alive + ParameterSetName: + - --service-group-name --sli-name --description --enable-alert + User-Agent: + - AZURECLI/2.86.0 azsdk-python-core/1.39.0 Python/3.11.9 (Windows-10-10.0.26200-SP0) + method: GET + uri: https://management.azure.com/providers/Microsoft.Management/serviceGroups/cli-test-sli-sg/providers/Microsoft.Monitor/slis/clisli000001?api-version=2025-03-01-preview + response: + body: + string: '{"id":"/providers/Microsoft.Management/serviceGroups/cli-test-sli-sg/providers/Microsoft.Monitor/slis/clisli000001","name":"clisli000001","type":"microsoft.monitor/slis","systemData":{"createdBy":"test@example.com","createdByType":"User","createdAt":"2026-05-23T17:57:14.7445149Z","lastModifiedBy":"test@example.com","lastModifiedByType":"User","lastModifiedAt":"2026-05-23T17:57:14.7445149Z"},"identity":{"type":"UserAssigned","userAssignedIdentities":{"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli-test-sli-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/cli-test-sli-uami":{"clientId":"c355a8a2-2d6b-491e-86f6-42b11846b324","principalId":"f9ac6c44-5c1c-4bd5-9f89-90e804c3fa6f"}}},"properties":{"description":"CLI + SLI scenario test","category":"Latency","evaluationType":"RequestBased","provisioningState":"Succeeded","executionState":{"message":null,"state":"Pending"},"destinationAmwAccounts":[{"resourceId":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli-test-sli-rg/providers/microsoft.monitor/accounts/cli-test-sli-amw","identity":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli-test-sli-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/cli-test-sli-uami"}],"destinationMetrics":[{"metricName":"clisli000001:Good","metricNamespace":"cli-test-sli-sg"},{"metricName":"clisli000001:Total","metricNamespace":"cli-test-sli-sg"},{"metricName":"clisli000001:Value","metricNamespace":"cli-test-sli-sg"}],"baselineProperties":{"baseline":{"value":50,"evaluationCalculationType":"CalendarDays","evaluationPeriodDays":30}},"streamingRuleId":"72f988bf-86f1-41af-91ab-2d7cd011db47_global_bb0fbe78-c966-45c1-af84-b7220c084dd0","streamingRuleLastUpdatedTimestamp":"2026-05-23T17:57:18.5824099Z","enableAlert":false,"sliProperties":{"goodSignals":{"signalFormula":"A","signalSources":[{"signalSourceId":"A","sourceAmwAccountManagedIdentity":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli-test-sli-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/cli-test-sli-uami","sourceAmwAccountResourceId":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli-test-sli-rg/providers/microsoft.monitor/accounts/cli-test-sli-amw","metricNamespace":"cliTestNamespace","metricName":"cliTestMetric1","filters":[{"dimensionName":"dimName1","operator":"eq","value":"GetContosoUsers"}],"spatialAggregation":{"type":"Count","dimensions":["dimName1"]},"temporalAggregation":{"type":"Max"}}]},"totalSignals":{"signalFormula":"A","signalSources":[{"signalSourceId":"A","sourceAmwAccountManagedIdentity":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli-test-sli-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/cli-test-sli-uami","sourceAmwAccountResourceId":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli-test-sli-rg/providers/microsoft.monitor/accounts/cli-test-sli-amw","metricNamespace":"cliTestNamespace","metricName":"cliTestMetric1","filters":[{"dimensionName":"dimName1","operator":"eq","value":"GetContosoUsers"}],"spatialAggregation":{"type":"Count","dimensions":["dimName1"]},"temporalAggregation":{"type":"Max"}}]}}}}' + headers: + cache-control: + - no-cache + content-length: + - '3277' + content-type: + - application/json; charset=utf-8 + date: + - Sat, 23 May 2026 17:57:21 GMT + etag: + - '"c00229ec-0000-0a00-0000-6a11ea7e0000"' + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-ms-operation-identifier: + - '' + x-ms-providerhub-traffic: + - 'True' + x-msedge-ref: + - 'Ref A: A35A302E6D584E16815BD467028BAE78 Ref B: MWH011020806029 Ref C: 2026-05-23T17:57:21Z' + status: + code: 200 + message: OK +- request: + body: '{"identity": {"type": "UserAssigned", "userAssignedIdentities": {"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli-test-sli-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/cli-test-sli-uami": + {}}}, "properties": {"baselineProperties": {"baseline": {"evaluationCalculationType": + "CalendarDays", "evaluationPeriodDays": 30, "value": 50.0}}, "category": "Latency", + "description": "CLI SLI scenario test updated", "destinationAmwAccounts": [{"identity": + "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli-test-sli-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/cli-test-sli-uami", + "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli-test-sli-rg/providers/microsoft.monitor/accounts/cli-test-sli-amw"}], + "enableAlert": true, "evaluationType": "RequestBased", "sliProperties": {"goodSignals": + {"signalFormula": "A", "signalSources": [{"filters": [{"dimensionName": "dimName1", + "operator": "eq", "value": "GetContosoUsers"}], "metricName": "cliTestMetric1", + "metricNamespace": "cliTestNamespace", "signalSourceId": "A", "sourceAmwAccountManagedIdentity": + "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli-test-sli-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/cli-test-sli-uami", + "sourceAmwAccountResourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli-test-sli-rg/providers/microsoft.monitor/accounts/cli-test-sli-amw", + "spatialAggregation": {"dimensions": ["dimName1"], "type": "Count"}, "temporalAggregation": + {"type": "Max"}}]}, "totalSignals": {"signalFormula": "A", "signalSources": + [{"filters": [{"dimensionName": "dimName1", "operator": "eq", "value": "GetContosoUsers"}], + "metricName": "cliTestMetric1", "metricNamespace": "cliTestNamespace", "signalSourceId": + "A", "sourceAmwAccountManagedIdentity": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli-test-sli-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/cli-test-sli-uami", + "sourceAmwAccountResourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli-test-sli-rg/providers/microsoft.monitor/accounts/cli-test-sli-amw", + "spatialAggregation": {"dimensions": ["dimName1"], "type": "Count"}, "temporalAggregation": + {"type": "Max"}}]}}}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - monitor sli update + Connection: + - keep-alive + Content-Length: + - '2383' + Content-Type: + - application/json + ParameterSetName: + - --service-group-name --sli-name --description --enable-alert + User-Agent: + - AZURECLI/2.86.0 azsdk-python-core/1.39.0 Python/3.11.9 (Windows-10-10.0.26200-SP0) + method: PUT + uri: https://management.azure.com/providers/Microsoft.Management/serviceGroups/cli-test-sli-sg/providers/Microsoft.Monitor/slis/clisli000001?api-version=2025-03-01-preview + response: + body: + string: '{"id":"/providers/Microsoft.Management/serviceGroups/cli-test-sli-sg/providers/Microsoft.Monitor/slis/clisli000001","name":"clisli000001","type":"microsoft.monitor/slis","systemData":{"createdBy":"test@example.com","createdByType":"User","createdAt":"2026-05-23T17:57:14.7445149Z","lastModifiedBy":"test@example.com","lastModifiedByType":"User","lastModifiedAt":"2026-05-23T17:57:22.7281506Z"},"identity":{"type":"UserAssigned","userAssignedIdentities":{"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli-test-sli-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/cli-test-sli-uami":{"clientId":"c355a8a2-2d6b-491e-86f6-42b11846b324","principalId":"f9ac6c44-5c1c-4bd5-9f89-90e804c3fa6f"}}},"properties":{"description":"CLI + SLI scenario test updated","category":"Latency","evaluationType":"RequestBased","provisioningState":"Succeeded","executionState":{"message":null,"state":"Pending"},"destinationAmwAccounts":[{"resourceId":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli-test-sli-rg/providers/microsoft.monitor/accounts/cli-test-sli-amw","identity":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli-test-sli-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/cli-test-sli-uami"}],"destinationMetrics":[{"metricName":"clisli000001:Good","metricNamespace":"cli-test-sli-sg"},{"metricName":"clisli000001:Total","metricNamespace":"cli-test-sli-sg"},{"metricName":"clisli000001:Value","metricNamespace":"cli-test-sli-sg"}],"baselineProperties":{"baseline":{"value":50.0,"evaluationCalculationType":"CalendarDays","evaluationPeriodDays":30}},"streamingRuleId":"72f988bf-86f1-41af-91ab-2d7cd011db47_global_bb0fbe78-c966-45c1-af84-b7220c084dd0","streamingRuleLastUpdatedTimestamp":"2026-05-23T17:57:25.6697794Z","enableAlert":true,"sliProperties":{"goodSignals":{"signalFormula":"A","signalSources":[{"signalSourceId":"A","sourceAmwAccountManagedIdentity":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli-test-sli-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/cli-test-sli-uami","sourceAmwAccountResourceId":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli-test-sli-rg/providers/microsoft.monitor/accounts/cli-test-sli-amw","metricNamespace":"cliTestNamespace","metricName":"cliTestMetric1","filters":[{"dimensionName":"dimName1","operator":"eq","value":"GetContosoUsers"}],"spatialAggregation":{"type":"Count","dimensions":["dimName1"]},"temporalAggregation":{"type":"Max"}}]},"totalSignals":{"signalFormula":"A","signalSources":[{"signalSourceId":"A","sourceAmwAccountManagedIdentity":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli-test-sli-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/cli-test-sli-uami","sourceAmwAccountResourceId":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli-test-sli-rg/providers/microsoft.monitor/accounts/cli-test-sli-amw","metricNamespace":"cliTestNamespace","metricName":"cliTestMetric1","filters":[{"dimensionName":"dimName1","operator":"eq","value":"GetContosoUsers"}],"spatialAggregation":{"type":"Count","dimensions":["dimName1"]},"temporalAggregation":{"type":"Max"}}]}}}}' + headers: + accept-ranges: + - bytes + cache-control: + - no-cache + content-length: + - '3286' + content-type: + - application/json; charset=utf-8 + date: + - Sat, 23 May 2026 17:57:25 GMT + etag: + - '"c0028ff1-0000-0a00-0000-6a11ea850000"' + expires: + - '-1' + mise-correlation-id: + - 02da1205-3049-499c-a4d8-ac111663c169 + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-azure-ref: + - 20260523T175723Z-1646496db66scv25hC1CO16cq400000006hg000000001w44 + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-ms-operation-identifier: + - '' + x-ms-providerhub-traffic: + - 'True' + x-ms-ratelimit-remaining-tenant-writes: + - '799' + x-msedge-ref: + - 'Ref A: BF45101EAA664030B4786A8BBEC27201 Ref B: MWH011020806052 Ref C: 2026-05-23T17:57:22Z' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - monitor sli delete + Connection: + - keep-alive + Content-Length: + - '0' + ParameterSetName: + - --service-group-name --sli-name --yes + User-Agent: + - AZURECLI/2.86.0 azsdk-python-core/1.39.0 Python/3.11.9 (Windows-10-10.0.26200-SP0) + method: DELETE + uri: https://management.azure.com/providers/Microsoft.Management/serviceGroups/cli-test-sli-sg/providers/Microsoft.Monitor/slis/clisli000001?api-version=2025-03-01-preview + response: + body: + string: '{"error":{"code":"UnspecifiedError","message":"An unspecified error + occurred. (RequestId: dbfd9bb6-56d0-11f1-9b06-f4289dce1732, CorrelationId: + e3cd9712-051c-4fa6-aecc-2890dc787180)"}}' + headers: + cache-control: + - no-cache + content-length: + - '184' + content-type: + - application/json + date: + - Sat, 23 May 2026 17:57:35 GMT + etag: + - '"c002eef8-0000-0a00-0000-6a11ea8f0000"' + expires: + - '-1' + mise-correlation-id: + - 686a07ad-faa2-48f8-95de-b1138c8abaeb + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-azure-ref: + - 20260523T175728Z-1646496db66wl8qphC1CO1ss5c000000042000000000d928 + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-ms-failure-cause: + - service + x-ms-operation-identifier: + - '' + x-ms-providerhub-traffic: + - 'True' + x-ms-ratelimit-remaining-tenant-deletes: + - '800' + x-msedge-ref: + - 'Ref A: 936D302C676341BF9FB22742E9C8B707 Ref B: MWH011020808060 Ref C: 2026-05-23T17:57:27Z' + status: + code: 500 + message: Internal Server Error +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - monitor sli delete + Connection: + - keep-alive + Content-Length: + - '0' + ParameterSetName: + - --service-group-name --sli-name --yes + User-Agent: + - AZURECLI/2.86.0 azsdk-python-core/1.39.0 Python/3.11.9 (Windows-10-10.0.26200-SP0) + method: DELETE + uri: https://management.azure.com/providers/Microsoft.Management/serviceGroups/cli-test-sli-sg/providers/Microsoft.Monitor/slis/clisli000001?api-version=2025-03-01-preview + response: + body: + string: '{"error":{"code":"UnspecifiedError","message":"An unspecified error + occurred. (RequestId: dbfd9bb6-56d0-11f1-9b06-f4289dce1732, CorrelationId: + c42c9923-d7c7-4c15-8b99-ebef89f2baf4)"}}' + headers: + cache-control: + - no-cache + content-length: + - '184' + content-type: + - application/json + date: + - Sat, 23 May 2026 17:57:47 GMT + etag: + - '"c102b503-0000-0a00-0000-6a11ea9b0000"' + expires: + - '-1' + mise-correlation-id: + - 1a5f4c74-c93c-4d29-b9ca-0ceec290f573 + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-azure-ref: + - 20260523T175738Z-1646496db666wj24hC1CO13v6w0000000850000000002wwe + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-ms-failure-cause: + - service + x-ms-operation-identifier: + - '' + x-ms-providerhub-traffic: + - 'True' + x-ms-ratelimit-remaining-tenant-deletes: + - '800' + x-msedge-ref: + - 'Ref A: 4B9EDFBE00014316BD162373A04F809E Ref B: MWH011020806025 Ref C: 2026-05-23T17:57:36Z' + status: + code: 500 + message: Internal Server Error +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - monitor sli delete + Connection: + - keep-alive + Content-Length: + - '0' + ParameterSetName: + - --service-group-name --sli-name --yes + User-Agent: + - AZURECLI/2.86.0 azsdk-python-core/1.39.0 Python/3.11.9 (Windows-10-10.0.26200-SP0) + method: DELETE + uri: https://management.azure.com/providers/Microsoft.Management/serviceGroups/cli-test-sli-sg/providers/Microsoft.Monitor/slis/clisli000001?api-version=2025-03-01-preview + response: + body: + string: '' + headers: + accept-ranges: + - bytes + cache-control: + - no-cache + content-length: + - '0' + date: + - Sat, 23 May 2026 17:57:51 GMT + expires: + - '-1' + mise-correlation-id: + - b6877f65-5c71-40a6-9f1e-15982ffaeea3 + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-azure-ref: + - 20260523T175751Z-177cf685948bs76whC1CO194h000000007w000000000rqrn + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-ms-operation-identifier: + - '' + x-ms-providerhub-traffic: + - 'True' + x-ms-ratelimit-remaining-tenant-deletes: + - '799' + x-msedge-ref: + - 'Ref A: CC9173DA239F49998D8DFD607285C008 Ref B: MWH011020808052 Ref C: 2026-05-23T17:57:49Z' + status: + code: 200 + message: OK +version: 1 diff --git a/src/azure-cli/azure/cli/command_modules/monitor/tests/latest/recordings/test_monitor_sli_uami_rotation.yaml b/src/azure-cli/azure/cli/command_modules/monitor/tests/latest/recordings/test_monitor_sli_uami_rotation.yaml new file mode 100644 index 00000000000..c8b19d24d8e --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/tests/latest/recordings/test_monitor_sli_uami_rotation.yaml @@ -0,0 +1,276 @@ +interactions: +- request: + body: '{"identity": {"userAssignedIdentities": {"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli-test-sli-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/cli-test-sli-uami": + {}}, "type": "UserAssigned"}, "properties": {"baselineProperties": {"baseline": + {"evaluationCalculationType": "CalendarDays", "evaluationPeriodDays": 30, "value": + 50.0}}, "category": "Latency", "description": "CLI SLI rotation test", "destinationAmwAccounts": + [{"identity": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli-test-sli-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/cli-test-sli-uami", + "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli-test-sli-rg/providers/microsoft.monitor/accounts/cli-test-sli-amw"}], + "enableAlert": false, "evaluationType": "RequestBased", "sliProperties": {"goodSignals": + {"signalFormula": "A", "signalSources": [{"filters": [{"dimensionName": "dimName1", + "operator": "eq", "samplingType": "Count", "value": "GetContosoUsers"}], "metricName": + "cliTestMetric1", "metricNamespace": "cliTestNamespace", "signalSourceId": + "A", "sourceAmwAccountManagedIdentity": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli-test-sli-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/cli-test-sli-uami", + "sourceAmwAccountResourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli-test-sli-rg/providers/microsoft.monitor/accounts/cli-test-sli-amw", + "spatialAggregation": {"dimensions": ["dimName1"], "type": "Count"}, "temporalAggregation": + {"type": "Max"}}]}, "totalSignals": {"signalFormula": "A", "signalSources": + [{"filters": [{"dimensionName": "dimName1", "operator": "eq", "samplingType": + "Count", "value": "GetContosoUsers"}], "metricName": "cliTestMetric1", "metricNamespace": + "cliTestNamespace", "signalSourceId": "A", "sourceAmwAccountManagedIdentity": + "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli-test-sli-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/cli-test-sli-uami", + "sourceAmwAccountResourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli-test-sli-rg/providers/microsoft.monitor/accounts/cli-test-sli-amw", + "spatialAggregation": {"dimensions": ["dimName1"], "type": "Count"}, "temporalAggregation": + {"type": "Max"}}]}}}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - monitor sli create + Connection: + - keep-alive + Content-Length: + - '2426' + Content-Type: + - application/json + ParameterSetName: + - --service-group-name --sli-name --category --evaluation-type --description + --enable-alert --user-assigned --destination-amw-accounts --baseline-properties + --sli-properties + User-Agent: + - AZURECLI/2.86.0 azsdk-python-core/1.39.0 Python/3.11.9 (Windows-10-10.0.26200-SP0) + method: PUT + uri: https://management.azure.com/providers/Microsoft.Management/serviceGroups/cli-test-sli-sg/providers/Microsoft.Monitor/slis/clislirot000001?api-version=2025-03-01-preview + response: + body: + string: '{"id":"/providers/Microsoft.Management/serviceGroups/cli-test-sli-sg/providers/Microsoft.Monitor/slis/clislirot000001","name":"clislirot000001","type":"microsoft.monitor/slis","systemData":{"createdBy":"test@example.com","createdByType":"User","createdAt":"2026-05-23T18:47:13.8307726Z","lastModifiedBy":"test@example.com","lastModifiedByType":"User","lastModifiedAt":"2026-05-23T18:47:13.8307726Z"},"identity":{"type":"UserAssigned","userAssignedIdentities":{"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli-test-sli-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/cli-test-sli-uami":{"clientId":"c355a8a2-2d6b-491e-86f6-42b11846b324","principalId":"f9ac6c44-5c1c-4bd5-9f89-90e804c3fa6f"}}},"properties":{"description":"CLI + SLI rotation test","category":"Latency","evaluationType":"RequestBased","provisioningState":"Succeeded","executionState":{"message":null,"state":"Pending"},"destinationAmwAccounts":[{"resourceId":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli-test-sli-rg/providers/microsoft.monitor/accounts/cli-test-sli-amw","identity":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli-test-sli-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/cli-test-sli-uami"}],"destinationMetrics":[{"metricName":"clislirot000001:Good","metricNamespace":"cli-test-sli-sg"},{"metricName":"clislirot000001:Total","metricNamespace":"cli-test-sli-sg"},{"metricName":"clislirot000001:Value","metricNamespace":"cli-test-sli-sg"}],"baselineProperties":{"baseline":{"value":50.0,"evaluationCalculationType":"CalendarDays","evaluationPeriodDays":30}},"streamingRuleId":"72f988bf-86f1-41af-91ab-2d7cd011db47_global_75867cb7-909e-4698-b932-68c7cee42428","streamingRuleLastUpdatedTimestamp":"2026-05-23T18:47:17.1774363Z","enableAlert":false,"sliProperties":{"goodSignals":{"signalFormula":"A","signalSources":[{"signalSourceId":"A","sourceAmwAccountManagedIdentity":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli-test-sli-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/cli-test-sli-uami","sourceAmwAccountResourceId":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli-test-sli-rg/providers/microsoft.monitor/accounts/cli-test-sli-amw","metricNamespace":"cliTestNamespace","metricName":"cliTestMetric1","filters":[{"dimensionName":"dimName1","operator":"eq","value":"GetContosoUsers"}],"spatialAggregation":{"type":"Count","dimensions":["dimName1"]},"temporalAggregation":{"type":"Max"}}]},"totalSignals":{"signalFormula":"A","signalSources":[{"signalSourceId":"A","sourceAmwAccountManagedIdentity":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli-test-sli-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/cli-test-sli-uami","sourceAmwAccountResourceId":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli-test-sli-rg/providers/microsoft.monitor/accounts/cli-test-sli-amw","metricNamespace":"cliTestNamespace","metricName":"cliTestMetric1","filters":[{"dimensionName":"dimName1","operator":"eq","value":"GetContosoUsers"}],"spatialAggregation":{"type":"Count","dimensions":["dimName1"]},"temporalAggregation":{"type":"Max"}}]}}}}' + headers: + accept-ranges: + - bytes + cache-control: + - no-cache + content-length: + - '3294' + content-type: + - application/json; charset=utf-8 + date: + - Sat, 23 May 2026 18:47:16 GMT + etag: + - '"cd02fc5d-0000-0a00-0000-6a11f6350000"' + expires: + - '-1' + mise-correlation-id: + - 8e9865f0-489b-4707-9e4e-aa0c1a0257d9 + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-azure-ref: + - 20260523T184714Z-1646496db66vt7kbhC1CO1ce000000000760000000002vnq + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-ms-operation-identifier: + - '' + x-ms-providerhub-traffic: + - 'True' + x-ms-ratelimit-remaining-tenant-writes: + - '799' + x-msedge-ref: + - 'Ref A: BCFA52B4677746A58D71C944B8B0F6B0 Ref B: CO6AA3150220045 Ref C: 2026-05-23T18:47:13Z' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - monitor sli update + Connection: + - keep-alive + ParameterSetName: + - --service-group-name --sli-name --set --set --set --set + User-Agent: + - AZURECLI/2.86.0 azsdk-python-core/1.39.0 Python/3.11.9 (Windows-10-10.0.26200-SP0) + method: GET + uri: https://management.azure.com/providers/Microsoft.Management/serviceGroups/cli-test-sli-sg/providers/Microsoft.Monitor/slis/clislirot000001?api-version=2025-03-01-preview + response: + body: + string: '{"id":"/providers/Microsoft.Management/serviceGroups/cli-test-sli-sg/providers/Microsoft.Monitor/slis/clislirot000001","name":"clislirot000001","type":"microsoft.monitor/slis","systemData":{"createdBy":"test@example.com","createdByType":"User","createdAt":"2026-05-23T18:47:13.8307726Z","lastModifiedBy":"test@example.com","lastModifiedByType":"User","lastModifiedAt":"2026-05-23T18:47:13.8307726Z"},"identity":{"type":"UserAssigned","userAssignedIdentities":{"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli-test-sli-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/cli-test-sli-uami":{"clientId":"c355a8a2-2d6b-491e-86f6-42b11846b324","principalId":"f9ac6c44-5c1c-4bd5-9f89-90e804c3fa6f"}}},"properties":{"description":"CLI + SLI rotation test","category":"Latency","evaluationType":"RequestBased","provisioningState":"Succeeded","executionState":{"message":null,"state":"Pending"},"destinationAmwAccounts":[{"resourceId":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli-test-sli-rg/providers/microsoft.monitor/accounts/cli-test-sli-amw","identity":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli-test-sli-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/cli-test-sli-uami"}],"destinationMetrics":[{"metricName":"clislirot000001:Good","metricNamespace":"cli-test-sli-sg"},{"metricName":"clislirot000001:Total","metricNamespace":"cli-test-sli-sg"},{"metricName":"clislirot000001:Value","metricNamespace":"cli-test-sli-sg"}],"baselineProperties":{"baseline":{"value":50,"evaluationCalculationType":"CalendarDays","evaluationPeriodDays":30}},"streamingRuleId":"72f988bf-86f1-41af-91ab-2d7cd011db47_global_75867cb7-909e-4698-b932-68c7cee42428","streamingRuleLastUpdatedTimestamp":"2026-05-23T18:47:17.1774363Z","enableAlert":false,"sliProperties":{"goodSignals":{"signalFormula":"A","signalSources":[{"signalSourceId":"A","sourceAmwAccountManagedIdentity":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli-test-sli-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/cli-test-sli-uami","sourceAmwAccountResourceId":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli-test-sli-rg/providers/microsoft.monitor/accounts/cli-test-sli-amw","metricNamespace":"cliTestNamespace","metricName":"cliTestMetric1","filters":[{"dimensionName":"dimName1","operator":"eq","value":"GetContosoUsers"}],"spatialAggregation":{"type":"Count","dimensions":["dimName1"]},"temporalAggregation":{"type":"Max"}}]},"totalSignals":{"signalFormula":"A","signalSources":[{"signalSourceId":"A","sourceAmwAccountManagedIdentity":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli-test-sli-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/cli-test-sli-uami","sourceAmwAccountResourceId":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli-test-sli-rg/providers/microsoft.monitor/accounts/cli-test-sli-amw","metricNamespace":"cliTestNamespace","metricName":"cliTestMetric1","filters":[{"dimensionName":"dimName1","operator":"eq","value":"GetContosoUsers"}],"spatialAggregation":{"type":"Count","dimensions":["dimName1"]},"temporalAggregation":{"type":"Max"}}]}}}}' + headers: + cache-control: + - no-cache + content-length: + - '3292' + content-type: + - application/json; charset=utf-8 + date: + - Sat, 23 May 2026 18:47:17 GMT + etag: + - '"cd02fc5d-0000-0a00-0000-6a11f6350000"' + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-ms-operation-identifier: + - '' + x-ms-providerhub-traffic: + - 'True' + x-msedge-ref: + - 'Ref A: 69E30B764C6240EC95DDD15F143EC879 Ref B: MWH011020808052 Ref C: 2026-05-23T18:47:18Z' + status: + code: 200 + message: OK +- request: + body: '{"identity": {"type": "UserAssigned", "userAssignedIdentities": {"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli-test-sli-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/cli-test-sli-uami-2": + {}}}, "properties": {"baselineProperties": {"baseline": {"evaluationCalculationType": + "CalendarDays", "evaluationPeriodDays": 30, "value": 50.0}}, "category": "Latency", + "description": "CLI SLI rotation test", "destinationAmwAccounts": [{"identity": + "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli-test-sli-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/cli-test-sli-uami-2", + "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli-test-sli-rg/providers/microsoft.monitor/accounts/cli-test-sli-amw"}], + "enableAlert": false, "evaluationType": "RequestBased", "sliProperties": {"goodSignals": + {"signalFormula": "A", "signalSources": [{"filters": [{"dimensionName": "dimName1", + "operator": "eq", "value": "GetContosoUsers"}], "metricName": "cliTestMetric1", + "metricNamespace": "cliTestNamespace", "signalSourceId": "A", "sourceAmwAccountManagedIdentity": + "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli-test-sli-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/cli-test-sli-uami-2", + "sourceAmwAccountResourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli-test-sli-rg/providers/microsoft.monitor/accounts/cli-test-sli-amw", + "spatialAggregation": {"dimensions": ["dimName1"], "type": "Count"}, "temporalAggregation": + {"type": "Max"}}]}, "totalSignals": {"signalFormula": "A", "signalSources": + [{"filters": [{"dimensionName": "dimName1", "operator": "eq", "value": "GetContosoUsers"}], + "metricName": "cliTestMetric1", "metricNamespace": "cliTestNamespace", "signalSourceId": + "A", "sourceAmwAccountManagedIdentity": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli-test-sli-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/cli-test-sli-uami-2", + "sourceAmwAccountResourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli-test-sli-rg/providers/microsoft.monitor/accounts/cli-test-sli-amw", + "spatialAggregation": {"dimensions": ["dimName1"], "type": "Count"}, "temporalAggregation": + {"type": "Max"}}]}}}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - monitor sli update + Connection: + - keep-alive + Content-Length: + - '2384' + Content-Type: + - application/json + ParameterSetName: + - --service-group-name --sli-name --set --set --set --set + User-Agent: + - AZURECLI/2.86.0 azsdk-python-core/1.39.0 Python/3.11.9 (Windows-10-10.0.26200-SP0) + method: PUT + uri: https://management.azure.com/providers/Microsoft.Management/serviceGroups/cli-test-sli-sg/providers/Microsoft.Monitor/slis/clislirot000001?api-version=2025-03-01-preview + response: + body: + string: '{"id":"/providers/Microsoft.Management/serviceGroups/cli-test-sli-sg/providers/Microsoft.Monitor/slis/clislirot000001","name":"clislirot000001","type":"microsoft.monitor/slis","systemData":{"createdBy":"test@example.com","createdByType":"User","createdAt":"2026-05-23T18:47:13.8307726Z","lastModifiedBy":"test@example.com","lastModifiedByType":"User","lastModifiedAt":"2026-05-23T18:47:18.9729399Z"},"identity":{"type":"UserAssigned","userAssignedIdentities":{"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli-test-sli-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/cli-test-sli-uami-2":{"clientId":"a7c6f044-28b2-4005-8823-b420bd51af51","principalId":"249cb22e-c9b6-4190-9419-29b2bd914d5a"}}},"properties":{"description":"CLI + SLI rotation test","category":"Latency","evaluationType":"RequestBased","provisioningState":"Succeeded","executionState":{"message":null,"state":"Pending"},"destinationAmwAccounts":[{"resourceId":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli-test-sli-rg/providers/microsoft.monitor/accounts/cli-test-sli-amw","identity":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli-test-sli-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/cli-test-sli-uami-2"}],"destinationMetrics":[{"metricName":"clislirot000001:Good","metricNamespace":"cli-test-sli-sg"},{"metricName":"clislirot000001:Total","metricNamespace":"cli-test-sli-sg"},{"metricName":"clislirot000001:Value","metricNamespace":"cli-test-sli-sg"}],"baselineProperties":{"baseline":{"value":50.0,"evaluationCalculationType":"CalendarDays","evaluationPeriodDays":30}},"streamingRuleId":"72f988bf-86f1-41af-91ab-2d7cd011db47_global_75867cb7-909e-4698-b932-68c7cee42428","streamingRuleLastUpdatedTimestamp":"2026-05-23T18:47:22.5592904Z","enableAlert":false,"sliProperties":{"goodSignals":{"signalFormula":"A","signalSources":[{"signalSourceId":"A","sourceAmwAccountManagedIdentity":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli-test-sli-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/cli-test-sli-uami-2","sourceAmwAccountResourceId":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli-test-sli-rg/providers/microsoft.monitor/accounts/cli-test-sli-amw","metricNamespace":"cliTestNamespace","metricName":"cliTestMetric1","filters":[{"dimensionName":"dimName1","operator":"eq","value":"GetContosoUsers"}],"spatialAggregation":{"type":"Count","dimensions":["dimName1"]},"temporalAggregation":{"type":"Max"}}]},"totalSignals":{"signalFormula":"A","signalSources":[{"signalSourceId":"A","sourceAmwAccountManagedIdentity":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli-test-sli-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/cli-test-sli-uami-2","sourceAmwAccountResourceId":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli-test-sli-rg/providers/microsoft.monitor/accounts/cli-test-sli-amw","metricNamespace":"cliTestNamespace","metricName":"cliTestMetric1","filters":[{"dimensionName":"dimName1","operator":"eq","value":"GetContosoUsers"}],"spatialAggregation":{"type":"Count","dimensions":["dimName1"]},"temporalAggregation":{"type":"Max"}}]}}}}' + headers: + accept-ranges: + - bytes + cache-control: + - no-cache + content-length: + - '3302' + content-type: + - application/json; charset=utf-8 + date: + - Sat, 23 May 2026 18:47:22 GMT + etag: + - '"cd02a96d-0000-0a00-0000-6a11f63a0000"' + expires: + - '-1' + mise-correlation-id: + - 11cd9dc7-1718-457c-b8fa-26ba068c3809 + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-azure-ref: + - 20260523T184719Z-1646496db66s6dzthC1CO1wzr400000007s000000000dd4e + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-ms-operation-identifier: + - '' + x-ms-providerhub-traffic: + - 'True' + x-ms-ratelimit-remaining-tenant-writes: + - '799' + x-msedge-ref: + - 'Ref A: 324CC3E673E84623ABD261E1A1D343CD Ref B: MWH011020807029 Ref C: 2026-05-23T18:47:18Z' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - monitor sli delete + Connection: + - keep-alive + Content-Length: + - '0' + ParameterSetName: + - --service-group-name --sli-name --yes + User-Agent: + - AZURECLI/2.86.0 azsdk-python-core/1.39.0 Python/3.11.9 (Windows-10-10.0.26200-SP0) + method: DELETE + uri: https://management.azure.com/providers/Microsoft.Management/serviceGroups/cli-test-sli-sg/providers/Microsoft.Monitor/slis/clislirot000001?api-version=2025-03-01-preview + response: + body: + string: '' + headers: + accept-ranges: + - bytes + cache-control: + - no-cache + content-length: + - '0' + date: + - Sat, 23 May 2026 18:47:49 GMT + expires: + - '-1' + mise-correlation-id: + - 935a9aaa-6e6b-49df-a5a5-6ad32a331589 + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-azure-ref: + - 20260523T184741Z-1646496db66skvvkhC1CO16z8400000003mg0000000084tz + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-ms-operation-identifier: + - '' + x-ms-providerhub-traffic: + - 'True' + x-ms-ratelimit-remaining-tenant-deletes: + - '800' + x-msedge-ref: + - 'Ref A: B5E870D832784BDABD521C2ADD8965D8 Ref B: MWH011020809060 Ref C: 2026-05-23T18:47:41Z' + status: + code: 200 + message: OK +version: 1 diff --git a/src/azure-cli/azure/cli/command_modules/monitor/tests/latest/test_monitor_sli_scenario.py b/src/azure-cli/azure/cli/command_modules/monitor/tests/latest/test_monitor_sli_scenario.py new file mode 100644 index 00000000000..18f7b40ca1c --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/tests/latest/test_monitor_sli_scenario.py @@ -0,0 +1,251 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + +"""Live-recordable scenario tests for ``az monitor sli``. + +The ``Microsoft.Monitor`` SLI resource provider is tenant-scoped under a +``Microsoft.Management/serviceGroups`` parent. Azure CLI does not currently +expose a command for creating service groups, so the service group and the +referenced UAMI + AMW account must be pre-provisioned in a tenant where the +``2025-03-01-preview`` API is enabled. + +When the cassette is absent or stale, re-record with:: + + az login + azdev test test_monitor_sli_crud --live + +The cassette is recorded against the *currently active* subscription, so make +sure ``az account show`` points to a tenant where the SLI preview API is +enabled before re-recording. + +Override any of the prerequisites with these environment variables: + + * ``AZURE_CLI_TEST_SLI_SERVICE_GROUP`` - name of an existing service group. + * ``AZURE_CLI_TEST_SLI_UAMI_ID`` - ARM ID of a UAMI authorized to read from + the AMW account below. + * ``AZURE_CLI_TEST_SLI_UAMI_ID_2`` - ARM ID of a second UAMI used by the + rotation test. Must have the same RBAC on the AMW as the primary UAMI. + * ``AZURE_CLI_TEST_SLI_AMW_ID`` - ARM ID of the Azure Monitor (AMW) account + used as both destination and signal source. +""" + +import json +import os + +from azure.cli.testsdk import ScenarioTest + + +_DEFAULT_SERVICE_GROUP = "cli-test-sli-sg" +# Resource IDs are built relative to the test's current subscription so the +# cassette (scrubbed to MOCKED_SUBSCRIPTION_ID) replays cleanly without the AAZ +# auxiliary-subscription lookup failing against the mocked profile. +_DEFAULT_UAMI_TEMPLATE = ( + "/subscriptions/{sub}/resourcegroups/cli-test-sli-rg/providers/" + "Microsoft.ManagedIdentity/userAssignedIdentities/cli-test-sli-uami" +) +_DEFAULT_UAMI_2_TEMPLATE = ( + "/subscriptions/{sub}/resourcegroups/cli-test-sli-rg/providers/" + "Microsoft.ManagedIdentity/userAssignedIdentities/cli-test-sli-uami-2" +) +_DEFAULT_AMW_TEMPLATE = ( + "/subscriptions/{sub}/resourceGroups/cli-test-sli-rg/providers/" + "microsoft.monitor/accounts/cli-test-sli-amw" +) + + +def _build_signal_source(uami_id, amw_id, signal_source_id="A"): + return { + "filters": [ + { + "dimensionName": "dimName1", + "operator": "eq", + "value": "GetContosoUsers", + "samplingType": "Count", + }, + ], + "metricName": "cliTestMetric1", + "metricNamespace": "cliTestNamespace", + "signalSourceId": signal_source_id, + "sourceAmwAccountManagedIdentity": uami_id, + "sourceAmwAccountResourceId": amw_id, + "spatialAggregation": {"dimensions": ["dimName1"], "type": "Count"}, + "temporalAggregation": {"type": "Max"}, + } + + +class TestMonitorSliScenarios(ScenarioTest): + + def _common_kwargs(self, sub_id, sli_name_prefix): + return { + "sg": os.environ.get("AZURE_CLI_TEST_SLI_SERVICE_GROUP", _DEFAULT_SERVICE_GROUP), + "sli": self.create_random_name(sli_name_prefix, 20), + "uami_id": os.environ.get( + "AZURE_CLI_TEST_SLI_UAMI_ID", _DEFAULT_UAMI_TEMPLATE.format(sub=sub_id) + ), + "uami_id_2": os.environ.get( + "AZURE_CLI_TEST_SLI_UAMI_ID_2", _DEFAULT_UAMI_2_TEMPLATE.format(sub=sub_id) + ), + "amw_id": os.environ.get( + "AZURE_CLI_TEST_SLI_AMW_ID", _DEFAULT_AMW_TEMPLATE.format(sub=sub_id) + ), + } + + def test_monitor_sli_crud(self): + sub_id = self.get_subscription_id() + self.kwargs.update(self._common_kwargs(sub_id, "clisli")) + + good_signal_source = _build_signal_source(self.kwargs["uami_id"], self.kwargs["amw_id"]) + total_signal_source = _build_signal_source(self.kwargs["uami_id"], self.kwargs["amw_id"], signal_source_id="B") + self.kwargs.update({ + "baseline": json.dumps({ + "baseline": { + "evaluationCalculationType": "CalendarDays", + "evaluationPeriodDays": 30, + "value": 50, + }, + }), + "destination_amw_accounts": json.dumps([{ + "identity": self.kwargs["uami_id"], + "resourceId": self.kwargs["amw_id"], + }]), + "sli_properties": json.dumps({ + "goodSignals": {"signalFormula": "A", "signalSources": [good_signal_source]}, + "totalSignals": {"signalFormula": "B", "signalSources": [total_signal_source]}, + }), + }) + + try: + self.cmd( + "monitor sli create --service-group-name {sg} --sli-name {sli} " + "--category Latency --evaluation-type RequestBased " + "--description 'CLI SLI scenario test' --enable-alert false " + "--user-assigned {uami_id} " + "--destination-amw-accounts '{destination_amw_accounts}' " + "--baseline-properties '{baseline}' --sli-properties '{sli_properties}'", + checks=[ + self.check("name", "{sli}"), + self.check("properties.category", "Latency"), + self.check("properties.evaluationType", "RequestBased"), + self.check("properties.enableAlert", False), + self.check("properties.description", "CLI SLI scenario test"), + ], + ) + + self.cmd( + "monitor sli show --service-group-name {sg} --sli-name {sli}", + checks=[ + self.check("name", "{sli}"), + self.check("properties.description", "CLI SLI scenario test"), + ], + ) + + self.cmd( + "monitor sli list --service-group-name {sg}", + checks=[self.exists("[?name=='{sli}']")], + ) + + self.cmd( + "monitor sli update --service-group-name {sg} --sli-name {sli} " + "--description 'CLI SLI scenario test updated' --enable-alert true", + checks=[ + self.check("name", "{sli}"), + self.check("properties.description", "CLI SLI scenario test updated"), + self.check("properties.enableAlert", True), + ], + ) + finally: + self.cmd("monitor sli delete --service-group-name {sg} --sli-name {sli} --yes") + + def test_monitor_sli_uami_rotation(self): + """Rotate source-AMW and destination-AMW UAMIs together in a single + ``az monitor sli update`` call, exercising the three-place identity + invariant documented in ``az monitor sli update --help``. + + Because the same UAMI is used for both source and destination in this + fixture, a single rotation pass updates all three identity surfaces: + + 1. ``identity.userAssignedIdentities`` (remove old, add new). + 2. ``properties.destinationAmwAccounts[0].identity``. + 3. ``properties.sliProperties.goodSignals.signalSources[0].sourceAmwAccountManagedIdentity`` + and the matching ``totalSignals`` entry (request-based SLI). + """ + sub_id = self.get_subscription_id() + self.kwargs.update(self._common_kwargs(sub_id, "clislirot")) + + good_signal_source = _build_signal_source(self.kwargs["uami_id"], self.kwargs["amw_id"]) + total_signal_source = _build_signal_source(self.kwargs["uami_id"], self.kwargs["amw_id"], signal_source_id="B") + self.kwargs.update({ + "baseline": json.dumps({ + "baseline": { + "evaluationCalculationType": "CalendarDays", + "evaluationPeriodDays": 30, + "value": 50, + }, + }), + "destination_amw_accounts": json.dumps([{ + "identity": self.kwargs["uami_id"], + "resourceId": self.kwargs["amw_id"], + }]), + "sli_properties": json.dumps({ + "goodSignals": {"signalFormula": "A", "signalSources": [good_signal_source]}, + "totalSignals": {"signalFormula": "B", "signalSources": [total_signal_source]}, + }), + # ARM IDs contain dots (Microsoft.ManagedIdentity, etc.), so they + # cannot be addressed as path segments by --set/--remove. The + # working idiom is to replace the entire userAssignedIdentities + # map with a JSON value rooted at a dotless path. + "user_assigned_identities_new": json.dumps({self.kwargs["uami_id_2"]: {}}), + }) + + try: + self.cmd( + "monitor sli create --service-group-name {sg} --sli-name {sli} " + "--category Latency --evaluation-type RequestBased " + "--description 'CLI SLI rotation test' --enable-alert false " + "--user-assigned {uami_id} " + "--destination-amw-accounts '{destination_amw_accounts}' " + "--baseline-properties '{baseline}' --sli-properties '{sli_properties}'", + checks=[ + self.check("name", "{sli}"), + self.check("identity.type", "UserAssigned"), + self.check("properties.destinationAmwAccounts[0].identity", "{uami_id}"), + self.check( + "properties.sliProperties.goodSignals.signalSources[0].sourceAmwAccountManagedIdentity", + "{uami_id}", + ), + self.check( + "properties.sliProperties.totalSignals.signalSources[0].sourceAmwAccountManagedIdentity", + "{uami_id}", + ), + self.exists("identity.userAssignedIdentities.\"{uami_id}\""), + ], + ) + + self.cmd( + "monitor sli update --service-group-name {sg} --sli-name {sli} " + "--set 'identity.userAssignedIdentities={user_assigned_identities_new}' " + "--set 'properties.destinationAmwAccounts[0].identity={uami_id_2}' " + "--set 'properties.sliProperties.goodSignals.signalSources[0].sourceAmwAccountManagedIdentity={uami_id_2}' " + "--set 'properties.sliProperties.totalSignals.signalSources[0].sourceAmwAccountManagedIdentity={uami_id_2}'", + checks=[ + self.check("name", "{sli}"), + self.check("identity.type", "UserAssigned"), + self.check("length(identity.userAssignedIdentities)", 1), + self.check("properties.destinationAmwAccounts[0].identity", "{uami_id_2}"), + self.check( + "properties.sliProperties.goodSignals.signalSources[0].sourceAmwAccountManagedIdentity", + "{uami_id_2}", + ), + self.check( + "properties.sliProperties.totalSignals.signalSources[0].sourceAmwAccountManagedIdentity", + "{uami_id_2}", + ), + self.exists("identity.userAssignedIdentities.\"{uami_id_2}\""), + self.not_exists("identity.userAssignedIdentities.\"{uami_id}\""), + ], + ) + finally: + self.cmd("monitor sli delete --service-group-name {sg} --sli-name {sli} --yes") +