Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]: AzurePowerShell@5 is failing to install Az modules #19890

Closed
5 of 7 tasks
RickKra opened this issue May 20, 2024 · 10 comments
Closed
5 of 7 tasks

[BUG]: AzurePowerShell@5 is failing to install Az modules #19890

RickKra opened this issue May 20, 2024 · 10 comments

Comments

@RickKra
Copy link
Member

RickKra commented May 20, 2024

New issue checklist

Task name

AzurePowerShell

Task version

5.239.11

Issue Description

For these 3 builds:

We got this, before our script even had a chance to run:

##[error]Package 'Az.Resources' failed to be installed because: End of Central Directory record could not be found.

For this build:

We got this, also before our script could run:

##[error]No match was found for the specified search criteria and module name 'Az.Accounts'. Try Get-PSRepository to see all available registered module repositories.

This problem is intermittent.

Environment type (Please select at least one enviroment where you face this issue)

  • Self-Hosted
  • Microsoft Hosted
  • VMSS Pool
  • Container

Azure DevOps Server type

dev.azure.com (formerly visualstudio.com)

Azure DevOps Server Version (if applicable)

No response

Operation system

Windows Server 2019

Relevant log output

2024-05-20T19:33:33.7381204Z ##[section]Starting: Layout BuildArtifacts
2024-05-20T19:33:33.7385860Z ==============================================================================
2024-05-20T19:33:33.7385963Z Task         : Azure PowerShell
2024-05-20T19:33:33.7386023Z Description  : Run a PowerShell script within an Azure environment
2024-05-20T19:33:33.7386103Z Version      : 5.239.11
2024-05-20T19:33:33.7386150Z Author       : Microsoft Corporation
2024-05-20T19:33:33.7386207Z Help         : https://aka.ms/azurepowershelltroubleshooting
2024-05-20T19:33:33.7386274Z ==============================================================================
2024-05-20T19:33:34.4791927Z Generating script.
2024-05-20T19:33:34.5074276Z ========================== Starting Command Output ===========================
2024-05-20T19:33:34.5291831Z ##[command]"C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command ". 'D:\a\_work\_temp\9d1676c0-d557-4875-81bb-3183c4e21c06.ps1'"
2024-05-20T19:33:35.4260872Z WARNING: String format failed.
2024-05-20T19:33:35.5239926Z ##[warning]Failed to Initialize Existing Az modules, fallback to installation
2024-05-20T19:33:35.5386423Z ##[command]Install-Module -Name Az.Accounts -Force -AllowClobber -ErrorAction Stop SkipPublisherCheck
2024-05-20T19:34:55.4908950Z ##[command]Import-Module -Name C:\Program Files\WindowsPowerShell\Modules\Az.Accounts\2.19.0\Az.Accounts.psd1 -Global -PassThru -Force
2024-05-20T19:34:56.6503461Z Imported module 'Az.Accounts', version: 2.19.0
2024-05-20T19:34:56.6564439Z ##[command]Update-AzConfig -DisplayBreakingChangeWarning False -AppliesTo Az
2024-05-20T19:34:56.8400777Z ##[command]Enable-AzureRmAlias -Scope Process
2024-05-20T19:34:57.5691157Z ##[command]Install-Module -Name Az.Resources -Force -AllowClobber -ErrorAction Stop SkipPublisherCheck
2024-05-20T19:38:55.9972009Z ##[error]Package 'Az.Resources' failed to be installed because: End of Central Directory record could not be found.
2024-05-20T19:38:56.0432033Z ##[error]Failed to Install Az modules
2024-05-20T19:38:56.1289362Z ##[error]PowerShell exited with code '1'.
2024-05-20T19:38:57.2853993Z ##[command]Disconnect-AzAccount -Scope CurrentUser -ErrorAction Stop
2024-05-20T19:38:57.3962503Z ##[command]Disconnect-AzAccount -Scope Process -ErrorAction Stop
2024-05-20T19:38:57.4056340Z ##[command]Clear-AzContext -Scope Process -ErrorAction Stop
2024-05-20T19:38:57.5543188Z ##[section]Finishing: Layout BuildArtifacts

Full task logs with system.debug enabled

We don't have full task logs with system.debug enabled.

Repro steps

- task: AzurePowerShell@5
          displayName: Layout BuildArtifacts
          inputs:
            azureSubscription: 'VSEngCloudBuildAPI'
            workingDirectory: '$(Build.SourcesDirectory)'
            ScriptPath: 'src\Scripts\CB-BuildArtifacts.ps1'
            ScriptArguments: '-AccessToken $(System.AccessToken) -ReservedVersion $(ReservedVersion) -NugetPackageDirectory $(PackageDirectory) -ArtifactPublishDirectory $(ArtifactPublishDirectory) -DownloadDirectory $(DownloadDirectory) -VstsDropMetadataDownloadDirectory $(DropMetadataDirectory) -SourcesDirectory $(Build.SourcesDirectory) -BuildArtifactsJson $(BuildArtifactsJson)'
            azurePowerShellVersion: LatestVersion
          condition: succeeded()
@v-schhabra
Copy link
Contributor

@RickKra Could you please install Az and Az.Accounts module externally and check if task works fine or not?

@RickKra
Copy link
Member Author

RickKra commented May 22, 2024

@v-schhabra it's a complex pipeline building a production app, so I can't change it quickly and easily. Can you not fix the task?

@v-schhabra
Copy link
Contributor

v-schhabra commented May 28, 2024

@RickKra I observed that now the task is working fine for you without any issues.
Could you please update if the issue is fixed or not?
https://devdiv.visualstudio.com/DevDiv/_build/results?buildId=9639822&view=logs&j=dba4eab8-d390-5c78-738f-db7f79514c75&t=c65817ea-71c0-54c4-1fb8-aa7f6abad7a3

@RickKra
Copy link
Member Author

RickKra commented May 29, 2024

@v-schhabra it only happened 4 times for us. I created the bug in case it happened more.

Any way you can look into why it happened and either add retries or something to prevent future occurrences?

@dimpatel-MSFT
Copy link

@v-schhabra
Copy link
Contributor

@dimpatel-MSFT Could you pls enable debug logs for the pipeline?

@v-schhabra v-schhabra added the Area:RM RM task team label May 31, 2024
@v-schhabra
Copy link
Contributor

Hi @dimpatel-MSFT
Thanks for sharing the logs. We are investigating your issue and will share the updates soon.

@v-schhabra
Copy link
Contributor

The above error may be caused by the PowerShell NuGet package provider not being installed in 1ES agents.
https://microsoft.github.io/PSRule/v2/troubleshooting/#windows-powershell-is-in-noninteractive-mode
As a workaround we suggested @dimpatel-MSFT to install the Nuget packages through Azure Powershell or Powershell task and this works fine for her.
For the permanent fix we are working with 1ES Hosted agent team and will post the latest updates here.

@v-schhabra
Copy link
Contributor

Closing this out as issue is mitigated. Please raise the new request incase you face any new issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants