你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。
Web Tests - Create Or Update
创建或更新 Application Insights Web 测试定义。
PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/webtests/{webTestName}?api-version=2022-06-15
URI 参数
名称 | 在 | 必需 | 类型 | 说明 |
---|---|---|---|---|
resource
|
path | True |
string minLength: 1maxLength: 90 |
资源组的名称。 名称不区分大小写。 |
subscription
|
path | True |
string minLength: 1 |
目标订阅的 ID。 |
web
|
path | True |
string |
Application Insights WebTest 资源的名称。 |
api-version
|
query | True |
string minLength: 1 |
用于此作的 API 版本。 |
请求正文
名称 | 必需 | 类型 | 说明 |
---|---|---|---|
location | True |
string |
资源位置 |
properties.Kind | True |
Web 测试的类型是 ping、多步骤和标准。 |
|
properties.Locations | True |
一个列表,其中列出了从何处物理运行测试,以便为应用程序的可访问性提供全局覆盖范围。 |
|
properties.Name | True |
string |
如果用户定义的名称,则为此 WebTest。 |
properties.SyntheticMonitorId | True |
string |
此 WebTest 的唯一 ID。 此值通常与“名称”字段相同。 |
kind |
此 Web 测试监视的 WebTest 类型。 选项为 ping、多步骤和标准。 |
||
properties.Configuration |
WebTest 的 XML 配置规范。 |
||
properties.Description |
string |
此 WebTest 的用户定义说明。 |
|
properties.Enabled |
boolean |
正在主动监视测试。 |
|
properties.Frequency |
integer (int32) |
此 WebTest 的测试运行间隔(以秒为单位)。 默认值为 300。 |
|
properties.Request |
请求属性的集合 |
||
properties.RetryEnabled |
boolean |
如果此 WebTest 失败,则允许重试。 |
|
properties.Timeout |
integer (int32) |
直到此 WebTest 超时并失败的秒。 默认值为 30。 |
|
properties.ValidationRules |
验证规则属性的集合 |
||
tags |
object |
资源标记 |
响应
名称 | 类型 | 说明 |
---|---|---|
200 OK |
已成功创建或更新 Application Insights Web 测试。 |
安全性
azure_auth
Azure Active Directory OAuth2 Flow。
类型:
oauth2
流向:
implicit
授权 URL:
https://login.microsoftonline.com/common/oauth2/authorize
作用域
名称 | 说明 |
---|---|
user_impersonation | 模拟用户帐户 |
示例
web |
web |
web |
webTestCreate
示例请求
PUT https://management.azure.com/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/webtests/my-webtest-my-component?api-version=2022-06-15
{
"location": "South Central US",
"kind": "ping",
"properties": {
"Name": "my-webtest-my-component",
"SyntheticMonitorId": "my-webtest-my-component",
"Configuration": {
"WebTest": "<WebTest Name=\"my-webtest\" Id=\"678ddf96-1ab8-44c8-9274-123456789abc\" Enabled=\"True\" CssProjectStructure=\"\" CssIteration=\"\" Timeout=\"120\" WorkItemIds=\"\" xmlns=\"http://microsoft.com/schemas/VisualStudio/TeamTest/2010\" Description=\"\" CredentialUserName=\"\" CredentialPassword=\"\" PreAuthenticate=\"True\" Proxy=\"default\" StopOnError=\"False\" RecordedResultFile=\"\" ResultsLocale=\"\" ><Items><Request Method=\"GET\" Guid=\"a4162485-9114-fcfc-e086-123456789abc\" Version=\"1.1\" Url=\"http://my-component.azurewebsites.net\" ThinkTime=\"0\" Timeout=\"120\" ParseDependentRequests=\"True\" FollowRedirects=\"True\" RecordResult=\"True\" Cache=\"False\" ResponseTimeGoal=\"0\" Encoding=\"utf-8\" ExpectedHttpStatusCode=\"200\" ExpectedResponseUrl=\"\" ReportingName=\"\" IgnoreHttpStatusCode=\"False\" /></Items></WebTest>"
},
"Description": "Ping web test alert for mytestwebapp",
"Enabled": true,
"Frequency": 900,
"Timeout": 120,
"Kind": "ping",
"RetryEnabled": true,
"Locations": [
{
"Id": "us-fl-mia-edge"
}
]
}
}
示例响应
{
"id": "/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/webtests/my-webtest-my-component",
"name": "my-webtest-my-component",
"type": "Microsoft.Insights/webtests",
"location": "southcentralus",
"tags": {
"hidden-link:/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/components/my-component": "Resource"
},
"kind": "ping",
"properties": {
"Name": "my-webtest-my-component",
"SyntheticMonitorId": "my-webtest-my-component",
"Description": "Ping web test alert for mytestwebapp",
"Enabled": true,
"Frequency": 900,
"Timeout": 120,
"Kind": "ping",
"RetryEnabled": true,
"Locations": [
{
"Id": "us-fl-mia-edge"
}
],
"Configuration": {
"WebTest": "<WebTest Name=\"my-webtest\" Id=\"678ddf96-1ab8-44c8-9274-123456789abc\" Enabled=\"True\" CssProjectStructure=\"\" CssIteration=\"\" Timeout=\"120\" WorkItemIds=\"\" xmlns=\"http://microsoft.com/schemas/VisualStudio/TeamTest/2010\" Description=\"\" CredentialUserName=\"\" CredentialPassword=\"\" PreAuthenticate=\"True\" Proxy=\"default\" StopOnError=\"False\" RecordedResultFile=\"\" ResultsLocale=\"\" ><Items><Request Method=\"GET\" Guid=\"a4162485-9114-fcfc-e086-123456789abc\" Version=\"1.1\" Url=\"http://my-component.azurewebsites.net\" ThinkTime=\"0\" Timeout=\"120\" ParseDependentRequests=\"True\" FollowRedirects=\"True\" RecordResult=\"True\" Cache=\"False\" ResponseTimeGoal=\"0\" Encoding=\"utf-8\" ExpectedHttpStatusCode=\"200\" ExpectedResponseUrl=\"\" ReportingName=\"\" IgnoreHttpStatusCode=\"False\" /></Items></WebTest>"
},
"provisioningState": "Succeeded"
}
}
webTestCreateStandard
示例请求
PUT https://management.azure.com/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/webtests/my-webtest-my-component?api-version=2022-06-15
{
"location": "South Central US",
"properties": {
"Name": "my-webtest-my-component",
"SyntheticMonitorId": "my-webtest-my-component",
"Description": "Ping web test alert for mytestwebapp",
"Enabled": true,
"Frequency": 900,
"Timeout": 120,
"Kind": "standard",
"RetryEnabled": true,
"Request": {
"RequestUrl": "https://bing.com",
"Headers": [
{
"key": "Content-Language",
"value": "de-DE"
},
{
"key": "Accept-Language",
"value": "de-DE"
}
],
"HttpVerb": "POST",
"RequestBody": "SGVsbG8gd29ybGQ="
},
"ValidationRules": {
"SSLCheck": true,
"SSLCertRemainingLifetimeCheck": 100
},
"Locations": [
{
"Id": "us-fl-mia-edge"
}
]
}
}
示例响应
{
"id": "/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/webtests/my-webtest-my-component",
"name": "my-webtest-my-component",
"type": "Microsoft.Insights/webtests",
"location": "southcentralus",
"tags": {
"hidden-link:/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/components/my-component": "Resource"
},
"properties": {
"Name": "my-webtest-my-component",
"SyntheticMonitorId": "my-webtest-my-component",
"Description": "Ping web test alert for mytestwebapp",
"Enabled": true,
"Frequency": 900,
"Timeout": 120,
"Kind": "standard",
"RetryEnabled": true,
"Locations": [
{
"Id": "us-fl-mia-edge"
}
],
"Request": {
"RequestUrl": "https://bing.com",
"Headers": [
{
"key": "Content-Language",
"value": "de-DE"
},
{
"key": "Accept-Language",
"value": "de-DE"
}
],
"HttpVerb": "POST",
"RequestBody": "SGVsbG8gd29ybGQ="
},
"ValidationRules": {
"SSLCheck": true,
"SSLCertRemainingLifetimeCheck": 100
},
"provisioningState": "Succeeded"
}
}
webTestUpdate
示例请求
PUT https://management.azure.com/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/webtests/my-webtest-my-component?api-version=2022-06-15
{
"location": "South Central US",
"kind": "ping",
"properties": {
"Configuration": {
"WebTest": "<WebTest Name=\"my-webtest\" Id=\"678ddf96-1ab8-44c8-9274-123456789abc\" Enabled=\"True\" CssProjectStructure=\"\" CssIteration=\"\" Timeout=\"30\" WorkItemIds=\"\" xmlns=\"http://microsoft.com/schemas/VisualStudio/TeamTest/2010\" Description=\"\" CredentialUserName=\"\" CredentialPassword=\"\" PreAuthenticate=\"True\" Proxy=\"default\" StopOnError=\"False\" RecordedResultFile=\"\" ResultsLocale=\"\" ><Items><Request Method=\"GET\" Guid=\"a4162485-9114-fcfc-e086-123456789abc\" Version=\"1.1\" Url=\"http://my-component.azurewebsites.net\" ThinkTime=\"0\" Timeout=\"30\" ParseDependentRequests=\"True\" FollowRedirects=\"True\" RecordResult=\"True\" Cache=\"False\" ResponseTimeGoal=\"0\" Encoding=\"utf-8\" ExpectedHttpStatusCode=\"200\" ExpectedResponseUrl=\"\" ReportingName=\"\" IgnoreHttpStatusCode=\"False\" /></Items></WebTest>"
},
"Frequency": 600,
"Timeout": 30,
"Locations": [
{
"Id": "us-fl-mia-edge"
},
{
"Id": "apac-hk-hkn-azr"
}
],
"Kind": "ping",
"Name": "my-webtest-my-component",
"SyntheticMonitorId": "my-webtest-my-component"
}
}
示例响应
{
"id": "/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/webtests/my-webtest-my-component",
"name": "my-webtest-my-component",
"type": "Microsoft.Insights/webtests",
"location": "southcentralus",
"tags": {
"hidden-link:/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/components/my-component": "Resource"
},
"kind": "ping",
"properties": {
"Name": "my-webtest-my-component",
"SyntheticMonitorId": "my-webtest-my-component",
"Description": "Ping web test alert for mytestwebapp",
"Enabled": true,
"Frequency": 600,
"Timeout": 30,
"Kind": "ping",
"RetryEnabled": true,
"Locations": [
{
"Id": "us-fl-mia-edge"
},
{
"Id": "apac-hk-hkn-azr"
}
],
"Configuration": {
"WebTest": "<WebTest Name=\"my-webtest\" Id=\"678ddf96-1ab8-44c8-9274-123456789abc\" Enabled=\"True\" CssProjectStructure=\"\" CssIteration=\"\" Timeout=\"30\" WorkItemIds=\"\" xmlns=\"http://microsoft.com/schemas/VisualStudio/TeamTest/2010\" Description=\"\" CredentialUserName=\"\" CredentialPassword=\"\" PreAuthenticate=\"True\" Proxy=\"default\" StopOnError=\"False\" RecordedResultFile=\"\" ResultsLocale=\"\" ><Items><Request Method=\"GET\" Guid=\"a4162485-9114-fcfc-e086-123456789abc\" Version=\"1.1\" Url=\"http://my-component.azurewebsites.net\" ThinkTime=\"0\" Timeout=\"30\" ParseDependentRequests=\"True\" FollowRedirects=\"True\" RecordResult=\"True\" Cache=\"False\" ResponseTimeGoal=\"0\" Encoding=\"utf-8\" ExpectedHttpStatusCode=\"200\" ExpectedResponseUrl=\"\" ReportingName=\"\" IgnoreHttpStatusCode=\"False\" /></Items></WebTest>"
},
"provisioningState": "Succeeded"
}
}
定义
名称 | 说明 |
---|---|
Configuration |
WebTest 的 XML 配置规范。 |
Content |
内容验证属性的集合 |
Header |
要添加到 WebTest 的标头。 |
Request |
请求属性的集合 |
Validation |
验证规则属性的集合 |
Web |
Application Insights WebTest 定义。 |
Web |
要从中运行 WebTest 的地理位置。 必须指定要从中运行测试的一个或多个位置。 |
Web |
此 Web 测试监视的 WebTest 类型。 选项为 ping、多步骤和标准。 |
Configuration
WebTest 的 XML 配置规范。
名称 | 类型 | 说明 |
---|---|---|
WebTest |
string |
要针对应用程序运行的 WebTest 的 XML 规范。 |
ContentValidation
内容验证属性的集合
名称 | 类型 | 说明 |
---|---|---|
ContentMatch |
string |
在 WebTest 的返回中查找的内容。 不得为 null 或为空。 |
IgnoreCase |
boolean |
设置后,此值会使 ContentMatch 验证大小写不区分大小写。 |
PassIfTextFound |
boolean |
如果为 true,则如果 ContentMatch 字符串匹配,则验证将传递。 如果为 false,则如果存在匹配项,验证将失败 |
HeaderField
要添加到 WebTest 的标头。
名称 | 类型 | 说明 |
---|---|---|
key |
string |
标头的名称。 |
value |
string |
标头的值。 |
Request
请求属性的集合
名称 | 类型 | 说明 |
---|---|---|
FollowRedirects |
boolean |
按照此 Web 测试的重定向作。 |
Headers |
要添加到 WebTest 调用的标头及其值的列表。 |
|
HttpVerb |
string |
要用于此 Web 测试的 Http 谓词。 |
ParseDependentRequests |
boolean |
分析此 WebTest 的从属请求。 |
RequestBody |
string |
要随此 Web 测试一起发送的 Base64 编码字符串正文。 |
RequestUrl |
string |
要测试的 URL 位置。 |
ValidationRules
验证规则属性的集合
名称 | 类型 | 说明 |
---|---|---|
ContentValidation |
内容验证属性的集合 |
|
ExpectedHttpStatusCode |
integer (int32) |
验证 WebTest 是否返回提供的 http 状态代码。 |
IgnoreHttpStatusCode |
boolean |
设置后,验证将忽略状态代码。 |
SSLCertRemainingLifetimeCheck |
integer (int32) |
在现有 SSL 证书过期之前,仍要检查的天数。 值必须为正值,SSLCheck 必须设置为 true。 |
SSLCheck |
boolean |
检查 SSL 证书是否仍然有效。 |
WebTest
Application Insights WebTest 定义。
名称 | 类型 | 默认值 | 说明 |
---|---|---|---|
id |
string |
Azure 资源 ID |
|
kind | ping |
此 Web 测试监视的 WebTest 类型。 选项为 ping、多步骤和标准。 |
|
location |
string |
资源位置 |
|
name |
string |
Azure 资源名称 |
|
properties.Configuration |
WebTest 的 XML 配置规范。 |
||
properties.Description |
string |
此 WebTest 的用户定义说明。 |
|
properties.Enabled |
boolean |
正在主动监视测试。 |
|
properties.Frequency |
integer (int32) |
300 |
此 WebTest 的测试运行间隔(以秒为单位)。 默认值为 300。 |
properties.Kind | ping |
Web 测试的类型是 ping、多步骤和标准。 |
|
properties.Locations |
一个列表,其中列出了从何处物理运行测试,以便为应用程序的可访问性提供全局覆盖范围。 |
||
properties.Name |
string |
如果用户定义的名称,则为此 WebTest。 |
|
properties.Request |
请求属性的集合 |
||
properties.RetryEnabled |
boolean |
如果此 WebTest 失败,则允许重试。 |
|
properties.SyntheticMonitorId |
string |
此 WebTest 的唯一 ID。 此值通常与“名称”字段相同。 |
|
properties.Timeout |
integer (int32) |
30 |
直到此 WebTest 超时并失败的秒。 默认值为 30。 |
properties.ValidationRules |
验证规则属性的集合 |
||
properties.provisioningState |
string |
此组件的当前状态(无论是否已在已定义资源组中预配)。 用户无法更改此值,但可以从中读取此值。 值将包括 Succeeded、Deploying、Canceled 和 Failed。 |
|
tags |
object |
资源标记 |
|
type |
string |
Azure 资源类型 |
WebTestGeolocation
要从中运行 WebTest 的地理位置。 必须指定要从中运行测试的一个或多个位置。
名称 | 类型 | 说明 |
---|---|---|
Id |
string |
要从中运行的 WebTest 的位置 ID。 |
WebTestKind
此 Web 测试监视的 WebTest 类型。 选项为 ping、多步骤和标准。
值 | 说明 |
---|---|
multistep | |
ping | |
standard |