-
Notifications
You must be signed in to change notification settings - Fork 100
Closed
Labels
Description
Prerequisites
- 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_