Fail to get packages from azure devops artifacts repo
See original GitHub issuePrerequisites
- Write a descriptive title.
- Make sure you are able to repro it on the latest released version
- Search the existing issues.
Steps to reproduce
I fail to successfully search for packages from my azure devops artifacts repo. Somehow it worked for a minute, but upon trying how the Install-Module commands would interact/mix with the Install-PSResource commands, things started to go nuts and I cannot recreate a working environment. I have also set up a new clean win11 vm on Azure, just to make sure there is no residual config on my machine. But alas, same result. I must be missing something.
The steps I took were:
Install-Module PowershellGet -AllowPrerelease -Repository psgallery -force
#### <RESTART TERMINAL>
Install-PSResource Microsoft.PowerShell.SecretManagement -Repository psgallery
Install-PSResource Microsoft.PowerShell.SecretStore -Repository psgallery
#### <RESTART TERMINAL>
Register-SecretVault -Name SecretStore -ModuleName Microsoft.PowerShell.SecretStore -DefaultVault
$patToken = "MY PAT TOKEN" | ConvertTo-SecureString -AsPlainText -Force
$devopsCreds = New-Object System.Management.Automation.PSCredential("something", $patToken)
Set-Secret -Name devopsCreds -Secret $devopsCreds
#### If it's first run, the password for the store will be requested here
$credsAzureDevopsServices = New-Object Microsoft.Powershell.PowershellGet.UtilClasses.PSCredentialInfo("SecretStore", "devopsCreds")
On the clean VM I hit a little snag here, easily fixed.
### <On the azure VM, I had to Import-Module PowershellGet first>
PS C:\Users\myuserrocks> $credsAzureDevopsServices = New-Object Microsoft.Powershell.PowershellGet.UtilClasses.PSCredentialInfo("SecretStore", "devopsCreds")
New-Object: Cannot find type [Microsoft.Powershell.PowershellGet.UtilClasses.PSCredentialInfo]: verify that the assembly containing this type is loaded.
PS C:\Users\myuserrocks> Import-Module PowershellGet
Then I could continue:
PS C:\Users\myuserrocks> $credsAzureDevopsServices = New-Object Microsoft.Powershell.PowershellGet.UtilClasses.PSCredentialInfo("SecretStore", "devopsCreds")
Register-PSResourceRepository -name MYORG -Uri "https://pkgs.dev.azure.com/MYORG/_packaging/MYREPO/nuget/v3/index.json" -Trusted -CredentialInfo $credsAzureDevopsServices
Find-PSResource 'dv.ifx.' -Repository MYORG
### FAILS HERE
I also tried with the V2 repo:
Set-PSResourceRepository -name MYORG -Uri "https://pkgs.dev.azure.com/MYORG/_packaging/MYREPO/nuget/v2" -Trusted -CredentialInfo $credsAzureDevopsServices
For completeness sake, I also tried with the old style credentials, that was necessary in the V2:
$patRaw = "MYPAT"
$oldSecret = '{"endpointCredentials": [{"endpoint":"https://pkgs.dev.azure.com/MYORG/_packaging/MYREPO/nuget/v2", "username":"OPTIONAL", "password":"' + $patRaw + '" }]}' | ConvertTo-SecureString -AsPlainText -Force
$devopsCreds = New-Object System.Management.Automation.PSCredential("something", $oldSecret)
Set-Secret -Name devopsCreds -Secret $devopsCreds
The PSResourceRepository.Xml file looks fine to me:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<Repository Name="PSGallery" Url="https://www.powershellgallery.com/api/v2" Priority="50" Trusted="false" />
<Repository Name="MYORG" Url="https://pkgs.dev.azure.com/MYORG/_packaging/MYREPO/nuget/v3/index.json" Priority="50" Trusted="true" VaultName="SecretStore" SecretName="devopsCreds" />
</configuration>
Expected behavior
Find-PSResource to show me the packages on my Azure Artifacts repo.
And consequently, Install-PSResource to install the package of my choosing.
Actual behavior
Error I'm getting for v3:
VERBOSE: Error retrieving resource from repository: Unable to load the service index for source https://pkgs.dev.azure.com/MYORG/_packaging/MYREPO/nuget/v3/index.json. ```
Error I'm getting for v2:
``` VERBOSE: FindHelper MetadataAsync: error receiving package: Failed to fetch results from V2 feed at 'https://pkgs.dev.azure.com/MYORG/_packaging/MYREPO/nuget/v2/FindPackagesById()?id='dv.ifx.'&semVerLevel=2.0.0' with following message : Response status code does not indicate success: 401 (Unauthorized). ```
Error details
No response
Environment data
Versions:
ModuleType Version PreRelease Name ExportedCommands
---------- ------- ---------- ---- ----------------
Binary 3.0.14 beta14 PowerShellGet {Find-PSResource, Get-PSResource, Get-PSResourceRepository, Install-PSResource…}
Binary 1.1.2 Microsoft.PowerShell.SecretManagem… {Get-Secret, Get-SecretInfo, Get-SecretVault, Register-SecretVault…}
Binary 1.0.6 Microsoft.PowerShell.SecretStore {Get-SecretStoreConfiguration, Reset-SecretStore, Set-SecretStoreConfiguration, Set-SecretStorePassword…}
### Visuals
_No response_
Issue Analytics
- State:
- Created a year ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Azure Artifacts fails to provide package
We use our own Azure Artifacts instance to provide a private Nuget feed. It has a default setup, with the @Local view as...
Read more >Azure Artifacts fails to get a package while using an ...
I'm trying to use Maven Central as an upstream source for Maven, but it's failing with org.sonatype.sisu.inject:guice-parent:pom:2.9.1:.
Read more >Unable to install packages from Azure DevOps private repo ...
I am trying to install from an Azure DevOps Artifacts Python feed. I can publish to the feed if I use the following:...
Read more >Restore NuGet packages in Azure Pipelines
Restore NuGet packages ... Navigate to your pipeline definition and select the NuGet restore task. Make sure you're using version 2 of the...
Read more >Package Management with Azure Artifacts
Azure Artifacts is an extension that makes it easy to discover, install, and publish NuGet, npm, and Maven packages in Azure DevOps.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
No real issues found. Everything went smooth. People were a bit concerned about documentation still using the old version commands. And the lack of wildcard searching.
But that was about it. good job!
As meticulous as I did my testing, I must’ve made a copy paste error somehow. I refreshed my PAT, just to be sure. Re-registered it. And all is working fine now.
The old commands are gone now as well, so no messing up with install-module or something else anymore. I’ll be rolling this out in my team this week. Thank you for following up!