-
Notifications
You must be signed in to change notification settings - Fork 248
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix issues caused by vsix changes + publish timeout on publishing apps (
#3258) When using Publish-PerTenantExtensionApps with a set of apps, which takes a very long time to publish, the AccessToken might expire and lead to failure. AccessToken is now refreshed when needed. Issue #3254 vsix no longer includes dotnet framework 4.8 compatible dlls for version 24 Avoid using CDN when downloading from bcinsider as this frequently changes and subsequently fails --------- Co-authored-by: freddydk <[email protected]>
- Loading branch information
Showing
7 changed files
with
98 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,6 +49,11 @@ function Publish-PerTenantExtensionApps { | |
$telemetryScope = InitTelemetryScope -name $MyInvocation.InvocationName -parameterValues $PSBoundParameters -includeParameters @() | ||
try { | ||
|
||
function GetAuthHeaders { | ||
$bcAuthContext = Renew-BcAuthContext -bcAuthContext $bcAuthContext | ||
return @{ "Authorization" = "Bearer $($bcAuthContext.AccessToken)" } | ||
} | ||
|
||
$newLine = @{} | ||
if (!$useNewLine) { | ||
$newLine = @{ "NoNewLine" = $true } | ||
|
@@ -70,18 +75,14 @@ try { | |
throw "Authentication failed" | ||
} | ||
} | ||
else { | ||
$bcAuthContext = Renew-BcAuthContext -bcAuthContext $bcAuthContext | ||
} | ||
|
||
$appFolder = Join-Path ([System.IO.Path]::GetTempPath()) ([guid]::NewGuid().ToString()) | ||
try { | ||
$appFiles = CopyAppFilesToFolder -appFiles $appFiles -folder $appFolder | ||
$automationApiUrl = "$($bcContainerHelperConfig.apiBaseUrl.TrimEnd('/'))/v2.0/$environment/api/microsoft/automation/v2.0" | ||
|
||
$authHeaders = @{ "Authorization" = "Bearer $($bcauthcontext.AccessToken)" } | ||
Write-Host "$automationApiUrl/companies" | ||
$companies = Invoke-RestMethod -Headers $authHeaders -Method Get -Uri "$automationApiUrl/companies" -UseBasicParsing | ||
$companies = Invoke-RestMethod -Headers (GetAuthHeaders) -Method Get -Uri "$automationApiUrl/companies" -UseBasicParsing | ||
$company = $companies.value | Where-Object { ($companyName -eq "") -or ($_.name -eq $companyName) } | Select-Object -First 1 | ||
if (!($company)) { | ||
throw "No company $companyName" | ||
|
@@ -90,7 +91,7 @@ try { | |
Write-Host "Company '$companyName' has id $companyId" | ||
|
||
Write-Host "$automationApiUrl/companies($companyId)/extensions" | ||
$getExtensions = Invoke-WebRequest -Headers $authHeaders -Method Get -Uri "$automationApiUrl/companies($companyId)/extensions" -UseBasicParsing | ||
$getExtensions = Invoke-WebRequest -Headers (GetAuthHeaders) -Method Get -Uri "$automationApiUrl/companies($companyId)/extensions" -UseBasicParsing | ||
$extensions = (ConvertFrom-Json $getExtensions.Content).value | Sort-Object -Property DisplayName | ||
|
||
if(!$hideInstalledExtensionsOutput) { | ||
|
@@ -147,20 +148,20 @@ try { | |
Write-Host @newLine "publishing and installing" | ||
} | ||
if (!$existingApp) { | ||
$extensionUpload = (Invoke-RestMethod -Method Get -Uri "$automationApiUrl/companies($companyId)/extensionUpload" -Headers $authHeaders).value | ||
$extensionUpload = (Invoke-RestMethod -Method Get -Uri "$automationApiUrl/companies($companyId)/extensionUpload" -Headers (GetAuthHeaders)).value | ||
Write-Host @newLine "." | ||
if ($extensionUpload -and $extensionUpload.systemId) { | ||
$extensionUpload = Invoke-RestMethod ` | ||
-Method Patch ` | ||
-Uri "$automationApiUrl/companies($companyId)/extensionUpload($($extensionUpload.systemId))" ` | ||
-Headers ($authHeaders + $ifMatchHeader + $jsonHeader) ` | ||
-Headers ((GetAuthHeaders) + $ifMatchHeader + $jsonHeader) ` | ||
-Body ($body | ConvertTo-Json -Compress) | ||
} | ||
else { | ||
$ExtensionUpload = Invoke-RestMethod ` | ||
-Method Post ` | ||
-Uri "$automationApiUrl/companies($companyId)/extensionUpload" ` | ||
-Headers ($authHeaders + $jsonHeader) ` | ||
-Headers ((GetAuthHeaders) + $jsonHeader) ` | ||
-Body ($body | ConvertTo-Json -Compress) | ||
} | ||
Write-Host @newLine "." | ||
|
@@ -171,22 +172,22 @@ try { | |
Invoke-RestMethod ` | ||
-Method Patch ` | ||
-Uri $extensionUpload.'[email protected]' ` | ||
-Headers ($authHeaders + $ifMatchHeader + $streamHeader) ` | ||
-Headers ((GetAuthHeaders) + $ifMatchHeader + $streamHeader) ` | ||
-Body $fileBody | Out-Null | ||
Write-Host @newLine "." | ||
Invoke-RestMethod ` | ||
-Method Post ` | ||
-Uri "$automationApiUrl/companies($companyId)/extensionUpload($($extensionUpload.systemId))/Microsoft.NAV.upload" ` | ||
-Headers ($authHeaders + $ifMatchHeader) | Out-Null | ||
-Headers ((GetAuthHeaders) + $ifMatchHeader) | Out-Null | ||
Write-Host @newLine "." | ||
$completed = $false | ||
$errCount = 0 | ||
$sleepSeconds = 5 | ||
$sleepSeconds = 30 | ||
while (!$completed) | ||
{ | ||
Start-Sleep -Seconds $sleepSeconds | ||
try { | ||
$extensionDeploymentStatusResponse = Invoke-WebRequest -Headers $authHeaders -Method Get -Uri "$automationApiUrl/companies($companyId)/extensionDeploymentStatus" -UseBasicParsing | ||
$extensionDeploymentStatusResponse = Invoke-WebRequest -Headers (GetAuthHeaders) -Method Get -Uri "$automationApiUrl/companies($companyId)/extensionDeploymentStatus" -UseBasicParsing | ||
$extensionDeploymentStatuses = (ConvertFrom-Json $extensionDeploymentStatusResponse.Content).value | ||
|
||
$completed = $true | ||
|
@@ -231,7 +232,7 @@ try { | |
throw | ||
} | ||
finally { | ||
$getExtensions = Invoke-WebRequest -Headers $authHeaders -Method Get -Uri "$automationApiUrl/companies($companyId)/extensions" -UseBasicParsing | ||
$getExtensions = Invoke-WebRequest -Headers (GetAuthHeaders) -Method Get -Uri "$automationApiUrl/companies($companyId)/extensions" -UseBasicParsing | ||
$extensions = (ConvertFrom-Json $getExtensions.Content).value | Sort-Object -Property DisplayName | ||
|
||
if (!$hideInstalledExtensionsOutput) { | ||
|