Skip to content

Commit 83f0b87

Browse files
authored
session bug + remove telemetry from low level functions (#3509)
Session caching didn't really work in the latest preview + telemetry in the low level functions can be measured in perf. Co-authored-by: freddydk <[email protected]>
1 parent de974c8 commit 83f0b87

25 files changed

+25
-265
lines changed

AppHandling/Publish-NavContainerApp.ps1

+2
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,7 @@ try {
310310
}
311311
else {
312312
[ScriptBlock] $scriptblock = { Param($appFile, $skipVerification, $sync, $install, $upgrade, $tenant, $syncMode, $packageType, $scope, $language, $PublisherAzureActiveDirectoryTenantId, $force, $ignoreIfAppExists)
313+
$prevPreference = $ProgressPreference; $ProgressPreference = "SilentlyContinue"
313314
$publishArgs = @{ "packageType" = $packageType }
314315
if ($scope) {
315316
$publishArgs += @{ "Scope" = $scope }
@@ -394,6 +395,7 @@ try {
394395
Start-NavAppDataUpgrade -ServerInstance $ServerInstance -Publisher $appPublisher -Name $appName -Version $appVersion -Tenant $tenant @installArgs
395396
}
396397
}
398+
$ProgressPreference = $prevPreference
397399
}
398400
if ($isCloudBcContainer) {
399401
$containerPath = Join-Path 'C:\DL' ([System.IO.Path]::GetFileName($appfile))

Common/Download-File.ps1

-11
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,6 @@ function Download-File {
3030
[int] $timeout = 100
3131
)
3232

33-
$telemetryScope = InitTelemetryScope -name $MyInvocation.InvocationName -parameterValues $PSBoundParameters -includeParameters @()
34-
try {
35-
3633
$replaceUrls = @{
3734
"https://go.microsoft.com/fwlink/?LinkID=844461" = "https://bcartifacts.azureedge.net/prerequisites/DotNetCore.1.0.4_1.1.1-WindowsHosting.exe"
3835
"https://download.microsoft.com/download/C/9/E/C9E8180D-4E51-40A6-A9BF-776990D8BCA9/rewrite_amd64.msi" = "https://bcartifacts.azureedge.net/prerequisites/rewrite_2.0_rtw_x64.msi"
@@ -99,12 +96,4 @@ try {
9996
}
10097
}
10198
}
102-
catch {
103-
TrackException -telemetryScope $telemetryScope -errorRecord $_
104-
throw
105-
}
106-
finally {
107-
TrackTrace -telemetryScope $telemetryScope
108-
}
109-
}
11099
Export-ModuleMember -Function Download-File

ContainerHandling/Get-NavContainerSession.ps1

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ function Get-BcContainerSession {
3030
$session = $sessions[$containerName]
3131
try {
3232
$platformVersion = Invoke-Command -Session $session -ScriptBlock { [System.Version](get-item 'C:\Program Files\Microsoft Dynamics NAV\*\Service\Microsoft.Dynamics.Nav.Server.exe').Versioninfo.FileVersion }
33-
if ($platformVersion -ge 24 -and ($usePwsh -xor $session.ConfigurationName -eq 'PowerShell.7')) {
33+
if ($platformVersion.Major -ge 24 -and ($usePwsh -xor $session.ConfigurationName -eq 'PowerShell.7')) {
3434
# Cannot use existing session
3535
Remove-PSSession -Session $session
3636
$sessions.Remove($containerName)

ContainerInfo/Get-NavContainerArtifactUrl.ps1

-11
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@ function Get-BcContainerArtifactUrl {
1616
[string] $containerName = $bcContainerHelperConfig.defaultContainerName
1717
)
1818

19-
$telemetryScope = InitTelemetryScope -name $MyInvocation.InvocationName -parameterValues $PSBoundParameters -includeParameters @()
20-
try {
21-
2219
$inspect = docker inspect $containerName | ConvertFrom-Json
2320
$artifactUrlEnv = $inspect.config.Env | Where-Object { $_ -like "artifactUrl=*" }
2421
if ($artifactUrlEnv) {
@@ -28,13 +25,5 @@ try {
2825
return ""
2926
}
3027
}
31-
catch {
32-
TrackException -telemetryScope $telemetryScope -errorRecord $_
33-
throw
34-
}
35-
finally {
36-
TrackTrace -telemetryScope $telemetryScope
37-
}
38-
}
3928
Set-Alias -Name Get-NavContainerArtifactUrl -Value Get-BcContainerArtifactUrl
4029
Export-ModuleMember -Function Get-BcContainerArtifactUrl -Alias Get-NavContainerArtifactUrl

ContainerInfo/Get-NavContainerCountry.ps1

-12
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,11 @@ function Get-BcContainerCountry {
1717
[string] $containerOrImageName
1818
)
1919

20-
$telemetryScope = InitTelemetryScope -name $MyInvocation.InvocationName -parameterValues $PSBoundParameters -includeParameters @()
21-
try {
22-
2320
$inspect = docker inspect $containerOrImageName | ConvertFrom-Json
2421
if ($inspect.Config.Labels.psobject.Properties.Match('maintainer').Count -eq 0 -or $inspect.Config.Labels.maintainer -ne "Dynamics SMB") {
2522
throw "Container $containerOrImageName is not a NAV/BC container"
2623
}
2724
return "$($inspect.Config.Labels.country)"
28-
29-
}
30-
catch {
31-
TrackException -telemetryScope $telemetryScope -errorRecord $_
32-
throw
33-
}
34-
finally {
35-
TrackTrace -telemetryScope $telemetryScope
36-
}
3725
}
3826
Set-Alias -Name Get-NavContainerCountry -Value Get-BcContainerCountry
3927
Export-ModuleMember -Function Get-BcContainerCountry -Alias Get-NavContainerCountry

ContainerInfo/Get-NavContainerDebugInfo.ps1

-11
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,6 @@ function Get-BcContainerDebugInfo {
4545
[switch] $CopyToClipboard
4646
)
4747

48-
$telemetryScope = InitTelemetryScope -name $MyInvocation.InvocationName -parameterValues $PSBoundParameters -includeParameters @()
49-
try {
50-
5148
$debugInfo = @{}
5249
$inspect = docker inspect $containerName | ConvertFrom-Json
5350

@@ -107,13 +104,5 @@ try {
107104

108105
return $debugInfoJson
109106
}
110-
catch {
111-
TrackException -telemetryScope $telemetryScope -errorRecord $_
112-
throw
113-
}
114-
finally {
115-
TrackTrace -telemetryScope $telemetryScope
116-
}
117-
}
118107
Set-Alias -Name Get-NavContainerDebugInfo -Value Get-BcContainerDebugInfo
119108
Export-ModuleMember -Function Get-BcContainerDebugInfo -Alias Get-NavContainerDebugInfo

ContainerInfo/Get-NavContainerEula.ps1

-10
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,11 @@ function Get-BcContainerEula {
1818
[string] $containerOrImageName
1919
)
2020

21-
$telemetryScope = InitTelemetryScope -name $MyInvocation.InvocationName -parameterValues $PSBoundParameters -includeParameters @()
22-
try {
2321
$inspect = docker inspect $containerOrImageName | ConvertFrom-Json
2422
if ($inspect.Config.Labels.psobject.Properties.Match('maintainer').Count -eq 0 -or $inspect.Config.Labels.maintainer -ne "Dynamics SMB") {
2523
throw "Container $containerOrImageName is not a NAV/BC container"
2624
}
2725
return "$($inspect.Config.Labels.Eula)"
2826
}
29-
catch {
30-
TrackException -telemetryScope $telemetryScope -errorRecord $_
31-
throw
32-
}
33-
finally {
34-
TrackTrace -telemetryScope $telemetryScope
35-
}
36-
}
3727
Set-Alias -Name Get-NavContainerEula -Value Get-BcContainerEula
3828
Export-ModuleMember -Function Get-BcContainerEula -Alias Get-NavContainerEula

ContainerInfo/Get-NavContainerEventLog.ps1

-10
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ function Get-BcContainerEventLog {
2323
[switch] $doNotOpen
2424
)
2525

26-
$telemetryScope = InitTelemetryScope -name $MyInvocation.InvocationName -parameterValues $PSBoundParameters -includeParameters @()
27-
try {
2826
Write-Host "Getting event log for $containername"
2927

3028
$eventLogFolder = Join-Path $bcContainerHelperConfig.hostHelperFolder "EventLogs"
@@ -46,13 +44,5 @@ try {
4644
Start-Process -FilePath $eventLogName | Out-Null
4745
}
4846
}
49-
catch {
50-
TrackException -telemetryScope $telemetryScope -errorRecord $_
51-
throw
52-
}
53-
finally {
54-
TrackTrace -telemetryScope $telemetryScope
55-
}
56-
}
5747
Set-Alias -Name Get-NavContainerEventLog -Value Get-BcContainerEventLog
5848
Export-ModuleMember -Function Get-BcContainerEventLog -Alias Get-NavContainerEventLog

ContainerInfo/Get-NavContainerGenericTag.ps1

-11
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,11 @@ function Get-BcContainerGenericTag {
1717
[string] $containerOrImageName
1818
)
1919

20-
$telemetryScope = InitTelemetryScope -name $MyInvocation.InvocationName -parameterValues $PSBoundParameters -includeParameters @()
21-
try {
22-
2320
$inspect = docker inspect $containerOrImageName | ConvertFrom-Json
2421
if ($inspect.Config.Labels.psobject.Properties.Match('tag').Count -eq 0) {
2522
throw "Container $containerOrImageName is not a NAV/BC container"
2623
}
2724
return "$($inspect.Config.Labels.tag)"
2825
}
29-
catch {
30-
TrackException -telemetryScope $telemetryScope -errorRecord $_
31-
throw
32-
}
33-
finally {
34-
TrackTrace -telemetryScope $telemetryScope
35-
}
36-
}
3726
Set-Alias -Name Get-NavContainerGenericTag -Value Get-BcContainerGenericTag
3827
Export-ModuleMember -Function Get-BcContainerGenericTag -Alias Get-NavContainerGenericTag

ContainerInfo/Get-NavContainerId.ps1

-11
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@ function Get-BcContainerId {
1515
[string] $containerName = $bcContainerHelperConfig.defaultContainerName
1616
)
1717

18-
$telemetryScope = InitTelemetryScope -name $MyInvocation.InvocationName -parameterValues $PSBoundParameters -includeParameters @()
19-
try {
20-
2118
$id = ""
2219
docker ps --format "{{.ID}}:{{.Names}}" -a --no-trunc | ForEach-Object {
2320
$ps = $_.split(':')
@@ -36,13 +33,5 @@ try {
3633
}
3734
$id
3835
}
39-
catch {
40-
TrackException -telemetryScope $telemetryScope -errorRecord $_
41-
throw
42-
}
43-
finally {
44-
TrackTrace -telemetryScope $telemetryScope
45-
}
46-
}
4736
Set-Alias -Name Get-NavContainerId -Value Get-BcContainerId
4837
Export-ModuleMember -Function Get-BcContainerId -Alias Get-NavContainerId

ContainerInfo/Get-NavContainerImageLabels.ps1

-12
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@ function Get-BcContainerImageLabels {
1717
[PSCredential] $registryCredential
1818
)
1919

20-
$telemetryScope = InitTelemetryScope -name $MyInvocation.InvocationName -parameterValues $PSBoundParameters -includeParameters @()
21-
try {
22-
2320
[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12
2421
$webclient = New-Object System.Net.WebClient
2522

@@ -72,15 +69,6 @@ try {
7269
}
7370
catch {
7471
}
75-
76-
}
77-
catch {
78-
TrackException -telemetryScope $telemetryScope -errorRecord $_
79-
throw
80-
}
81-
finally {
82-
TrackTrace -telemetryScope $telemetryScope
83-
}
8472
}
8573
Set-Alias -Name Get-NavContainerImageLabels -Value Get-BcContainerImageLabels
8674
Export-ModuleMember -Function Get-BcContainerImageLabels -Alias Get-NavContainerImageLabels

ContainerInfo/Get-NavContainerImageName.ps1

-10
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,8 @@ function Get-BcContainerImageName {
1616
[string] $containerName = $bcContainerHelperConfig.defaultContainerName
1717
)
1818

19-
$telemetryScope = InitTelemetryScope -name $MyInvocation.InvocationName -parameterValues $PSBoundParameters -includeParameters @()
20-
try {
2119
$inspect = docker inspect $containerName | ConvertFrom-Json
2220
return "$($inspect.Config.Image)"
2321
}
24-
catch {
25-
TrackException -telemetryScope $telemetryScope -errorRecord $_
26-
throw
27-
}
28-
finally {
29-
TrackTrace -telemetryScope $telemetryScope
30-
}
31-
}
3222
Set-Alias -Name Get-NavContainerImageName -Value Get-BcContainerImageName
3323
Export-ModuleMember -Function Get-BcContainerImageName -Alias Get-NavContainerImageName

ContainerInfo/Get-NavContainerImageTags.ps1

-11
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@ function Get-BcContainerImageTags {
1919
[int] $pageSize = -1
2020
)
2121

22-
$telemetryScope = InitTelemetryScope -name $MyInvocation.InvocationName -parameterValues $PSBoundParameters -includeParameters @()
23-
try {
24-
2522
[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12
2623
$webclient = New-Object System.Net.WebClient
2724

@@ -77,13 +74,5 @@ try {
7774
catch {
7875
}
7976
}
80-
catch {
81-
TrackException -telemetryScope $telemetryScope -errorRecord $_
82-
throw
83-
}
84-
finally {
85-
TrackTrace -telemetryScope $telemetryScope
86-
}
87-
}
8877
Set-Alias -Name Get-NavContainerImageTags -Value Get-BcContainerImageTags
8978
Export-ModuleMember -Function Get-BcContainerImageTags -Alias Get-NavContainerImageTags

ContainerInfo/Get-NavContainerIpAddress.ps1

-11
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@ function Get-BcContainerIpAddress {
1818
[string] $networkName = ""
1919
)
2020

21-
$telemetryScope = InitTelemetryScope -name $MyInvocation.InvocationName -parameterValues $PSBoundParameters -includeParameters @()
22-
try {
23-
2421
$ip = Invoke-ScriptInBcContainer -containerName $containerName -scriptblock {
2522
$ip = ""
2623
$ips = Get-NetIPAddress | Where-Object { $_.AddressFamily -eq "IPv4" -and $_.IPAddress -ne "127.0.0.1" }
@@ -47,13 +44,5 @@ try {
4744
}
4845
return $ip
4946
}
50-
catch {
51-
TrackException -telemetryScope $telemetryScope -errorRecord $_
52-
throw
53-
}
54-
finally {
55-
TrackTrace -telemetryScope $telemetryScope
56-
}
57-
}
5847
Set-Alias -Name Get-NavContainerIpAddress -Value Get-BcContainerIpAddress
5948
Export-ModuleMember -Function Get-BcContainerIpAddress -Alias Get-NavContainerIpAddress

ContainerInfo/Get-NavContainerLegal.ps1

-11
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,11 @@ function Get-BcContainerLegal {
1818
[string] $containerOrImageName
1919
)
2020

21-
$telemetryScope = InitTelemetryScope -name $MyInvocation.InvocationName -parameterValues $PSBoundParameters -includeParameters @()
22-
try {
23-
2421
$inspect = docker inspect $containerOrImageName | ConvertFrom-Json
2522
if ($inspect.Config.Labels.psobject.Properties.Match('maintainer').Count -eq 0 -or $inspect.Config.Labels.maintainer -ne "Dynamics SMB") {
2623
throw "Container $containerOrImageName is not a NAV/BC container"
2724
}
2825
return "$($inspect.Config.Labels.legal)"
2926
}
30-
catch {
31-
TrackException -telemetryScope $telemetryScope -errorRecord $_
32-
throw
33-
}
34-
finally {
35-
TrackTrace -telemetryScope $telemetryScope
36-
}
37-
}
3827
Set-Alias -Name Get-NavContainerLegal -Value Get-BcContainerLegal
3928
Export-ModuleMember -Function Get-BcContainerLegal -Alias Get-NavContainerLegal

ContainerInfo/Get-NavContainerLicenseInformation.ps1

-10
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,9 @@ Function Get-BcContainerLicenseInformation {
1313
[String] $ContainerName = $bcContainerHelperConfig.defaultContainerName
1414
)
1515

16-
$telemetryScope = InitTelemetryScope -name $MyInvocation.InvocationName -parameterValues $PSBoundParameters -includeParameters @()
17-
try {
1816
Invoke-ScriptInBcContainer -containerName $containerName -ScriptBlock {
1917
Get-NavServerInstance | Export-NAVServerLicenseInformation
2018
}
2119
}
22-
catch {
23-
TrackException -telemetryScope $telemetryScope -errorRecord $_
24-
throw
25-
}
26-
finally {
27-
TrackTrace -telemetryScope $telemetryScope
28-
}
29-
}
3020
Set-Alias -Name Get-NavContainerLicenseInformation -Value Get-BcContainerLicenseInformation
3121
Export-ModuleMember -Function Get-BcContainerLicenseInformation -Alias Get-NavContainerLicenseInformation

ContainerInfo/Get-NavContainerName.ps1

-11
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,7 @@ function Get-BcContainerName {
1515
[string] $containerId
1616
)
1717

18-
$telemetryScope = InitTelemetryScope -name $MyInvocation.InvocationName -parameterValues $PSBoundParameters -includeParameters @()
19-
try {
20-
2118
docker ps --format='{{.Names}}' -a --filter "id=$containerId"
2219
}
23-
catch {
24-
TrackException -telemetryScope $telemetryScope -errorRecord $_
25-
throw
26-
}
27-
finally {
28-
TrackTrace -telemetryScope $telemetryScope
29-
}
30-
}
3120
Set-Alias -Name Get-NavContainerName -Value Get-BcContainerName
3221
Export-ModuleMember -Function Get-BcContainerName -Alias Get-NavContainerName

ContainerInfo/Get-NavContainerNavVersion.ps1

-10
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,11 @@ function Get-BcContainerNavVersion {
1717
[string] $containerOrImageName
1818
)
1919

20-
$telemetryScope = InitTelemetryScope -name $MyInvocation.InvocationName -parameterValues $PSBoundParameters -includeParameters @()
21-
try {
2220
$inspect = docker inspect $containerOrImageName | ConvertFrom-Json
2321
if ($inspect.Config.Labels.psobject.Properties.Match('maintainer').Count -eq 0 -or $inspect.Config.Labels.maintainer -ne "Dynamics SMB") {
2422
throw "Container $containerOrImageName is not a NAV/BC container"
2523
}
2624
return "$($inspect.Config.Labels.version)-$($inspect.Config.Labels.country)"
2725
}
28-
catch {
29-
TrackException -telemetryScope $telemetryScope -errorRecord $_
30-
throw
31-
}
32-
finally {
33-
TrackTrace -telemetryScope $telemetryScope
34-
}
35-
}
3626
Set-Alias -Name Get-NavContainerNavVersion -Value Get-BcContainerNavVersion
3727
Export-ModuleMember -Function Get-BcContainerNavVersion -Alias Get-NavContainerNavVersion

0 commit comments

Comments
 (0)