Skip to content

Commit

Permalink
Use new CDN (#3459)
Browse files Browse the repository at this point in the history
```
bcartifacts.azureedge.net -> bcartifacts-exdbf9fwegejdqak.b02.azurefd.net
bcinsider.azureedge.net -> bcinsider-fvh2ekdjecfjd6gk.b02.azurefd.net
bcpublicpreview.azureedge.net ->bcpublicpreview-f2ajahg0e2cudpgh.b02.azurefd.net
businesscentralapps.azureedge.net -> businesscentralapps-hkdrdkaeangzfydv.b02.azurefd.net
bcprivate.azureedge.net -> bcprivate-fmdwbsb3ekbkc0bt.b02.azurefd.net
```

Also: remove support for SAS Token

PR also contains a fix for building with symbols only .app files -
copying installApps to the packagesFolder as well as publishing to a
container. Reason is that you cannot download symbols from a container
if you publish a symbols only package to the container.

---------

Co-authored-by: freddydk <[email protected]>
  • Loading branch information
freddydk and freddydk authored Apr 4, 2024
1 parent a154476 commit 43c9155
Show file tree
Hide file tree
Showing 14 changed files with 177 additions and 262 deletions.
2 changes: 1 addition & 1 deletion AlpacaBcContainer/New-AlpacaBcContainer.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ function New-AlpacaBcContainer {
$additionalFolders = @( "c:\run=$runFolderUrl" ) + $additionalFolders

if ($bcArtifact -like "https://*") {
$storageAccount = ("$bcArtifact////".Split('/')[2]).Split('.')[0]
$storageAccount = (ReplaceCDN -sourceUrl "$bcArtifact////".Split('/')[2] -useBlobUrl).Split('.')[0]
$artifactType = ("$bcArtifact////".Split('/')[3])
$version = ("$bcArtifact////".Split('/')[4])
$country = ("$bcArtifact////".Split('?')[0].Split('/')[5])
Expand Down
2 changes: 1 addition & 1 deletion AppHandling/Run-AlCops.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ function Run-AlCops {
$appSourceCopJson | ConvertTo-Json -Depth 99 | Set-Content (Join-Path $tmpFolder "appSourceCop.json") -Encoding UTF8

$appSourceRulesetFile = Join-Path $tmpFolder "appsource.default.ruleset.json"
Download-File -sourceUrl "https://bcartifacts.azureedge.net/rulesets/appsource.default.ruleset.json" -destinationFile $appSourceRulesetFile
Download-File -sourceUrl "https://bcartifacts-exdbf9fwegejdqak.b02.azurefd.net/rulesets/appsource.default.ruleset.json" -destinationFile $appSourceRulesetFile
$ruleset.includedRuleSets += @(@{
"action" = "Default"
"path" = Get-BcContainerPath -containerName $containerName -path $appSourceRulesetFile
Expand Down
32 changes: 22 additions & 10 deletions AppHandling/Run-AlPipeline.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,7 @@
.Parameter outputFolder
This is the folder (relative to base folder) where compiled apps are placed. Only relevant when not using useDevEndpoint.
.Parameter artifact
The description of which artifact to use. This can either be a URL (from Get-BcArtifactUrl) or in the format storageAccount/type/version/country/select/sastoken, where these values are transferred as parameters to Get-BcArtifactUrl. Default value is ///us/current.
If you specify accept_insiderEula, you do not need to specify a sasToken
The description of which artifact to use. This can either be a URL (from Get-BcArtifactUrl) or in the format storageAccount/type/version/country/select, where these values are transferred as parameters to Get-BcArtifactUrl. Default value is ///us/current.
.Parameter useGenericImage
Specify a private (or special) generic image to use for the Container OS. Default is calling Get-BestGenericImageName.
.Parameter buildArtifactFolder
Expand Down Expand Up @@ -616,24 +615,21 @@ else {
$version = $segments[2]
$country = $segments[3]; if ($country -eq "") { $country = "us" }
$select = $segments[4]; if ($select -eq "") { $select = "latest" }
$sasToken = $segments[5]

Write-Host "Determining artifacts to use"
$minsto = $storageAccount
$minsel = $select
$mintok = $sasToken
if ($additionalCountries) {
$minver = $null
@($country)+$additionalCountries | ForEach-Object {
$url = Get-BCArtifactUrl -storageAccount $storageAccount -type $type -version $version -country $_.Trim() -select $select -sasToken $sasToken -accept_insiderEula:$accept_insiderEula | Select-Object -First 1
$url = Get-BCArtifactUrl -storageAccount $storageAccount -type $type -version $version -country $_.Trim() -select $select -accept_insiderEula:$accept_insiderEula | Select-Object -First 1
Write-Host "Found $($url.Split('?')[0])"
if ($url) {
$ver = [Version]$url.Split('/')[4]
if ($minver -eq $null -or $ver -lt $minver) {
$minver = $ver
$minsto = $url.Split('/')[2].Split('.')[0]
$minsto = (ReplaceCDN -sourceUrl $url.Split('/')[2] -useBlobUrl).Split('.')[0]
$minsel = "Latest"
$mintok = $url.Split('?')[1]; if ($mintok) { $mintok = "?$mintok" }
}
}
}
Expand All @@ -642,7 +638,7 @@ else {
}
$version = $minver.ToString()
}
$artifactUrl = Get-BCArtifactUrl -storageAccount $minsto -type $type -version $version -country $country -select $minsel -sasToken $mintok -accept_insiderEula:$accept_insiderEula | Select-Object -First 1
$artifactUrl = Get-BCArtifactUrl -storageAccount $minsto -type $type -version $version -country $country -select $minsel -accept_insiderEula:$accept_insiderEula | Select-Object -First 1
if (!($artifactUrl)) {
throw "Unable to locate artifacts"
}
Expand All @@ -664,7 +660,6 @@ Write-Host -NoNewLine -ForegroundColor Yellow "Pipeline name "
Write-Host -NoNewLine -ForegroundColor Yellow "Container name "; Write-Host $containerName
Write-Host -NoNewLine -ForegroundColor Yellow "Image name "; Write-Host $imageName
Write-Host -NoNewLine -ForegroundColor Yellow "ArtifactUrl "; Write-Host $artifactUrl.Split('?')[0]
Write-Host -NoNewLine -ForegroundColor Yellow "SasToken "; if ($artifactUrl.Contains('?')) { Write-Host "Specified" } else { Write-Host "Not Specified" }
Write-Host -NoNewLine -ForegroundColor Yellow "BcAuthContext "; if ($bcauthcontext) { Write-Host "Specified" } else { Write-Host "Not Specified" }
Write-Host -NoNewLine -ForegroundColor Yellow "Environment "; Write-Host $environment
Write-Host -NoNewLine -ForegroundColor Yellow "ReUseContainer "; Write-Host $reUseContainer
Expand Down Expand Up @@ -1691,7 +1686,7 @@ Write-Host -ForegroundColor Yellow @'
})
}
$appSourceRulesetFile = Join-Path $folder "appsource.default.ruleset.json"
Download-File -sourceUrl "https://bcartifacts.azureedge.net/rulesets/appsource.default.ruleset.json" -destinationFile $appSourceRulesetFile
Download-File -sourceUrl "https://bcartifacts-exdbf9fwegejdqak.b02.azurefd.net/rulesets/appsource.default.ruleset.json" -destinationFile $appSourceRulesetFile
$ruleset.includedRuleSets += @(@{
"action" = "Default"
"path" = Get-BcContainerPath -containerName $containerName -path $appSourceRulesetFile
Expand Down Expand Up @@ -1792,6 +1787,23 @@ Write-Host -ForegroundColor Yellow @'
}
}

if ($generateDependencyArtifact -and !$filesOnly -and !$useCompilerFolder) {
$depFolder = Join-Path $buildArtifactFolder "Dependencies"
Write-Host "Copying dependencies from $depFolder to $appPackagesFolder"
if (Test-Path $depFolder) {
Get-ChildItem -Path $depFolder -Recurse -file -Filter '*.app' | ForEach-Object {
$destName = Join-Path $appPackagesFolder $_.Name
if (Test-Path $destName) {
Write-Host "- $destName already exists"
}
else {
Write-Host "+ Copying $($_.FullName) to $destName"
Copy-Item -Path $_.FullName -Destination $destName -Force
}
}
}
}

$Parameters += @{
"appProjectFolder" = $folder
"appOutputFolder" = $appOutputFolder
Expand Down
12 changes: 5 additions & 7 deletions AppHandling/Run-AlValidation.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@
.Parameter doNotIgnoreInfos
Include this switch if you don't want to ignore Infos (if you want to include Infos)
.Parameter sasToken
OBSOLETE - sasToken is no longer needed
Shared Access Service Token for accessing insider artifacts of Business Central. Available on http://aka.ms/collaborate
OBSOLETE - sasToken is no longer supported
.Parameter countries
Array or comma separated list of country codes to validate against
.Parameter affixes
Expand Down Expand Up @@ -96,7 +95,7 @@ Param(
[switch] $failOnError,
[switch] $includeWarnings,
[switch] $doNotIgnoreInfos,
[Obsolete("sasToken is no longer needed")]
[Obsolete("sasToken is no longer supported")]
[string] $sasToken = "",
[Parameter(Mandatory=$true)]
$countries,
Expand Down Expand Up @@ -152,7 +151,7 @@ Write-Host -ForegroundColor Yellow @'
$ver = [Version]$url.Split('/')[4]
if ($minver -eq $null -or $ver -lt $minver) {
$minver = $ver
$minsto = $url.Split('/')[2].Split('.')[0]
$minsto = (ReplaceCDN -sourceUrl $url.Split('/')[2] -useBlobUrl).Split('.')[0]
$minsel = "Latest"
}
}
Expand Down Expand Up @@ -260,7 +259,6 @@ Write-Host -NoNewLine -ForegroundColor Yellow "validateVersion "
Write-Host -NoNewLine -ForegroundColor Yellow "validateCurrent "; Write-Host $validateCurrent
Write-Host -NoNewLine -ForegroundColor Yellow "validateNextMinor "; Write-Host $validateNextMinor
Write-Host -NoNewLine -ForegroundColor Yellow "validateNextMajor "; Write-Host $validateNextMajor
Write-Host -NoNewLine -ForegroundColor Yellow "SasToken "; if ($sasToken) { Write-Host "Specified" } else { Write-Host "Not Specified" }
Write-Host -NoNewLine -ForegroundColor Yellow "countries "; Write-Host ([string]::Join(',',$countries))
Write-Host -NoNewLine -ForegroundColor Yellow "validateCountries "; Write-Host ([string]::Join(',',$validateCountries))
Write-Host -NoNewLine -ForegroundColor Yellow "affixes "; Write-Host ([string]::Join(',',$affixes))
Expand Down Expand Up @@ -380,10 +378,10 @@ elseif ($_ -eq 1 -and $validateVersion) {
$artifactUrl = DetermineArtifactsToUse -version $validateVersion -countries $validateCountries -select Latest
}
elseif ($_ -eq 2 -and $validateNextMinor) {
$artifactUrl = DetermineArtifactsToUse -countries $validateCountries -select NextMinor -sasToken $sasToken
$artifactUrl = DetermineArtifactsToUse -countries $validateCountries -select NextMinor
}
elseif ($_ -eq 3 -and $validateNextMajor) {
$artifactUrl = DetermineArtifactsToUse -countries $validateCountries -select NextMajor -sasToken $sasToken
$artifactUrl = DetermineArtifactsToUse -countries $validateCountries -select NextMajor
}

if ($artifactUrl) {
Expand Down
6 changes: 3 additions & 3 deletions AppHandling/Sign-NavContainerApp.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,11 @@ try {

if (!(Test-Path "C:\Windows\System32\msvcr120.dll")) {
Write-Host "Downloading vcredist_x86"
(New-Object System.Net.WebClient).DownloadFile('https://bcartifacts.azureedge.net/prerequisites/vcredist_x86.exe','c:\run\install\vcredist_x86.exe')
(New-Object System.Net.WebClient).DownloadFile('https://bcartifacts.blob.core.windows.net/prerequisites/vcredist_x86.exe','c:\run\install\vcredist_x86.exe')
Write-Host "Installing vcredist_x86"
start-process -Wait -FilePath c:\run\install\vcredist_x86.exe -ArgumentList /q, /norestart
Write-Host "Downloading vcredist_x64"
(New-Object System.Net.WebClient).DownloadFile('https://bcartifacts.azureedge.net/prerequisites/vcredist_x64.exe','c:\run\install\vcredist_x64.exe')
(New-Object System.Net.WebClient).DownloadFile('https://bcartifacts.blob.core.windows.net/prerequisites/vcredist_x64.exe','c:\run\install\vcredist_x64.exe')
Write-Host "Installing vcredist_x64"
start-process -Wait -FilePath c:\run\install\vcredist_x64.exe -ArgumentList /q, /norestart
}
Expand All @@ -140,7 +140,7 @@ try {
} else {
Write-Host "Downloading Signing Tools"
$winSdkSetupExe = "c:\run\install\winsdksetup.exe"
$winSdkSetupUrl = "https://bcartifacts.azureedge.net/prerequisites/winsdksetup.exe"
$winSdkSetupUrl = "https://bcartifacts.blob.core.windows.net/prerequisites/winsdksetup.exe"
(New-Object System.Net.WebClient).DownloadFile($winSdkSetupUrl,$winSdkSetupExe)
Write-Host "Installing Signing Tools"
Start-Process $winSdkSetupExe -ArgumentList "/features OptionId.SigningTools /q" -Wait
Expand Down
63 changes: 21 additions & 42 deletions Artifacts/Download-Artifacts.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -42,50 +42,31 @@ function Download-Artifacts {

$tmpFolder = Join-Path ([System.IO.Path]::GetDirectoryName($destinationPath)) ([System.IO.Path]::GetRandomFileName())
$zipFile = Join-Path ([System.IO.Path]::GetTempPath()) "$([Guid]::NewGuid().ToString()).zip"
if ($bcContainerHelperConfig.ArtifactsFeedOrganizationAndProject -and ($artifactUrl -like 'https://bcartifacts.*' -or $artifactUrl -like 'https://bcinsider.*')) {
# artifactUrl should be either:
# https://storageaccount.azureedge.net/type/version/country
# or
# https://storageaccount.blob.core.windows.net/type/version/country
if (-not ($artifactUrl -match '^https:\/\/([^.]+)\..*\.net\/([^\/]+)\/([^\/]+)\/([a-zA-Z0-9]+)$')) {
throw "Invalid artifact url '$artifactUrl'"
$retry = $false
do {
Download-File -sourceUrl $artifactUrl -destinationFile $zipFile -timeout $timeout
Write-Host "Unpacking artifact to tmp folder " -NoNewline
try {
Expand-7zipArchive -Path $zipFile -DestinationPath $tmpFolder -use7zipIfAvailable:(!$retry)
$retry = $false
}
$organization, $project = $bcContainerHelperConfig.ArtifactsFeedOrganizationAndProject.Split('/')
New-Item -Path $tmpFolder -ItemType Directory | Out-Null
$artifactVersion = [System.Version]"$($Matches[3])"
$feed = $Matches[1]
$packageName = "$($Matches[2]).$($Matches[4]).$($artifactVersion.Major)"
$packageVersion = "$($artifactVersion.Minor).$($artifactVersion.Build).$($artifactVersion.Revision)"
Write-Host "Using az artifacts universal download --organization https://dev.azure.com/$organization --project $project --scope project --feed $feed --name $packageName --version $packageVersion"
az artifacts universal download --organization "https://dev.azure.com/$organization" --project $project --scope project --feed $feed --name $packageName --version $packageVersion --path $tmpFolder
}
else {
$retry = $false
do {
Download-File -sourceUrl $artifactUrl -destinationFile $zipFile -timeout $timeout
Write-Host "Unpacking artifact to tmp folder " -NoNewline
try {
Expand-7zipArchive -Path $zipFile -DestinationPath $tmpFolder -use7zipIfAvailable:(!$retry)
$retry = $false
catch {
Remove-Item -path $zipFile -force
if (Test-Path $tmpFolder) {
Remove-Item $tmpFolder -Recurse -Force
}
catch {
Remove-Item -path $zipFile -force
if (Test-Path $tmpFolder) {
Remove-Item $tmpFolder -Recurse -Force
}
if ($retry) {
throw "Error trying to unpack artifact, downloaded package is corrupt"
}
else {
if ($artifactUrl -match '^https:\/\/(.+)\.azureedge\.net\/(.*)$') {
Write-Host "Error unpacking platform artifact downloaded from CDN, retrying download from direct download URL"
$artifactUrl = "https://$($Matches[1]).blob.core.windows.net/$($Matches[2])"
$retry = $true
}
if ($retry) {
throw "Error trying to unpack artifact, downloaded package is corrupt"
}
else {
if ($artifactUrl -match '^https:\/\/(.+)\.azureedge\.net\/(.*)$') {
Write-Host "Error unpacking platform artifact downloaded from CDN, retrying download from direct download URL"
$artifactUrl = "https://$($Matches[1]).blob.core.windows.net/$($Matches[2])"
$retry = $true
}
}
} while ($retry)
}
}
} while ($retry)
$result = $false
try {
$attempts = 0
Expand Down Expand Up @@ -162,7 +143,6 @@ try {
}
if (-not $exists) {
Write-Host "Downloading artifact $($appUri.AbsolutePath)"
TestSasToken -url $artifactUrl
DownloadPackage -artifactUrl $artifactUrl -destinationPath $appArtifactPath -timeout $timeout | Out-Null
}
try { [System.IO.File]::WriteAllText((Join-Path $appArtifactPath 'lastused'), "$([datetime]::UtcNow.Ticks)") } catch {}
Expand Down Expand Up @@ -240,7 +220,6 @@ try {
}
if (-not $exists) {
Write-Host "Downloading platform artifact $($platformUri.AbsolutePath)"
TestSasToken -url $platformUrl
$downloadprereqs = DownLoadPackage -ArtifactUrl $platformUrl -DestinationPath $platformArtifactPath -timeout $timeout
if ($downloadprereqs) {
$prerequisiteComponentsFile = Join-Path $platformArtifactPath "Prerequisite Components.json"
Expand Down
Loading

0 comments on commit 43c9155

Please sign in to comment.