Quantcast
Channel: Azure Management Portal forum
Viewing all articles
Browse latest Browse all 4189

Set JArray values with invalid key value: "LastUpdatedTime" on new alert rule creation

$
0
0

Hey all!

I'm trying to create a new alert rule using version 0.9.11 of the Monitoring Library and am getting this error on alertsClient.rules.CreateOrUpdate:

"Set JArray values with invalid key value: "LastUpdatedTime". Array position index expected."

That's interesting because LastUpdatedTime is a DateTime object, and whether I set it or I don't, if I set a breakpoint, it does set itself correctly, but the API appears to be expecting a JSON hash?

I've tested alertsClient and I'm able to get existing alerts (also metrics with metrics client), so I don't believe it's an access issue.

Any ideas?

The full code I'm using for the test (borrowed virtually verbatim from the Cloud Cover video here): 

Rule newRule = newRule

{

    Name = "CPU Over 90%",

    Id = Guid.NewGuid().ToString(),

    Description = "CPU Has been over 90% for 5 minutes",

    IsEnabled = true,

    LastUpdatedTime = DateTime.Now,

    Condition = newThresholdRuleCondition

    {

        Operator = Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.ConditionOperator.GreaterThan,

        Threshold = 90,

        WindowSize = TimeSpan.FromMinutes(5),

        DataSource = newRuleMetricDataSource

        {

            MetricName = "Percentage CPU",

            ResourceId = "",

            MetricNamespace = ResourceIdBuilder.BuildCloudServiceResourceId(<cloudservicename>, <deploymentname>)

        }

    }

};

RuleAction action = newRuleEmailAction

{

    SendToServiceOwners = true,

};

newRule.Actions.Add(action);

OperationResponse alertResponse = alertsClient.Rules.CreateOrUpdate(newRuleCreateOrUpdateParameters { Rule = newRule });

Console.WriteLine("Create alert rule response: "+ alertResponse.StatusCode);



Viewing all articles
Browse latest Browse all 4189

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>