Skip to content

Commit

Permalink
[Application insight] Fix update component (#24405)
Browse files Browse the repository at this point in the history
* fix application insight update cmdlet

* revert group logic in Application insights test utils
  • Loading branch information
JoyerJin authored Mar 19, 2024
1 parent a9bd00b commit e3757db
Show file tree
Hide file tree
Showing 5 changed files with 338 additions and 56 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,38 @@ function Update-AzApplicationInsights {
)

process {
# add PS bound parameters to run test
$EnvPSBoundParameters = @{}
if ($PSBoundParameters.ContainsKey('Debug')) {
$EnvPSBoundParameters['Debug'] = $Debug
}
if ($PSBoundParameters.ContainsKey('HttpPipelineAppend')) {
$EnvPSBoundParameters['HttpPipelineAppend'] = $HttpPipelineAppend
}
if ($PSBoundParameters.ContainsKey('HttpPipelinePrepend')) {
$EnvPSBoundParameters['HttpPipelinePrepend'] = $HttpPipelinePrepend
}
if ($PSBoundParameters.ContainsKey('Proxy')) {
$EnvPSBoundParameters['Proxy'] = $Proxy
}
if ($PSBoundParameters.ContainsKey('ProxyCredential')) {
$EnvPSBoundParameters['ProxyCredential'] = $ProxyCredential
}
if ($PSBoundParameters.ContainsKey('ProxyUseDefaultCredentials')) {
$EnvPSBoundParameters['ProxyUseDefaultCredentials'] = $ProxyUseDefaultCredentials
}
if ($PSBoundParameters.ContainsKey('SubscriptionId')) {
$EnvPSBoundParameters['SubscriptionId'] = $SubscriptionId
}
if ($PSBoundParameters.ContainsKey('ResourceGroupName')) {
$EnvPSBoundParameters['ResourceGroupName'] = $ResourceGroupName
}
if ($PSBoundParameters.ContainsKey('Name')) {
$EnvPSBoundParameters['Name'] = $Name
}

try {
$component = . Get-AzApplicationInsights -SubscriptionId $PSBoundParameters["SubscriptionId"] -ResourceGroupName $PSBoundParameters["ResourceGroupName"] -Name $PSBoundParameters["Name"]
$component = . Get-AzApplicationInsights @EnvPSBoundParameters
} catch {
Write-Warning "component $($PSBoundParameters['Name']) is not existed in Resource Group $($PSBoundParameters["ResourceGroupName"])"
return
Expand Down Expand Up @@ -258,7 +288,7 @@ function Update-AzApplicationInsights {
$PSBoundParameters["SamplingPercentage"] = $component.SamplingPercentage
}
if (!$PSBoundParameters.ContainsKey("Tag") -and ($null -ne $component.Tag)) {
$PSBoundParameters["Tag"] = [System.Collections.Hashtable]$component.Tag.AddtionalProperties
$PSBoundParameters["Tag"] = [System.Collections.Hashtable]$component.Tag.AdditionalProperties
}
if (!$PSBoundParameters.ContainsKey("WorkspaceResourceId") -and ![System.String]::IsNullOrEmpty($component.WorkspaceResourceId)) {
$PSBoundParameters["WorkspaceResourceId"] = $component.WorkspaceResourceId
Expand Down
Loading

0 comments on commit e3757db

Please sign in to comment.