调用web api以在ADF中创建度量标准警报的错误请求 [英] Bad request on calling web api for creating metric alert in ADF
问题描述
我正在尝试调用Web API,以编程方式为我的数据工厂创建指标警报。以下是我要点击的网址:
I am trying to call Web API for creating metric alert programmatically for my data factory. Below is the url which I am hitting :
PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/ providers / Microsoft.Insights / metricAlerts / {ruleName}?api-version = 2018-03-01
我用参数修改了网址。
,我的代码如下所示:
HttpClient client = new HttpClient();
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(result.AccessTokenType, result.AccessToken);
HttpResponseMessage responseMessage = client.PutAsJsonAsync(ALERT_API, content).Result;
var responseObj = responseMessage.Content.ReadAsStringAsync().Result;
和我的配置文件如下:
location = "global",
tags = { },
properties = new Properties()
{
description = "This is test Alert through Code",
severity = 1,
scopes = new string[] { "/subscriptions/{SubscriptionId}/resourceGroup/{resourceGroupName}/providers/Microsoft.Analytics/dataFactory/{datafactoryName}" },
evaluationFrequency = "PT1M",
windowSize = "PT15M",
targetResourceType = "Microsoft.Analytics/dataFactory",
targetResourceRegion = "West Us 2",
criteria = new Criteria()
{
odatatype = "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria",
allOf = new Allof[]
{
new Allof
{
criterionType= "Failed activity runs metrics",
name = "TestAlert",
metricNamespace = "Microsoft.Analytics/dataFactory",
Operator = "GreaterOrLessThan",
timeAggregation = "Average",
dimensions = new Dimensions[]
{
new Dimensions
{
name = "ActivityType",
_operator = "Include",
values = new string[]
{
"Lookup"
}
}
},
alertSensitivity = "Medium",
failingPeriods = new Failingperiods()
{
numberOfEvaluationPeriods = 4,
minFailingPeriodsToAlert = 4
}
}
}
},
autoMitigate = false,
enabled = true,
actions = new AlertsConfig.Action[]
{
new AlertsConfig.Action
{
}
}
}
当我点击API时,它会发回Bad请求并抛出错误:
When I hit the API it sends back a Bad request and it throws an error :
"找不到条件"
"The criteria is not found"
你能帮助我解决这个问题吗?或者我在这里做错了什么。
Can you guys please help me to fix this issue? Or What am I doing wrong here.
提前致谢
推荐答案
Hello Ramandeep,
Hello Ramandeep ,
我们理解您的问题的方式是围绕API
The way we understand your question is around the API
https://management.azure.com/subscriptions/ {subscriptionId} /resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}?api-version=2018-03-01。
如果是这样的话你需要在 Microsoft.Insights论坛中提出这个问题。
If that's the case you need to ask this question in the Microsoft.Insights forum .
这篇关于调用web api以在ADF中创建度量标准警报的错误请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!