PowerShell / PSResourceGet

PSResourceGet is the package manager for PowerShell
https://www.powershellgallery.com/packages/Microsoft.PowerShell.PSResourceGet
MIT License
494 stars 93 forks source link

ACR repository authentication - non-interactively #1622

Open Gijsreyn opened 7 months ago

Gijsreyn commented 7 months ago

Summary of the new feature / enhancement

It's awesome to see the investment the PowerShell team is making, and I really love seeing ACR being added as private repository capabilities.

However, my instant thought came to rise, is it also possible to connect to ACR repository non-interactively? Such scenario will be extremely useful when automating tasks.

Proposed technical implementation details (optional)

No response

SydneyhSmith commented 7 months ago

We support the whole Azure Identity sdk which includes non-interactive options, we plan to write a doc about using it in automation in the future, for our CI we use workload identity federation https://learn.microsoft.com/en-us/dotnet/api/overview/azure/identity-readme?view=azure-dotnet#defaultazurecredential

adityapatwardhan commented 7 months ago

Also storing the Az Access Token in Secret Store before registering can be used for non-interactive scenarios. Please see the documentation at: https://learn.microsoft.com/en-us/powershell/gallery/powershellget/how-to/credential-persistence?view=powershellget-3.x#add-a-credential-to-a-psresourcerepository

Gijsreyn commented 7 months ago

Thanks for the quick responses @SydneyhSmith and @adityapatwardhan. I might have been a bit to fast and should have just tried it out or could have asked the question in the community call when you presented it. Anyway, will give it a go. Thanks once again!

adityapatwardhan commented 7 months ago

No worries. Let us know how it goes. Feedback is invaluable.

Gijsreyn commented 7 months ago

@adityapatwardhan It wasn't even needed. I created it through Azure DevOps using the SPN from the Azure PowerShell task. Shared it for others if they want to see it at: https://gijsreijn.medium.com/build-and-publish-your-powershell-modules-to-azure-container-registry-using-azure-devops-c5aac13b001d

image

SCOMnewbie commented 3 weeks ago

Hi @SydneyhSmith @adityapatwardhan, I see that the Az.accounts module is mandatory. Can we imagine providing an ACR access token directly instead of using this dependency? At the end of the day, you only use the Az.Accounts module to generate an ACR access token and use it when you try to access your ACR. Allowing a direct access token parameter that you will forward on your side will help people that don't want or simply can't use the Az.accounts module. Cheers

SydneyhSmith commented 3 weeks ago

@SCOMnewbie we are using Azure Identity directly so you are not tied to Az Accounts you can use any method in this article https://learn.microsoft.com/en-us/dotnet/api/overview/azure/identity-readme?view=azure-dotnet does that help?

Where are you seeing that Az.Accounts is mandatory?