Example #1
0
        public virtual async Task <ArmOperation <MetricAlertResource> > CreateOrUpdateAsync(WaitUntil waitUntil, string ruleName, MetricAlertData data, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(ruleName, nameof(ruleName));
            Argument.AssertNotNull(data, nameof(data));

            using var scope = _metricAlertClientDiagnostics.CreateScope("MetricAlertCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response = await _metricAlertRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, ruleName, data, cancellationToken).ConfigureAwait(false);

                var operation = new MonitorArmOperation <MetricAlertResource>(Response.FromValue(new MetricAlertResource(Client, response), response.GetRawResponse()));
                if (waitUntil == WaitUntil.Completed)
                {
                    await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
Example #2
0
 internal MetricAlertResource(ArmClient client, MetricAlertData data) : this(client, data.Id)
 {
     HasData = true;
     _data   = data;
 }