Skip to content

Commit e3757db

Browse files
authored
[Application insight] Fix update component (#24405)
* fix application insight update cmdlet * revert group logic in Application insights test utils
1 parent a9bd00b commit e3757db

File tree

5 files changed

+338
-56
lines changed

5 files changed

+338
-56
lines changed

src/ApplicationInsights/ApplicationInsights.Autorest/custom/Update-AzApplicationInsights.ps1

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,38 @@ function Update-AzApplicationInsights {
206206
)
207207

208208
process {
209+
# add PS bound parameters to run test
210+
$EnvPSBoundParameters = @{}
211+
if ($PSBoundParameters.ContainsKey('Debug')) {
212+
$EnvPSBoundParameters['Debug'] = $Debug
213+
}
214+
if ($PSBoundParameters.ContainsKey('HttpPipelineAppend')) {
215+
$EnvPSBoundParameters['HttpPipelineAppend'] = $HttpPipelineAppend
216+
}
217+
if ($PSBoundParameters.ContainsKey('HttpPipelinePrepend')) {
218+
$EnvPSBoundParameters['HttpPipelinePrepend'] = $HttpPipelinePrepend
219+
}
220+
if ($PSBoundParameters.ContainsKey('Proxy')) {
221+
$EnvPSBoundParameters['Proxy'] = $Proxy
222+
}
223+
if ($PSBoundParameters.ContainsKey('ProxyCredential')) {
224+
$EnvPSBoundParameters['ProxyCredential'] = $ProxyCredential
225+
}
226+
if ($PSBoundParameters.ContainsKey('ProxyUseDefaultCredentials')) {
227+
$EnvPSBoundParameters['ProxyUseDefaultCredentials'] = $ProxyUseDefaultCredentials
228+
}
229+
if ($PSBoundParameters.ContainsKey('SubscriptionId')) {
230+
$EnvPSBoundParameters['SubscriptionId'] = $SubscriptionId
231+
}
232+
if ($PSBoundParameters.ContainsKey('ResourceGroupName')) {
233+
$EnvPSBoundParameters['ResourceGroupName'] = $ResourceGroupName
234+
}
235+
if ($PSBoundParameters.ContainsKey('Name')) {
236+
$EnvPSBoundParameters['Name'] = $Name
237+
}
238+
209239
try {
210-
$component = . Get-AzApplicationInsights -SubscriptionId $PSBoundParameters["SubscriptionId"] -ResourceGroupName $PSBoundParameters["ResourceGroupName"] -Name $PSBoundParameters["Name"]
240+
$component = . Get-AzApplicationInsights @EnvPSBoundParameters
211241
} catch {
212242
Write-Warning "component $($PSBoundParameters['Name']) is not existed in Resource Group $($PSBoundParameters["ResourceGroupName"])"
213243
return
@@ -258,7 +288,7 @@ function Update-AzApplicationInsights {
258288
$PSBoundParameters["SamplingPercentage"] = $component.SamplingPercentage
259289
}
260290
if (!$PSBoundParameters.ContainsKey("Tag") -and ($null -ne $component.Tag)) {
261-
$PSBoundParameters["Tag"] = [System.Collections.Hashtable]$component.Tag.AddtionalProperties
291+
$PSBoundParameters["Tag"] = [System.Collections.Hashtable]$component.Tag.AdditionalProperties
262292
}
263293
if (!$PSBoundParameters.ContainsKey("WorkspaceResourceId") -and ![System.String]::IsNullOrEmpty($component.WorkspaceResourceId)) {
264294
$PSBoundParameters["WorkspaceResourceId"] = $component.WorkspaceResourceId

0 commit comments

Comments
 (0)