Web Tests - Create Or Update

Creates or updates an Application Insights web test definition.

PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/webtests/{webTestName}?api-version=2022-06-15

URI Parameters

Name In Required Type Description
resourceGroupName
path True

string

The name of the resource group. The name is case insensitive.

subscriptionId
path True

string

The ID of the target subscription.

webTestName
path True

string

The name of the Application Insights WebTest resource.

api-version
query True

string

The API version to use for this operation.

Request Body

Name Required Type Description
location True

string

Resource location

properties.Kind True

WebTestKind

The kind of web test this is, valid choices are ping, multistep and standard.

properties.Locations True

WebTestGeolocation[]

A list of where to physically run the tests from to give global coverage for accessibility of your application.

properties.Name True

string

User defined name if this WebTest.

properties.SyntheticMonitorId True

string

Unique ID of this WebTest. This is typically the same value as the Name field.

kind

WebTestKind

The kind of WebTest that this web test watches. Choices are ping, multistep and standard.

properties.Configuration

Configuration

An XML configuration specification for a WebTest.

properties.Description

string

User defined description for this WebTest.

properties.Enabled

boolean

Is the test actively being monitored.

properties.Frequency

integer

Interval in seconds between test runs for this WebTest. Default value is 300.

properties.Request

Request

The collection of request properties

properties.RetryEnabled

boolean

Allow for retries should this WebTest fail.

properties.Timeout

integer

Seconds until this WebTest will timeout and fail. Default value is 30.

properties.ValidationRules

ValidationRules

The collection of validation rule properties

tags

object

Resource tags

Responses

Name Type Description
200 OK

WebTest

Successfully created or updated an Application Insights web test.

Security

azure_auth

Azure Active Directory OAuth2 Flow.

Type: oauth2
Flow: implicit
Authorization URL: https://login.microsoftonline.com/common/oauth2/authorize

Scopes

Name Description
user_impersonation impersonate your user account

Examples

webTestCreate
webTestCreateStandard
webTestUpdate

webTestCreate

Sample request

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"
      }
    ]
  }
}

Sample response

{
  "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

Sample request

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"
      }
    ]
  }
}

Sample response

{
  "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

Sample request

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"
  }
}

Sample response

{
  "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"
  }
}

Definitions

Name Description
Configuration

An XML configuration specification for a WebTest.

ContentValidation

The collection of content validation properties

HeaderField

A header to add to the WebTest.

Request

The collection of request properties

ValidationRules

The collection of validation rule properties

WebTest

An Application Insights WebTest definition.

WebTestGeolocation

Geo-physical location to run a WebTest from. You must specify one or more locations for the test to run from.

WebTestKind

The kind of WebTest that this web test watches. Choices are ping, multistep and standard.

Configuration

An XML configuration specification for a WebTest.

Name Type Description
WebTest

string

The XML specification of a WebTest to run against an application.

ContentValidation

The collection of content validation properties

Name Type Description
ContentMatch

string

Content to look for in the return of the WebTest. Must not be null or empty.

IgnoreCase

boolean

When set, this value makes the ContentMatch validation case insensitive.

PassIfTextFound

boolean

When true, validation will pass if there is a match for the ContentMatch string. If false, validation will fail if there is a match

HeaderField

A header to add to the WebTest.

Name Type Description
key

string

The name of the header.

value

string

The value of the header.

Request

The collection of request properties

Name Type Description
FollowRedirects

boolean

Follow redirects for this web test.

Headers

HeaderField[]

List of headers and their values to add to the WebTest call.

HttpVerb

string

Http verb to use for this web test.

ParseDependentRequests

boolean

Parse Dependent request for this WebTest.

RequestBody

string

Base64 encoded string body to send with this web test.

RequestUrl

string

Url location to test.

ValidationRules

The collection of validation rule properties

Name Type Description
ContentValidation

ContentValidation

The collection of content validation properties

ExpectedHttpStatusCode

integer

Validate that the WebTest returns the http status code provided.

IgnoreHttpStatusCode

boolean

When set, validation will ignore the status code.

SSLCertRemainingLifetimeCheck

integer

A number of days to check still remain before the the existing SSL cert expires. Value must be positive and the SSLCheck must be set to true.

SSLCheck

boolean

Checks to see if the SSL cert is still valid.

WebTest

An Application Insights WebTest definition.

Name Type Default value Description
id

string

Azure resource Id

kind

WebTestKind

ping

The kind of WebTest that this web test watches. Choices are ping, multistep and standard.

location

string

Resource location

name

string

Azure resource name

properties.Configuration

Configuration

An XML configuration specification for a WebTest.

properties.Description

string

User defined description for this WebTest.

properties.Enabled

boolean

Is the test actively being monitored.

properties.Frequency

integer

300

Interval in seconds between test runs for this WebTest. Default value is 300.

properties.Kind

WebTestKind

ping

The kind of web test this is, valid choices are ping, multistep and standard.

properties.Locations

WebTestGeolocation[]

A list of where to physically run the tests from to give global coverage for accessibility of your application.

properties.Name

string

User defined name if this WebTest.

properties.Request

Request

The collection of request properties

properties.RetryEnabled

boolean

Allow for retries should this WebTest fail.

properties.SyntheticMonitorId

string

Unique ID of this WebTest. This is typically the same value as the Name field.

properties.Timeout

integer

30

Seconds until this WebTest will timeout and fail. Default value is 30.

properties.ValidationRules

ValidationRules

The collection of validation rule properties

properties.provisioningState

string

Current state of this component, whether or not is has been provisioned within the resource group it is defined. Users cannot change this value but are able to read from it. Values will include Succeeded, Deploying, Canceled, and Failed.

tags

object

Resource tags

type

string

Azure resource type

WebTestGeolocation

Geo-physical location to run a WebTest from. You must specify one or more locations for the test to run from.

Name Type Description
Id

string

Location ID for the WebTest to run from.

WebTestKind

The kind of WebTest that this web test watches. Choices are ping, multistep and standard.

Name Type Description
multistep

string

ping

string

standard

string