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

Using Microsoft Container Registry as Trusted Package Management repository #1728

Open
3 tasks done
Gijsreyn opened this issue Oct 20, 2024 · 11 comments
Open
3 tasks done

Comments

@Gijsreyn
Copy link

Gijsreyn commented Oct 20, 2024

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

After Sydney's Trusted Package Management presentation during PSConfEU 2024 Minicon, I was curious to give it a try. Unfortunately, I'm stumbling on the following error message:

Install-PSResource: Repository 'mar' is not a known repository type that is supported. Please file an issue for support at https://github.com/PowerShell/PSResourceGet/issues

The steps to reproduce the issue:

  1. Run the following command: Register-PSResourceRepository -Name mar -Uri 'https://mcr.microsoft.com' -Trusted
  2. Install the module by running the following: Install-PSResource -Name Az.Accounts -Repository mar

The error message appears. Did I miss a step while registering or installing?

Expected behavior

Should install Az.Accounts module using MAR as repository.

Actual behavior

See description.

Error details

No response

Environment data

ModuleType Version    PreRelease Name                                ExportedCommands
---------- -------    ---------- ----                                ----------------
Binary     1.1.0      preview2   Microsoft.PowerShell.PSResourceGet  {Compress-PSResource, Find-PSResource, Get-Instal…

Key   : PSVersion
Value : 7.4.5
Name  : PSVersion


Key   : PSEdition
Value : Core
Name  : PSEdition


Key   : GitCommitId
Value : 7.4.5
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

@o-l-a-v
Copy link
Contributor

o-l-a-v commented Oct 21, 2024

Interesting. I found some more relevant resources:

I found that you can set ApiVersion to be ContainerRegistry (it was set to Unknown by default):

# Either when registering MCR
Register-PSResourceRepository -Name 'mcr' -Uri 'https://mcr.microsoft.com' -ApiVersion 'ContainerRegistry'

# Or after it has been registered
Set-PSResourceRepository -Name 'mcr' -ApiVersion 'ContainerRegistry'

It still does not work though.

PS > Find-PSResource -Repository 'mcr' -Name 'Az.Accounts' -Debug -Verbose

DEBUG: In FindPSResource::ProcessResourceNameParameterSet()
DEBUG: Filtering package name(s) on wildcards
DEBUG: In FindHelper::FindByResourceName()
DEBUG: Parameters passed in >>> Name: 'Az.Accounts'; ResourceType: 'None'; VersionRange: ''; NuGetVersion: ''; VersionType: 'NoVersion'; Version: ''; Prerelease: 'False'; Tag: ''; Repository: 'mcr'; IncludeDependencies 'False'
DEBUG: Searching through repository 'mcr'
DEBUG: In FindHelper::SearchByNames()
DEBUG: No version specified, package name is specified
DEBUG: In ContainerRegistryServerAPICalls::FindName()
DEBUG: In ContainerRegistryServerAPICalls::FindPackagesWithVersionHelper()
DEBUG: In ContainerRegistryServerAPICalls::GetContainerRegistryAccessToken()
DEBUG: In ContainerRegistryServerAPICalls::IsContainerRegistryUnauthenticated()
VERBOSE: Repository is unauthenticated
DEBUG: In ContainerRegistryServerAPICalls::GetContainerRegistryRefreshToken()
DEBUG: In ContainerRegistryServerAPICalls::GetHttpResponseJObjectUsingContentHeaders()
Find-PSResource: Unexpected character encountered while parsing value: <. Path '', line 0, position 0.

PS >

Using v1.1.0-preview2.

@Gijsreyn
Copy link
Author

Interesting. I found some more relevant resourves:

I found that you can set ApiVersion to be ContainerRegistry (it was set to Unknown by default):

# Either when registering MCR
Register-PSResourceRepository -Name 'mcr' -Uri 'https://mcr.microsoft.com' -ApiVersion 'ContainerRegistry'

# Or after it has been registered
Set-PSResourceRepository -Name 'mcr' -ApiVersion 'ContainerRegistry'

It still does not work though.

PS > Find-PSResource -Repository 'mcr' -Name 'Az.Accounts' -Debug -Verbose

DEBUG: In FindPSResource::ProcessResourceNameParameterSet()
DEBUG: Filtering package name(s) on wildcards
DEBUG: In FindHelper::FindByResourceName()
DEBUG: Parameters passed in >>> Name: 'Az.Accounts'; ResourceType: 'None'; VersionRange: ''; NuGetVersion: ''; VersionType: 'NoVersion'; Version: ''; Prerelease: 'False'; Tag: ''; Repository: 'mcr'; IncludeDependencies 'False'
DEBUG: Searching through repository 'mcr'
DEBUG: In FindHelper::SearchByNames()
DEBUG: No version specified, package name is specified
DEBUG: In ContainerRegistryServerAPICalls::FindName()
DEBUG: In ContainerRegistryServerAPICalls::FindPackagesWithVersionHelper()
DEBUG: In ContainerRegistryServerAPICalls::GetContainerRegistryAccessToken()
DEBUG: In ContainerRegistryServerAPICalls::IsContainerRegistryUnauthenticated()
VERBOSE: Repository is unauthenticated
DEBUG: In ContainerRegistryServerAPICalls::GetContainerRegistryRefreshToken()
DEBUG: In ContainerRegistryServerAPICalls::GetHttpResponseJObjectUsingContentHeaders()
Find-PSResource: Unexpected character encountered while parsing value: <. Path '', line 0, position 0.

PS >

Using v1.1.0-preview2.

Thanks for sharing Ivan. I didn't know that parameter could be used for it. I learned today :)

@o-l-a-v
Copy link
Contributor

o-l-a-v commented Oct 28, 2024

Thanks to PR #1737 I found a URL that lists tags for Az.Accounts:

And I think this should be the URL for the manifest of v2.12.1, but it gives an error:

@Gijsreyn
Copy link
Author

Thanks for the attentiveness @o-l-a-v. @adityapatwardhan Is this issue related to the PR?

@adityapatwardhan
Copy link
Member

The work for MAR as the artifact repository is not complete yet. More news coming soon
/cc @SydneyhSmith

@Gijsreyn
Copy link
Author

I'm a bit eager to test it out, so I validated with the latest changes that are merged from #1737. I can confirm it is working now. Thanks!

P.S. Is it needed to set the testhook?

@Gijsreyn
Copy link
Author

Gijsreyn commented Nov 4, 2024

@SydneyhSmith I was curious if there is a release planned to ship this feature.

@SydneyhSmith
Copy link
Collaborator

@Gijsreyn the latest release has the api support but we don't yet have any packages in MAR/MCR officially supported ...we are working with teams to get those in there but its a tough time of year right now with the holidays coming up etc. look forward to more progress soon!

@SydneyhSmith SydneyhSmith added this to 1.1 Nov 5, 2024
@SydneyhSmith SydneyhSmith added feature_request Resolution-Fixed Fixed the issue in latest release or PR labels Nov 5, 2024
@SydneyhSmith SydneyhSmith removed the Resolution-Fixed Fixed the issue in latest release or PR label Nov 7, 2024
@SydneyhSmith SydneyhSmith removed this from 1.1 Nov 7, 2024
@SydneyhSmith
Copy link
Collaborator

Moved to 1.2 because in future we will want to have MCR as a default registered trusted repo

@SydneyhSmith SydneyhSmith reopened this Nov 7, 2024
@alerickson
Copy link
Member

@SydneyhSmith this issue is just about MAR not working properly. I just opened an issue here: #1749 to track adding MCR as a default repo.

@Gijsreyn's issue should be resolved with the 1.1.0-RC2 release.

@Gijsreyn
Copy link
Author

Gijsreyn commented Nov 9, 2024

@alerickson Thanks for the heads-up.

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

5 participants