Note

Access to this page requires authorization. You can try signing in or .

Access to this page requires authorization. You can try .

New-AzApplicationInsightsWebTest

Creates or updates an Application Insights web test definition.

Syntax

CreateStandard (Default)

New-AzApplicationInsightsWebTest
 -Name <String>
 -ResourceGroupName <String>
 -Location <String>
 [-SubscriptionId <String>]
 [-ContentIgnoreCase]
 [-ContentMatch <String>]
 [-ContentPassIfTextFound]
 [-Description <String>]
 [-Enabled]
 [-Frequency <Int32>]
 [-GeoLocation <IWebTestGeolocation[]>]
 [-Kind <String>]
 [-RequestBody <String>]
 [-RequestFollowRedirect]
 [-RequestHeader <IHeaderField[]>]
 [-RequestHttpVerb <String>]
 [-RequestParseDependent]
 [-RequestUrl <String>]
 [-RetryEnabled]
 [-RuleExpectedHttpStatusCode <Int32>]
 [-RuleIgnoreHttpsStatusCode]
 [-RuleSslCertRemainingLifetimeCheck <Int32>]
 [-RuleSslCheck]
 [-Tag <Hashtable>]
 [-TestName <String>]
 [-Timeout <Int32>]
 [-DefaultProfile <PSObject>]
 [-WhatIf]
 [-Confirm]
 [<CommonParameters>]

CreateClassic

New-AzApplicationInsightsWebTest
 -Name <String>
 -ResourceGroupName <String>
 -Location <String>
 [-SubscriptionId <String>]
 [-ContentMatch <String>]
 [-Description <String>]
 [-Enabled]
 [-Frequency <Int32>]
 [-GeoLocation <IWebTestGeolocation[]>]
 [-Kind <String>]
 [-RequestParseDependent]
 [-RequestUrl <String>]
 [-RetryEnabled]
 [-RuleExpectedHttpStatusCode <Int32>]
 [-RuleIgnoreHttpsStatusCode]
 [-RuleSslCertRemainingLifetimeCheck <Int32>]
 [-RuleSslCheck]
 [-Tag <Hashtable>]
 [-TestName <String>]
 [-Timeout <Int32>]
 [-Configuration <String>]
 [-DefaultProfile <PSObject>]
 [-WhatIf]
 [-Confirm]
 [<CommonParameters>]

Description

Creates or updates an Application Insights web test definition.

Examples

Example 1: Creates or updates a standard kind of the Application Insights web test

$geoLocation = @()
$geoLocation += New-AzApplicationInsightsWebTestGeolocationObject -Location "emea-nl-ams-azr"
$geoLocation += New-AzApplicationInsightsWebTestGeolocationObject -Location "us-ca-sjc-azr"
New-AzApplicationInsightsWebTest -ResourceGroupName azpwsh-rg-test -Name standard-pwsh01 -Location 'westus2' `
-Tag @{"hidden-link:/subscriptions/xxxxxxxxxx-xxxx-xxxxx-xxxxxxxxxxxx/resourceGroups/azpwsh-rg-test/providers/microsoft.insights/components/appinsights-portal01" = "Resource"} `
-RequestUrl "https://www.bing.com" -RequestHttpVerb "GET" -TestName 'standard-pwsh01' `
-RuleExpectedHttpStatusCode 200 -Frequency 300 -Enabled -Timeout 120 -Kind 'standard' -RetryEnabled -GeoLocation $geoLocation
Name Location WebTestKind ResourceGroupName Enabled
---- -------- ----------- ----------------- -------
standard-pwsh01 westus2 standard azpwsh-rg-test True

This command creates or updates an standard kind of the Application Insights web test.

We enter hidden-link in the Tag parameter to associate WebTest and Application Insights.

Example 2: Creates or updates a standard kind of the Application Insights web test in disabled state

$geoLocation = @()
$geoLocation += New-AzApplicationInsightsWebTestGeolocationObject -Location "emea-nl-ams-azr"
$geoLocation += New-AzApplicationInsightsWebTestGeolocationObject -Location "us-ca-sjc-azr"
New-AzApplicationInsightsWebTest -ResourceGroupName azpwsh-rg-test -Name standard-pwsh01 -Location 'westus2' `
-Tag @{"hidden-link:/subscriptions/xxxxxxxxxx-xxxx-xxxxx-xxxxxxxxxxxx/resourceGroups/azpwsh-rg-test/providers/microsoft.insights/components/appinsights-portal01" = "Resource"} `
-RequestUrl "https://www.bing.com" -RequestHttpVerb "GET" -TestName 'standard-pwsh01' `
-RuleExpectedHttpStatusCode 200 -Frequency 300 -Enabled:$false -Timeout 120 -Kind 'standard' -RetryEnabled -GeoLocation $geoLocation
Name Location WebTestKind ResourceGroupName Enabled
---- -------- ----------- ----------------- -------
standard-pwsh01 westus2 standard azpwsh-rg-test False

This command creates or updates a standard kind of the Application Insights web test in disabled state.

The switch parameter "-Enabled" must be set explicitly to $false to disable the test.

Example 3: Creates a standard kind of the Application Insights web test with a custom header

$headerField = New-AzApplicationInsightsWebTestHeaderFieldObject -Name "HeaderName1" -Value "HeaderValue1"
New-AzApplicationInsightsWebTest -ResourceGroupName exampleRG -Name expwshelltestheader2 -Location 'westus2' -Tag @{"hidden-link:<RESOURCE URL>" = "Resource"} -RequestUrl "https://www.bing.com" -RequestHttpVerb "GET" -TestName 'expwshelltestheader2' -RuleExpectedHttpStatusCode 200 -Frequency 300 -Enabled -Timeout 120 -Kind 'standard' -RetryEnabled -GeoLocation $geoLocation -RequestHeader $headerField
Name 	Location 	WebTestKind 	ResourceGroupName 	Enabled
---- 	-------- 	----------- 	----------------- 	-------
expwshellheader2 	westus2 	standard 	exampleRG		 True

This command creates a standard kind of the Application Insights web test with a custom header

Example 4: Creates or updates a ping kind of the Application Insights web test

$geoLocation = @()
$geoLocation += New-AzApplicationInsightsWebTestGeolocationObject -Location "emea-nl-ams-azr"
$geoLocation += New-AzApplicationInsightsWebTestGeolocationObject -Location "us-ca-sjc-azr"
New-AzApplicationInsightsWebTest -ResourceGroupName azpwsh-rg-test -Name 'pingwebtest-pwsh01' -TestName 'pingwentest-pwsh01testname' -Location 'westus2' `
-Tag @{"hidden-link:/subscriptions/xxxxxxxxxx-xxxx-xxxxx-xxxxxxxxxxxx/resourceGroups/azpwsh-rg-test/providers/microsoft.insights/components/appinsights-portal01" = "Resource"} `
-GeoLocation $geoLocation -RetryEnabled -Enabled -Frequency 300 -Timeout 90 `
-Kind 'ping' -RequestUrl 'https://cn.bing.com' -RequestParseDependent -RuleExpectedHttpStatusCode 200 `
-ContentMatch "status"
Name Location WebTestKind ResourceGroupName Enabled
---- -------- ----------- ----------------- -------
pingwebtest-pwsh01 westus2 ping azpwsh-rg-test True

This command creates or updates an ping kind of the Application Insights web test.

Example 5: Creates or updates a ping kind of the Application Insights web test with custom configuration

$geoLocation = @()
$geoLocation += New-AzApplicationInsightsWebTestGeolocationObject -Location "emea-nl-ams-azr"
$geoLocation += New-AzApplicationInsightsWebTestGeolocationObject -Location "us-ca-sjc-azr"
New-AzApplicationInsightsWebTest -ResourceGroupName azpwsh-rg-test -Name 'pingwebtest-pwsh01' -TestName 'pingwentest-pwsh01testname' -Location 'westus2' `
-Tag @{"hidden-link:/subscriptions/xxxxxxxxxx-xxxx-xxxxx-xxxxxxxxxxxx/resourceGroups/azpwsh-rg-test/providers/microsoft.insights/components/appinsights-portal01" = "Resource"} `
-GeoLocation $geoLocation -RetryEnabled -Enabled -Frequency 300 -Timeout 90 `
-Kind 'ping' `
-Configuration "<WebTest Name=`"basic-portal03`" Id=`"9407db10-5d84-487f-98a3-a1ee67bb98f0`" Enabled=`"True`" CssProjectStructure=`"`" CssIteration=`"`" Timeout=`"90`" 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=`"a2025e53-0702-d03e-f311-5774ec16893d`" Version=`"1.1`" Url=`"https://www.bing.com`" ThinkTime=`"0`" Timeout=`"90`" ParseDependentRequests=`"True`" FollowRedirects=`"True`" RecordResult=`"True`" Cache=`"False`" ResponseTimeGoal=`"0`" Encoding=`"utf-8`" ExpectedHttpStatusCode=`"200`" ExpectedResponseUrl=`"`" ReportingName=`"`" IgnoreHttpStatusCode=`"False`" />
 </Items>
 <ValidationRules>
 <ValidationRule Classname=`"Microsoft.VisualStudio.TestTools.WebTesting.Rules.ValidationRuleFindText, Microsoft.VisualStudio.QualityTools.WebTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a`" DisplayName=`"Find Text`" Description=`"Verifies the existence of the specified text in the response.`" Level=`"High`" ExectuionOrder=`"BeforeDependents`">
 <RuleParameters>
 <RuleParameter Name=`"FindText`" Value=`"test&#x20;content&#x20;match`" />
 <RuleParameter Name=`"IgnoreCase`" Value=`"False`" />
 <RuleParameter Name=`"UseRegularExpression`" Value=`"False`" />
 <RuleParameter Name=`"PassIfTextFound`" Value=`"True`" />
 </RuleParameters>
 </ValidationRule>
 </ValidationRules>
</WebTest>"
Name Location WebTestKind ResourceGroupName Enabled
---- -------- ----------- ----------------- -------
pingwebtest-pwsh01 westus2 ping azpwsh-rg-test True

This command creates or updates an ping kind of the Application Insights web test with custom configuration.

Parameters

-Configuration

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

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

-Confirm

Prompts you for confirmation before running the cmdlet.

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False
Aliases:cf

Parameter sets

-ContentIgnoreCase

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

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

-ContentMatch

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

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

-ContentPassIfTextFound

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

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

-DefaultProfile

The DefaultProfile parameter is not functional. Use the SubscriptionId parameter when available if executing the cmdlet against a different subscription.

Parameter properties

Type:PSObject
Default value:None
Supports wildcards:False
DontShow:False
Aliases:AzureRMContext, AzureCredential

Parameter sets

-Description

User defined description for this WebTest.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

-Enabled

Is the test actively being monitored.

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

-Frequency

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

Parameter properties

Type:Int32
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

-GeoLocation

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

Parameter properties

Type:

IWebTestGeolocation[]

Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

-Kind

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

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

-Location

Resource location

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

-Name

The name of the Application Insights WebTest resource.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False
Aliases:WebTestName

Parameter sets

-RequestBody

Base64 encoded string body to send with this web test.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

-RequestFollowRedirect

Follow redirects for this web test.

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

-RequestHeader

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

Parameter properties

Type:

IHeaderField[]

Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

-RequestHttpVerb

Http verb to use for this web test.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

-RequestParseDependent

Parse Dependent request for this WebTest.

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

-RequestUrl

Url location to test.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

-ResourceGroupName

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

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

-RetryEnabled

Allow for retries should this WebTest fail.

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

-RuleExpectedHttpStatusCode

Validate that the WebTest returns the http status code provided.

Parameter properties

Type:Int32
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

-RuleIgnoreHttpsStatusCode

When set, validation will ignore the status code.

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

-RuleSslCertRemainingLifetimeCheck

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.

Parameter properties

Type:Int32
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

-RuleSslCheck

Checks to see if the SSL cert is still valid.

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

-SubscriptionId

The ID of the target subscription.

Parameter properties

Type:String
Default value:(Get-AzContext).Subscription.Id
Supports wildcards:False
DontShow:False

Parameter sets

-Tag

Resource tags

Parameter properties

Type:Hashtable
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

-TestName

User defined name if this WebTest.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

-Timeout

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

Parameter properties

Type:Int32
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False
Aliases:wi

Parameter sets

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

Outputs

IWebTest


Feedback

Was this page helpful?