-
Notifications
You must be signed in to change notification settings - Fork 99
Open
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
When leveraging the Publish-PSResource command using the Azure Artifacts Credential Provider, I'm getting an unauthorized (401) error. The command Find-PSResource works in the same session.
The steps that I tried:
$token = (Get-AzAccessToken -ResourceUrl "499b84ac-1321-427f-aa17-267ca6975798").Token | ConvertFrom-SecureString -AsPlainText
$repositoryName = 'AzureDevOps'
$repoUri = "https://pkgs.dev.azure.com/<organizationName>/<projectName>/_packaging/<repoName>/nuget/v3/index.json" # Replace with your own repository
$credObject = @{ endpointCredentials = @( @{ endpoint = $repoUri; password = $token })}
$env:VSS_NUGET_EXTERNAL_FEED_ENDPOINTS = $credObject | ConvertTo-Json -Compress
$registerSplat = @{
Name = $repositoryName
Uri = $repoUri
Trusted = $true
Force = $true
}
Register-PSResourceRepository @registerSplat
# test.psd1
@{
RootModule = 'test.psm1'
ModuleVersion = '1.0.0'
GUID = '59a9b25e-5c3a-444a-81f3-f038f9785bd8'
Author = 'Gijs Reijn'
Description = 'Simple test module for demonstration.'
PowerShellVersion = '7.0'
FunctionsToExport = @('TestFunction')
CmdletsToExport = @()
VariablesToExport = @()
AliasesToExport = @()
}
# test.psm1
function TestFunction {
[CmdletBinding()]
param()
Write-Output "TestFunction executed."
}
Publish-PSResource -Path test.psd1 -Repository AzureDevOps
I can see the Credential Provider kicking in. When uploading it with PAT and then use the Find command (without PAT), it finds the module.
Expected behavior
Able to use Azure Artifacts Credential Provider with Publish-PSResource
Actual behavior
Error occurs (401) unauthorized
Error details
Environment data
ModuleType Version PreRelease Name ExportedCommands
---------- ------- ---------- ---- ----------------
Binary 1.2.0 preview2 Microsoft.PowerShell.PSResourceGet {Compress-PSResource, Find-PSResource, Get-Instal…
Key : PSVersion
Value : 7.5.2
Name : PSVersion
Key : PSEdition
Value : Core
Name : PSEdition
Key : GitCommitId
Value : 7.5.2
Name : GitCommitId
Key : OS
Value : Microsoft Windows 10.0.26100
Name : OS
Key : Platform
Value : Win32NT
Name : Platform
Key : PSCompatibleVersions
Value : {1.0, 2.0, 3.0, 4.0…}
Name : PSCompatibleVersions
Key : PSRemotingProtocolVersion
Value : 2.3
Name : PSRemotingProtocolVersion
Key : SerializationVersion
Value : 1.1.0.1
Name : SerializationVersion
Key : WSManStackVersion
Value : 3.0
Name : WSManStackVersion
Visuals
No response