我需要写一个变量值ExpectedHttpStatusCode。
我得出了这个结论,但是我不知道下一步该怎么做?
$new = Get-AzResource -ResourceId /subscriptions/<subscriptions>/resourceGroups/us-test-vitalii/providers/microsoft.insights/webtests/us-test-vitalii-ui
$new.Properties.Configuration.WebTest
<WebTest Name="us-test-vitalii-ui" Id="" Enabled="True"
CssProjectStructure="" CssIteration="" Timeout="120" WorkItemIds="" xmlns="http://mi
crosoft.com/schemas/VisualStudio/TeamTest/2010" Description="" CredentialUserName="" CredentialPasswo
rd="" PreAuthenticate="True" Proxy="default" StopOnError="False" RecordedResultFile=""
ResultsLocale=""> <Items> <Request Method="GET" Guid=""
Version="1.1" Url="" ThinkTime="0" Timeo
ut="120" ParseDependentRequests="True" FollowRedirects="True" RecordResult="True" Cache="Fals
e" ResponseTimeGoal="0" Encoding="utf-8" ExpectedHttpStatusCode="350" ExpectedResponseUrl=""
ReportingName="" IgnoreHttpStatusCode="False" /> </Items> <ValidationRules> <ValidationR
ule Classname="Microsoft.VisualStudio.TestTools.WebTesting.Rules.ValidationRuleFindText, Microsoft.VisualStudio.Quali
tyTools.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" ExectuionOr
der="BeforeDependents"> <RuleParameters> <RuleParameter Name="FindText" Value="us-test-vitalii-ui" />
<RuleParameter Name="IgnoreCase" Value="False" /> <RuleParameter Name="UseRegularExpression" Value="False" />
<RuleParameter Name="PassIfTextFound" Value="True" /> </RuleParameters> </ValidationRule> </Valid
ationRules> </WebTest>
答案 0 :(得分:0)
如评论中所述,XML似乎已损坏。如果要写入ExpectedHttpStatusCode
,可以考虑使用REST API Web Tests - Create Or Update,更新properties.Configuration
。要在PowerShell中调用API,可以使用Invoke-RestMethod
。有关带有powershell的Call Rest API的更多详细信息,您可以看到类似的link。
对于api的访问令牌,您可以单击Try it
按钮,如下所示登录并复制Authorization
。或者,如果您要手动生成,请参见此link。