New-AzApplicationInsightsWebTest
建立或更新 Application Insights Web 測試定義。
語法
New-AzApplicationInsightsWebTest
-Name <String>
-ResourceGroupName <String>
[-SubscriptionId <String>]
-Location <String>
[-ContentIgnoreCase]
[-ContentMatch <String>]
[-ContentPassIfTextFound]
[-Description <String>]
[-Enabled]
[-Frequency <Int32>]
[-GeoLocation <IWebTestGeolocation[]>]
[-Kind <WebTestKindEnum>]
[-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>]
New-AzApplicationInsightsWebTest
-Name <String>
-ResourceGroupName <String>
[-SubscriptionId <String>]
-Location <String>
[-ContentMatch <String>]
[-Description <String>]
[-Enabled]
[-Frequency <Int32>]
[-GeoLocation <IWebTestGeolocation[]>]
[-Kind <WebTestKindEnum>]
[-RequestParseDependent]
[-RequestUrl <String>]
[-RetryEnabled]
[-RuleExpectedHttpStatusCode <Int32>]
[-Tag <Hashtable>]
[-TestName <String>]
[-Timeout <Int32>]
[-Configuration <String>]
[-DefaultProfile <PSObject>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Description
建立或更新 Application Insights Web 測試定義。
範例
範例 1:建立或更新 Application Insights Web 測試的標準種類
$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
此命令會建立或更新 Application Insights Web 測試的標準種類。
我們會在 Tag
參數中輸入 hidden-link,以建立 WebTest 和 Application Insights 的關聯。
範例 2:以停用狀態建立或更新 Application Insights Web 測試的標準種類
$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
此命令會建立或更新處於停用狀態的標準 Application Insights Web 測試種類。
參數 「-Enabled」 必須明確設定為$false停用測試。
範例 3:使用自定義標頭建立 Application Insights Web 測試的標準種類
$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
此命令會使用自定義標頭建立Application Insights Web測試的標準種類
範例 4:建立或更新 Application Insights Web 測試的 Ping 類型
$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
此命令會建立或更新 Application Insights Web 測試的 Ping 種類。
範例 5:使用自定義設定建立或更新 Application Insights Web 測試的 Ping 類型
$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 content 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
此命令會使用自定義組態建立或更新 Application Insights Web 測試的 Ping 類型。
參數
-Configuration
要針對應用程式執行的 WebTest XML 規格。
類型: | String |
Position: | Named |
預設值: | None |
必要: | False |
接受管線輸入: | False |
接受萬用字元: | False |
-Confirm
在執行 Cmdlet 之前,提示您進行確認。
類型: | SwitchParameter |
別名: | cf |
Position: | Named |
預設值: | None |
必要: | False |
接受管線輸入: | False |
接受萬用字元: | False |
-ContentIgnoreCase
設定時,此值會使 ContentMatch 驗證案例不區分。
類型: | SwitchParameter |
Position: | Named |
預設值: | None |
必要: | False |
接受管線輸入: | False |
接受萬用字元: | False |
-ContentMatch
在 WebTest 傳回中要尋找的內容。 不得為 Null 或空白。
類型: | String |
Position: | Named |
預設值: | None |
必要: | False |
接受管線輸入: | False |
接受萬用字元: | False |
-ContentPassIfTextFound
若為 true,如果 ContentMatch 字串相符,驗證將會通過。 如果為 false,如果相符項目,驗證將會失敗
類型: | SwitchParameter |
Position: | Named |
預設值: | None |
必要: | False |
接受管線輸入: | False |
接受萬用字元: | False |
-DefaultProfile
用於與 Azure 通訊的認證、帳戶、租用戶和訂用帳戶。
類型: | PSObject |
別名: | AzureRMContext, AzureCredential |
Position: | Named |
預設值: | None |
必要: | False |
接受管線輸入: | False |
接受萬用字元: | False |
-Description
此 WebTest 的使用者定義描述。
類型: | String |
Position: | Named |
預設值: | None |
必要: | False |
接受管線輸入: | False |
接受萬用字元: | False |
-Enabled
是否正在主動監視測試。
類型: | SwitchParameter |
Position: | Named |
預設值: | None |
必要: | False |
接受管線輸入: | False |
接受萬用字元: | False |
-Frequency
此 WebTest 的測試回合之間以秒為單位的間隔。 預設值為 300。
類型: | Int32 |
Position: | Named |
預設值: | None |
必要: | False |
接受管線輸入: | False |
接受萬用字元: | False |
-GeoLocation
實際執行測試的來源清單,以提供應用程式輔助功能的全域涵蓋範圍。 若要建構,請參閱 GEOLOCATION 屬性的 NOTES 一節,並建立哈希表。
類型: | IWebTestGeolocation[] |
Position: | Named |
預設值: | None |
必要: | False |
接受管線輸入: | False |
接受萬用字元: | False |
-Kind
這是 Web 測試的類型,有效的選擇是 ping、multistep 和 standard。
類型: | WebTestKindEnum |
Position: | Named |
預設值: | None |
必要: | False |
接受管線輸入: | False |
接受萬用字元: | False |
-Location
資源位置
類型: | String |
Position: | Named |
預設值: | None |
必要: | True |
接受管線輸入: | False |
接受萬用字元: | False |
-Name
Application Insights WebTest 資源的名稱。
類型: | String |
別名: | WebTestName |
Position: | Named |
預設值: | None |
必要: | True |
接受管線輸入: | False |
接受萬用字元: | False |
-RequestBody
使用此 Web 測試傳送的 Base64 編碼字串主體。
類型: | String |
Position: | Named |
預設值: | None |
必要: | False |
接受管線輸入: | False |
接受萬用字元: | False |
-RequestFollowRedirect
請遵循此 Web 測試的重新導向。
類型: | SwitchParameter |
Position: | Named |
預設值: | None |
必要: | False |
接受管線輸入: | False |
接受萬用字元: | False |
-RequestHeader
要新增至 WebTest 呼叫的標頭及其值清單。 若要建構,請參閱 REQUESTHEADER 屬性的 NOTES 區段並建立哈希表。
類型: | IHeaderField[] |
Position: | Named |
預設值: | None |
必要: | False |
接受管線輸入: | False |
接受萬用字元: | False |
-RequestHttpVerb
要用於此 Web 測試的 Http 動詞。
類型: | String |
Position: | Named |
預設值: | None |
必要: | False |
接受管線輸入: | False |
接受萬用字元: | False |
-RequestParseDependent
剖析此 WebTest 的相依要求。
類型: | SwitchParameter |
Position: | Named |
預設值: | None |
必要: | False |
接受管線輸入: | False |
接受萬用字元: | False |
-RequestUrl
要測試的URL位置。
類型: | String |
Position: | Named |
預設值: | None |
必要: | False |
接受管線輸入: | False |
接受萬用字元: | False |
-ResourceGroupName
資源群組的名稱。 名稱不區分大小寫。
類型: | String |
Position: | Named |
預設值: | None |
必要: | True |
接受管線輸入: | False |
接受萬用字元: | False |
-RetryEnabled
如果此 WebTest 失敗,請允許重試。
類型: | SwitchParameter |
Position: | Named |
預設值: | None |
必要: | False |
接受管線輸入: | False |
接受萬用字元: | False |
-RuleExpectedHttpStatusCode
驗證 WebTest 是否傳回提供的 HTTP 狀態代碼。
類型: | Int32 |
Position: | Named |
預設值: | None |
必要: | False |
接受管線輸入: | False |
接受萬用字元: | False |
-RuleIgnoreHttpsStatusCode
設定時,驗證會忽略狀態代碼。
類型: | SwitchParameter |
Position: | Named |
預設值: | None |
必要: | False |
接受管線輸入: | False |
接受萬用字元: | False |
-RuleSslCertRemainingLifetimeCheck
在現有 SSL 憑證到期之前,仍要檢查的天數。 值必須是正數,且 SSLCheck 必須設定為 true。
類型: | Int32 |
Position: | Named |
預設值: | None |
必要: | False |
接受管線輸入: | False |
接受萬用字元: | False |
-RuleSslCheck
檢查 SSL 憑證是否仍然有效。
類型: | SwitchParameter |
Position: | Named |
預設值: | None |
必要: | False |
接受管線輸入: | False |
接受萬用字元: | False |
-SubscriptionId
目標訂用帳戶的標識碼。
類型: | String |
Position: | Named |
預設值: | (Get-AzContext).Subscription.Id |
必要: | False |
接受管線輸入: | False |
接受萬用字元: | False |
-Tag
資源標籤
類型: | Hashtable |
Position: | Named |
預設值: | None |
必要: | False |
接受管線輸入: | False |
接受萬用字元: | False |
-TestName
如果這個 WebTest,則為使用者定義的名稱。
類型: | String |
Position: | Named |
預設值: | None |
必要: | False |
接受管線輸入: | False |
接受萬用字元: | False |
-Timeout
此 WebTest 逾時並失敗的秒數。 預設值為 30。
類型: | Int32 |
Position: | Named |
預設值: | None |
必要: | False |
接受管線輸入: | False |
接受萬用字元: | False |
-WhatIf
顯示 Cmdlet 執行時會發生什麼事。 Cmdlet 未執行。
類型: | SwitchParameter |
別名: | wi |
Position: | Named |
預設值: | None |
必要: | False |
接受管線輸入: | False |
接受萬用字元: | False |