Closed staedter closed 4 years ago
There has been quite a lot of updates to the scripts and also the install-containerhelper. You should be able to see here: https://dev.azure.com/businesscentralapps/_git/HelloWorld?path=%2Fscripts%2FInstall-BcContainerHelper.ps1 how you can grab the module directly from github and use it. That typically is not as stable as the preview builds, but today it is.
That was my preferred option anyways, but my colleagues pointed out, that the master branch might not be as stable as the released PSGallery Package. That is what prompted my question.
I will look into it but I guess this would work for me as a solution. Thanks :)
Hi @freddydk,
can you maybe look into using Github Package as an alternative to the PowerShell Gallery? It would also be really helpful if you could use the release feature to have the ability to download a specific version of the container helper directly from Github.
@Sven-Niehus - yes, I am considering other options.
I copied your new Install-BcContainerHelper.ps1 script over into one pipeline and I got it to work, but I had to modify it a little bit. This version is now working for us:
Param(
[string] $bcContainerHelperVersion = "",
[string] $genericImageName = ""
)
if ($bcContainerHelperVersion -eq "") {
$bcContainerHelperVersion = "latest"
}
Write-Host "Use bcContainerHelper Version: '$bcContainerHelperVersion'"
Write-Host 'Skipping PSGallery by setting $bcContainerHelperVersion = "https://github.com/microsoft/navcontainerhelper/archive/master.zip'
$bcContainerHelperVersion = "https://github.com/microsoft/navcontainerhelper/archive/master.zip"
$buildMutexName = "bcContainerHelper"
$buildMutex = New-Object System.Threading.Mutex($false, $buildMutexName)
try {
try {
if (!$buildMutex.WaitOne(1000)) {
Write-Host "Waiting for other process to update BcContainerHelper"
$buildMutex.WaitOne() | Out-Null
Write-Host "Other process completed"
}
}
catch [System.Threading.AbandonedMutexException] {
Write-Host "Other process terminated abnormally"
}
$bcContainerHelperVersion = $bcContainerHelperVersion.Replace('{HOME}',$HOME.TrimEnd('\'))
if ($bcContainerHelperVersion -like "?:\*") {
if (Test-Path $bcContainerHelperVersion) {
$bch = Get-Item (Join-Path $bcContainerHelperVersion '*ContainerHelper.ps1')
if ($bch) {
Write-Host "Using $bch"
. "$bch"
return
}
}
$bcContainerHelperVersion = "https://github.com/microsoft/navcontainerhelper/archive/dev.zip"
}
if ($bcContainerHelperVersion -notlike "https://*") {
try {
Remove-Module -Name BcContainerHelper -Force -ErrorAction SilentlyContinue
if ($bcContainerHelperVersion -eq "preview") {
Write-Host "Determine latest BcContainerHelper preview version"
$latestVersion = (Find-Module -Name bccontainerhelper -AllowPrerelease).Version
$bcContainerHelperVersion = $latestVersion.ToString()
Write-Host "BcContainerHelper $bcContainerHelperVersion is the latest preview version"
}
elseif ($bcContainerHelperVersion -eq "latest") {
Write-Host "Determine latest BcContainerHelper version"
$latestVersion = (Find-Module -Name bccontainerhelper).Version
$bcContainerHelperVersion = $latestVersion.ToString()
Write-Host "BcContainerHelper $bcContainerHelperVersion is the latest version"
}
$modules = Get-InstalledModule -Name bccontainerhelper -ErrorAction SilentlyContinue -AllVersions -AllowPrerelease
if ($modules | Where-Object { $_.Version -eq $bcContainerHelperVersion }) {
if ($bcContainerHelperVersion -like "*preview*") {
Import-Module -Name BcContainerHelper -DisableNameChecking
}
else {
Import-Module -Name BcContainerHelper -RequiredVersion $bcContainerHelperVersion -DisableNameChecking
}
}
else {
if ($bcContainerHelperVersion -like "*preview*") {
Install-Module -Name BcContainerHelper -AllowPrerelease -Force
Import-Module -Name BcContainerHelper -Force -DisableNameChecking
}
else {
Install-Module -Name BcContainerHelper -RequiredVersion $bcContainerHelperVersion -Force
Import-Module -Name BcContainerHelper -RequiredVersion $bcContainerHelperVersion -Force -DisableNameChecking
}
}
}
catch {
$bcContainerHelperVersion = "https://github.com/microsoft/navcontainerhelper/archive/master.zip"
}
}
if ($bcContainerHelperVersion -like "https://*") {
Remove-Module BcContainerHelper -ErrorAction SilentlyContinue
#$tempName = Join-Path $env:TEMP $containerName
#Remove-Item $tempName -Recurse -Force -ErrorAction SilentlyContinue
#Remove-Item "$tempName.zip" -Force -ErrorAction SilentlyContinue
$tempName = $env:TEMP
Write-Host "Downloading $bcContainerHelperVersion"
#(New-Object System.Net.WebClient).DownloadFile($bcContainerHelperVersion, "$tempName.zip")
Invoke-Webrequest -Uri $bcContainerHelperVersion -OutFile "$tempName\BcContainerHelper.zip" -UseBasicParsing
Expand-Archive -Path "$tempName\BcContainerHelper.zip" -DestinationPath $tempName
$modulePath = (Get-Item (Join-Path $tempName "*\BcContainerHelper.psm1")).FullName
Write-Host $modulePath
Import-Module $modulePath -DisableNameChecking
}
}
finally {
$buildMutex.ReleaseMutex()
}
if ($genericImageName) {
$bcContainerHelperConfig.genericImageName = $genericImageName
}
I first switched to Invoke-WebRequest but I think that is not necessary anymore but I think there is a Problem with the removal of the TempName Folder ... after I commented that out it worked.
It's only a workaround but enough to get us trough the weekend hopefully.
When I go to look at the Hello World DevOps Repo for that change I keep getting kicked out for not having access to the resource. Did permission change in those Projects?
The project is public - but maybe devops want you to login?
I had the same thing... after unsuccessfully logging in with my O365 credentials I could at least access the Repos...
I do login and then get
{"$id":"1","innerException":null,"message":"TF400813: The user '72f988bf-86f1-41af-91ab-2d7cd011db47\matt@XXXX.com' is not authorized to access this resource.","typeName":"Microsoft.TeamFoundation.Framework.Server.UnauthorizedRequestException, Microsoft.TeamFoundation.Framework.Server","typeKey":"UnauthorizedRequestException","errorCode":0,"eventId":3000}
Azure DevOps has issues right now, I can't access organizations that I created myself and am very sure that I am administrator...
One of these days....:-(
TGIF ;)
Alternative source is enabled - https://bccontainerhelper.azureedge.net/public?restype=blob&comp=list Latest in PS Gallery is also here: https://bccontainerhelper.azureedge.net/public/latest.zip Latest preview in PS Gallery is also here: https://bccontainerhelper.azureedge.net/public/preview.zip
I have changed the way I install the containerhelper to always use the storage account. It is faster and I have more control over what's happening. https://dev.azure.com/businesscentralapps/_git/HelloWorld?path=%2Fscripts%2FInstall-BcContainerHelper.ps1
Describe the issue As of tonight the PSGallery is down for atleast 8 hours now and because of that all our pipelines are obviously failing during the Install-Navcontainer Task.
@freddydk I know that this is neither your fault nor your responsibility. And the responsible Team is apparently having a bad time with their CDN and are scrambling to get the Service back up. (https://github.com/PowerShell/PowerShellGallery/issues/135#issuecomment-719437957)
While we are trying to mitigate this issue in our own pipelines we were discussing multiple options (locally caching the Packages from PSGallery or checkout of this Repo in the Pipeline among others ), we were wondering if it would be possible for you to also provide the releases here on Github either as a Release or as Github Package or even both.
That would give us more options to use as the package source and would eliminate the PSGallery as the single point of failure that it apparently is (which we did not even see coming despite the recent availability issues https://github.com/PowerShell/PowerShellGallery/issues/132#issuecomment-704875043)
I thought I might as well just asked directly here although the issue is not directly related to BcContainerHelper. I hope that was ok?
Scripts used to create container and cause the issue
Full output of scripts