Skip to content

Commit 5d99039

Browse files
Move ApplicationInsights to main (#24510)
1 parent 48c7c1a commit 5d99039

File tree

98 files changed

+1586
-283
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

98 files changed

+1586
-283
lines changed

src/ApplicationInsights/ApplicationInsights.Autorest/examples/New-AzApplicationInsightsWebTest.md

Lines changed: 39 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
### Example 1: Creates or updates an standard kind of the Application Insights web test
1+
### Example 1: Creates or updates a standard kind of the Application Insights web test
22
```powershell
33
$geoLocation = @()
44
$geoLocation += New-AzApplicationInsightsWebTestGeolocationObject -Location "emea-nl-ams-azr"
@@ -8,6 +8,7 @@ New-AzApplicationInsightsWebTest -ResourceGroupName azpwsh-rg-test -Name standar
88
-RequestUrl "https://www.bing.com" -RequestHttpVerb "GET" -TestName 'standard-pwsh01' `
99
-RuleExpectedHttpStatusCode 200 -Frequency 300 -Enabled -Timeout 120 -Kind 'standard' -RetryEnabled -GeoLocation $geoLocation
1010
```
11+
1112
```output
1213
Name Location WebTestKind ResourceGroupName Enabled
1314
---- -------- ----------- ----------------- -------
@@ -18,7 +19,28 @@ This command creates or updates an standard kind of the Application Insights web
1819

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

21-
### Example 2: Creates or updates an ping kind of the Application Insights web test
22+
### Example 2: Creates or updates a standard kind of the Application Insights web test in disabled state
23+
```powershell
24+
$geoLocation = @()
25+
$geoLocation += New-AzApplicationInsightsWebTestGeolocationObject -Location "emea-nl-ams-azr"
26+
$geoLocation += New-AzApplicationInsightsWebTestGeolocationObject -Location "us-ca-sjc-azr"
27+
New-AzApplicationInsightsWebTest -ResourceGroupName azpwsh-rg-test -Name standard-pwsh01 -Location 'westus2' `
28+
-Tag @{"hidden-link:/subscriptions/xxxxxxxxxx-xxxx-xxxxx-xxxxxxxxxxxx/resourceGroups/azpwsh-rg-test/providers/microsoft.insights/components/appinsights-portal01" = "Resource"} `
29+
-RequestUrl "https://www.bing.com" -RequestHttpVerb "GET" -TestName 'standard-pwsh01' `
30+
-RuleExpectedHttpStatusCode 200 -Frequency 300 -Enabled:$false -Timeout 120 -Kind 'standard' -RetryEnabled -GeoLocation $geoLocation
31+
```
32+
33+
```output
34+
Name Location WebTestKind ResourceGroupName Enabled
35+
---- -------- ----------- ----------------- -------
36+
standard-pwsh01 westus2 standard azpwsh-rg-test False
37+
```
38+
39+
This command creates or updates a standard kind of the Application Insights web test in disabled state.
40+
41+
The switch parameter "-Enabled" must be set explicitly to $false to disable the test.
42+
43+
### Example 3: Creates or updates a ping kind of the Application Insights web test
2244
```powershell
2345
$geoLocation = @()
2446
$geoLocation += New-AzApplicationInsightsWebTestGeolocationObject -Location "emea-nl-ams-azr"
@@ -29,6 +51,7 @@ New-AzApplicationInsightsWebTest -ResourceGroupName azpwsh-rg-test -Name 'pingwe
2951
-Kind 'ping' -RequestUrl 'https://cn.bing.com' -RequestParseDependent -RuleExpectedHttpStatusCode 200 `
3052
-ContentMatch "status"
3153
```
54+
3255
```output
3356
Name Location WebTestKind ResourceGroupName Enabled
3457
---- -------- ----------- ----------------- -------
@@ -37,7 +60,7 @@ pingwebtest-pwsh01 westus2 ping azpwsh-rg-test True
3760

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

40-
### Example 3: Creates or updates an ping kind of the Application Insights web test with custom configuration
63+
### Example 4: Creates or updates a ping kind of the Application Insights web test with custom configuration
4164
```powershell
4265
$geoLocation = @()
4366
$geoLocation += New-AzApplicationInsightsWebTestGeolocationObject -Location "emea-nl-ams-azr"
@@ -46,20 +69,20 @@ New-AzApplicationInsightsWebTest -ResourceGroupName azpwsh-rg-test -Name 'pingwe
4669
-Tag @{"hidden-link:/subscriptions/xxxxxxxxxx-xxxx-xxxxx-xxxxxxxxxxxx/resourceGroups/azpwsh-rg-test/providers/microsoft.insights/components/appinsights-portal01" = "Resource"} `
4770
-GeoLocation $geoLocation -RetryEnabled -Enabled -Frequency 300 -Timeout 90 `
4871
-Kind 'ping' `
49-
-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=`"`">
50-
<Items>
51-
<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`" />
52-
</Items>
53-
<ValidationRules>
72+
-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=`"`">
73+
<Items>
74+
<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`" />
75+
</Items>
76+
<ValidationRules>
5477
<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`">
55-
<RuleParameters>
56-
<RuleParameter Name=`"FindText`" Value=`"test&#x20;content&#x20;match`" />
57-
<RuleParameter Name=`"IgnoreCase`" Value=`"False`" />
58-
<RuleParameter Name=`"UseRegularExpression`" Value=`"False`" />
59-
<RuleParameter Name=`"PassIfTextFound`" Value=`"True`" />
60-
</RuleParameters>
61-
</ValidationRule>
62-
</ValidationRules>
78+
<RuleParameters>
79+
<RuleParameter Name=`"FindText`" Value=`"test&#x20;content&#x20;match`" />
80+
<RuleParameter Name=`"IgnoreCase`" Value=`"False`" />
81+
<RuleParameter Name=`"UseRegularExpression`" Value=`"False`" />
82+
<RuleParameter Name=`"PassIfTextFound`" Value=`"True`" />
83+
</RuleParameters>
84+
</ValidationRule>
85+
</ValidationRules>
6386
</WebTest>"
6487
```
6588
```output
@@ -69,4 +92,3 @@ pingwebtest-pwsh01 westus2 ping azpwsh-rg-test True
6992
```
7093

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

src/ApplicationInsights/ApplicationInsights.Autorest/exports/Get-AzApplicationInsights.ps1

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,13 @@ begin {
180180
GetByInputObject = 'Az.ApplicationInsights.custom\Get-AzApplicationInsights';
181181
}
182182
if (('ListBySubscription', 'ListByResourceGroupName', 'Get') -contains $parameterSet -and -not $PSBoundParameters.ContainsKey('SubscriptionId')) {
183-
$PSBoundParameters['SubscriptionId'] = (Get-AzContext).Subscription.Id
183+
$testPlayback = $false
184+
$PSBoundParameters['HttpPipelinePrepend'] | Foreach-Object { $testPlayback = $testPlayback -or ('Microsoft.Azure.PowerShell.Cmdlets.ApplicationInsights.Runtime.PipelineMock' -eq $_.Target.GetType().FullName) }
185+
if ($testPlayback) {
186+
$PSBoundParameters['SubscriptionId'] = . (Join-Path $PSScriptRoot '..' 'utils' 'Get-SubscriptionIdTestSafe.ps1')
187+
} else {
188+
$PSBoundParameters['SubscriptionId'] = (Get-AzContext).Subscription.Id
189+
}
184190
}
185191
$cmdInfo = Get-Command -Name $mapping[$parameterSet]
186192
[Microsoft.Azure.PowerShell.Cmdlets.ApplicationInsights.Runtime.MessageAttributeHelper]::ProcessCustomAttributesAtRuntime($cmdInfo, $MyInvocation, $parameterSet, $PSCmdlet)

src/ApplicationInsights/ApplicationInsights.Autorest/exports/Get-AzApplicationInsightsApiKey.ps1

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,13 @@ begin {
171171
List = 'Az.ApplicationInsights.private\Get-AzApplicationInsightsApiKey_List';
172172
}
173173
if (('Get', 'List') -contains $parameterSet -and -not $PSBoundParameters.ContainsKey('SubscriptionId')) {
174-
$PSBoundParameters['SubscriptionId'] = (Get-AzContext).Subscription.Id
174+
$testPlayback = $false
175+
$PSBoundParameters['HttpPipelinePrepend'] | Foreach-Object { $testPlayback = $testPlayback -or ('Microsoft.Azure.PowerShell.Cmdlets.ApplicationInsights.Runtime.PipelineMock' -eq $_.Target.GetType().FullName) }
176+
if ($testPlayback) {
177+
$PSBoundParameters['SubscriptionId'] = . (Join-Path $PSScriptRoot '..' 'utils' 'Get-SubscriptionIdTestSafe.ps1')
178+
} else {
179+
$PSBoundParameters['SubscriptionId'] = (Get-AzContext).Subscription.Id
180+
}
175181
}
176182
$cmdInfo = Get-Command -Name $mapping[$parameterSet]
177183
[Microsoft.Azure.PowerShell.Cmdlets.ApplicationInsights.Runtime.MessageAttributeHelper]::ProcessCustomAttributesAtRuntime($cmdInfo, $MyInvocation, $parameterSet, $PSCmdlet)

src/ApplicationInsights/ApplicationInsights.Autorest/exports/Get-AzApplicationInsightsContinuousExport.ps1

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,13 @@ begin {
171171
List = 'Az.ApplicationInsights.private\Get-AzApplicationInsightsContinuousExport_List';
172172
}
173173
if (('Get', 'List') -contains $parameterSet -and -not $PSBoundParameters.ContainsKey('SubscriptionId')) {
174-
$PSBoundParameters['SubscriptionId'] = (Get-AzContext).Subscription.Id
174+
$testPlayback = $false
175+
$PSBoundParameters['HttpPipelinePrepend'] | Foreach-Object { $testPlayback = $testPlayback -or ('Microsoft.Azure.PowerShell.Cmdlets.ApplicationInsights.Runtime.PipelineMock' -eq $_.Target.GetType().FullName) }
176+
if ($testPlayback) {
177+
$PSBoundParameters['SubscriptionId'] = . (Join-Path $PSScriptRoot '..' 'utils' 'Get-SubscriptionIdTestSafe.ps1')
178+
} else {
179+
$PSBoundParameters['SubscriptionId'] = (Get-AzContext).Subscription.Id
180+
}
175181
}
176182
$cmdInfo = Get-Command -Name $mapping[$parameterSet]
177183
[Microsoft.Azure.PowerShell.Cmdlets.ApplicationInsights.Runtime.MessageAttributeHelper]::ProcessCustomAttributesAtRuntime($cmdInfo, $MyInvocation, $parameterSet, $PSCmdlet)

src/ApplicationInsights/ApplicationInsights.Autorest/exports/Get-AzApplicationInsightsLinkedStorageAccount.ps1

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,13 @@ begin {
158158
GetViaIdentity = 'Az.ApplicationInsights.private\Get-AzApplicationInsightsLinkedStorageAccount_GetViaIdentity';
159159
}
160160
if (('Get') -contains $parameterSet -and -not $PSBoundParameters.ContainsKey('SubscriptionId')) {
161-
$PSBoundParameters['SubscriptionId'] = (Get-AzContext).Subscription.Id
161+
$testPlayback = $false
162+
$PSBoundParameters['HttpPipelinePrepend'] | Foreach-Object { $testPlayback = $testPlayback -or ('Microsoft.Azure.PowerShell.Cmdlets.ApplicationInsights.Runtime.PipelineMock' -eq $_.Target.GetType().FullName) }
163+
if ($testPlayback) {
164+
$PSBoundParameters['SubscriptionId'] = . (Join-Path $PSScriptRoot '..' 'utils' 'Get-SubscriptionIdTestSafe.ps1')
165+
} else {
166+
$PSBoundParameters['SubscriptionId'] = (Get-AzContext).Subscription.Id
167+
}
162168
}
163169
$cmdInfo = Get-Command -Name $mapping[$parameterSet]
164170
[Microsoft.Azure.PowerShell.Cmdlets.ApplicationInsights.Runtime.MessageAttributeHelper]::ProcessCustomAttributesAtRuntime($cmdInfo, $MyInvocation, $parameterSet, $PSCmdlet)

src/ApplicationInsights/ApplicationInsights.Autorest/exports/Get-AzApplicationInsightsMyWorkbook.ps1

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,13 @@ begin {
166166
List1 = 'Az.ApplicationInsights.private\Get-AzApplicationInsightsMyWorkbook_List1';
167167
}
168168
if (('Get', 'List', 'List1') -contains $parameterSet -and -not $PSBoundParameters.ContainsKey('SubscriptionId')) {
169-
$PSBoundParameters['SubscriptionId'] = (Get-AzContext).Subscription.Id
169+
$testPlayback = $false
170+
$PSBoundParameters['HttpPipelinePrepend'] | Foreach-Object { $testPlayback = $testPlayback -or ('Microsoft.Azure.PowerShell.Cmdlets.ApplicationInsights.Runtime.PipelineMock' -eq $_.Target.GetType().FullName) }
171+
if ($testPlayback) {
172+
$PSBoundParameters['SubscriptionId'] = . (Join-Path $PSScriptRoot '..' 'utils' 'Get-SubscriptionIdTestSafe.ps1')
173+
} else {
174+
$PSBoundParameters['SubscriptionId'] = (Get-AzContext).Subscription.Id
175+
}
170176
}
171177
$cmdInfo = Get-Command -Name $mapping[$parameterSet]
172178
[Microsoft.Azure.PowerShell.Cmdlets.ApplicationInsights.Runtime.MessageAttributeHelper]::ProcessCustomAttributesAtRuntime($cmdInfo, $MyInvocation, $parameterSet, $PSCmdlet)

src/ApplicationInsights/ApplicationInsights.Autorest/exports/Get-AzApplicationInsightsWebTest.ps1

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,13 @@ begin {
187187
List2 = 'Az.ApplicationInsights.private\Get-AzApplicationInsightsWebTest_List2';
188188
}
189189
if (('Get', 'List', 'List1', 'List2') -contains $parameterSet -and -not $PSBoundParameters.ContainsKey('SubscriptionId')) {
190-
$PSBoundParameters['SubscriptionId'] = (Get-AzContext).Subscription.Id
190+
$testPlayback = $false
191+
$PSBoundParameters['HttpPipelinePrepend'] | Foreach-Object { $testPlayback = $testPlayback -or ('Microsoft.Azure.PowerShell.Cmdlets.ApplicationInsights.Runtime.PipelineMock' -eq $_.Target.GetType().FullName) }
192+
if ($testPlayback) {
193+
$PSBoundParameters['SubscriptionId'] = . (Join-Path $PSScriptRoot '..' 'utils' 'Get-SubscriptionIdTestSafe.ps1')
194+
} else {
195+
$PSBoundParameters['SubscriptionId'] = (Get-AzContext).Subscription.Id
196+
}
191197
}
192198
$cmdInfo = Get-Command -Name $mapping[$parameterSet]
193199
[Microsoft.Azure.PowerShell.Cmdlets.ApplicationInsights.Runtime.MessageAttributeHelper]::ProcessCustomAttributesAtRuntime($cmdInfo, $MyInvocation, $parameterSet, $PSCmdlet)

src/ApplicationInsights/ApplicationInsights.Autorest/exports/Get-AzApplicationInsightsWorkbook.ps1

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,13 @@ begin {
198198
List1 = 'Az.ApplicationInsights.private\Get-AzApplicationInsightsWorkbook_List1';
199199
}
200200
if (('Get', 'List', 'List1') -contains $parameterSet -and -not $PSBoundParameters.ContainsKey('SubscriptionId')) {
201-
$PSBoundParameters['SubscriptionId'] = (Get-AzContext).Subscription.Id
201+
$testPlayback = $false
202+
$PSBoundParameters['HttpPipelinePrepend'] | Foreach-Object { $testPlayback = $testPlayback -or ('Microsoft.Azure.PowerShell.Cmdlets.ApplicationInsights.Runtime.PipelineMock' -eq $_.Target.GetType().FullName) }
203+
if ($testPlayback) {
204+
$PSBoundParameters['SubscriptionId'] = . (Join-Path $PSScriptRoot '..' 'utils' 'Get-SubscriptionIdTestSafe.ps1')
205+
} else {
206+
$PSBoundParameters['SubscriptionId'] = (Get-AzContext).Subscription.Id
207+
}
202208
}
203209
$cmdInfo = Get-Command -Name $mapping[$parameterSet]
204210
[Microsoft.Azure.PowerShell.Cmdlets.ApplicationInsights.Runtime.MessageAttributeHelper]::ProcessCustomAttributesAtRuntime($cmdInfo, $MyInvocation, $parameterSet, $PSCmdlet)

src/ApplicationInsights/ApplicationInsights.Autorest/exports/Get-AzApplicationInsightsWorkbookRevision.ps1

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,13 @@ begin {
171171
List = 'Az.ApplicationInsights.private\Get-AzApplicationInsightsWorkbookRevision_List';
172172
}
173173
if (('Get', 'List') -contains $parameterSet -and -not $PSBoundParameters.ContainsKey('SubscriptionId')) {
174-
$PSBoundParameters['SubscriptionId'] = (Get-AzContext).Subscription.Id
174+
$testPlayback = $false
175+
$PSBoundParameters['HttpPipelinePrepend'] | Foreach-Object { $testPlayback = $testPlayback -or ('Microsoft.Azure.PowerShell.Cmdlets.ApplicationInsights.Runtime.PipelineMock' -eq $_.Target.GetType().FullName) }
176+
if ($testPlayback) {
177+
$PSBoundParameters['SubscriptionId'] = . (Join-Path $PSScriptRoot '..' 'utils' 'Get-SubscriptionIdTestSafe.ps1')
178+
} else {
179+
$PSBoundParameters['SubscriptionId'] = (Get-AzContext).Subscription.Id
180+
}
175181
}
176182
$cmdInfo = Get-Command -Name $mapping[$parameterSet]
177183
[Microsoft.Azure.PowerShell.Cmdlets.ApplicationInsights.Runtime.MessageAttributeHelper]::ProcessCustomAttributesAtRuntime($cmdInfo, $MyInvocation, $parameterSet, $PSCmdlet)

src/ApplicationInsights/ApplicationInsights.Autorest/exports/Get-AzApplicationInsightsWorkbookTemplate.ps1

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,13 @@ begin {
188188
GetViaIdentity = 'Az.ApplicationInsights.private\Get-AzApplicationInsightsWorkbookTemplate_GetViaIdentity';
189189
}
190190
if (('Get') -contains $parameterSet -and -not $PSBoundParameters.ContainsKey('SubscriptionId')) {
191-
$PSBoundParameters['SubscriptionId'] = (Get-AzContext).Subscription.Id
191+
$testPlayback = $false
192+
$PSBoundParameters['HttpPipelinePrepend'] | Foreach-Object { $testPlayback = $testPlayback -or ('Microsoft.Azure.PowerShell.Cmdlets.ApplicationInsights.Runtime.PipelineMock' -eq $_.Target.GetType().FullName) }
193+
if ($testPlayback) {
194+
$PSBoundParameters['SubscriptionId'] = . (Join-Path $PSScriptRoot '..' 'utils' 'Get-SubscriptionIdTestSafe.ps1')
195+
} else {
196+
$PSBoundParameters['SubscriptionId'] = (Get-AzContext).Subscription.Id
197+
}
192198
}
193199
$cmdInfo = Get-Command -Name $mapping[$parameterSet]
194200
[Microsoft.Azure.PowerShell.Cmdlets.ApplicationInsights.Runtime.MessageAttributeHelper]::ProcessCustomAttributesAtRuntime($cmdInfo, $MyInvocation, $parameterSet, $PSCmdlet)

src/ApplicationInsights/ApplicationInsights.Autorest/exports/New-AzApplicationInsights.ps1

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,13 @@ begin {
253253
__AllParameterSets = 'Az.ApplicationInsights.custom\New-AzApplicationInsights';
254254
}
255255
if (('__AllParameterSets') -contains $parameterSet -and -not $PSBoundParameters.ContainsKey('SubscriptionId')) {
256-
$PSBoundParameters['SubscriptionId'] = (Get-AzContext).Subscription.Id
256+
$testPlayback = $false
257+
$PSBoundParameters['HttpPipelinePrepend'] | Foreach-Object { $testPlayback = $testPlayback -or ('Microsoft.Azure.PowerShell.Cmdlets.ApplicationInsights.Runtime.PipelineMock' -eq $_.Target.GetType().FullName) }
258+
if ($testPlayback) {
259+
$PSBoundParameters['SubscriptionId'] = . (Join-Path $PSScriptRoot '..' 'utils' 'Get-SubscriptionIdTestSafe.ps1')
260+
} else {
261+
$PSBoundParameters['SubscriptionId'] = (Get-AzContext).Subscription.Id
262+
}
257263
}
258264
$cmdInfo = Get-Command -Name $mapping[$parameterSet]
259265
[Microsoft.Azure.PowerShell.Cmdlets.ApplicationInsights.Runtime.MessageAttributeHelper]::ProcessCustomAttributesAtRuntime($cmdInfo, $MyInvocation, $parameterSet, $PSCmdlet)

src/ApplicationInsights/ApplicationInsights.Autorest/exports/New-AzApplicationInsightsApiKey.ps1

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,13 @@ begin {
145145
ComponentNameParameterSet = 'Az.ApplicationInsights.custom\New-AzApplicationInsightsApiKey';
146146
}
147147
if (('ComponentNameParameterSet') -contains $parameterSet -and -not $PSBoundParameters.ContainsKey('SubscriptionId')) {
148-
$PSBoundParameters['SubscriptionId'] = (Get-AzContext).Subscription.Id
148+
$testPlayback = $false
149+
$PSBoundParameters['HttpPipelinePrepend'] | Foreach-Object { $testPlayback = $testPlayback -or ('Microsoft.Azure.PowerShell.Cmdlets.ApplicationInsights.Runtime.PipelineMock' -eq $_.Target.GetType().FullName) }
150+
if ($testPlayback) {
151+
$PSBoundParameters['SubscriptionId'] = . (Join-Path $PSScriptRoot '..' 'utils' 'Get-SubscriptionIdTestSafe.ps1')
152+
} else {
153+
$PSBoundParameters['SubscriptionId'] = (Get-AzContext).Subscription.Id
154+
}
149155
}
150156
$cmdInfo = Get-Command -Name $mapping[$parameterSet]
151157
[Microsoft.Azure.PowerShell.Cmdlets.ApplicationInsights.Runtime.MessageAttributeHelper]::ProcessCustomAttributesAtRuntime($cmdInfo, $MyInvocation, $parameterSet, $PSCmdlet)

0 commit comments

Comments
 (0)