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

Connect-PnPOnline Azure Environment Discovery from URI Support #2533

Closed
BernieEllis opened this issue Nov 7, 2022 · 4 comments · Fixed by #2925
Closed

Connect-PnPOnline Azure Environment Discovery from URI Support #2533

BernieEllis opened this issue Nov 7, 2022 · 4 comments · Fixed by #2925
Labels
enhancement New feature or request

Comments

@BernieEllis
Copy link

BernieEllis commented Nov 7, 2022

Is your feature request related to a problem? Please describe.
Yes, I'm trying to use PnP PowerShell in a Microsoft national cloud other than Azure Government/GCC High/DoD. The issue is that the Azure environments PnP is designed to work with are limited, therefore I have no way of instructing which Azure AD, Microsoft Graph, and other endpoints it should use to connect to.

Describe the solution you'd like
Continue allowing customers to specify environments like GCC, GCC High, and DoD but also allow Connect-PnPOnline to connect via the discovery pattern shown above, allowing customers in additional Microsoft cloud environments beyond what's currently in src/sdk/PnP.Core/Services/Core/CloudManager.cs to leverage the PnPPowerShell platform for management and automation.

Connect-PnPOnline, could do one of two things:

Honor the environments discovered by Add-AzEnvironment.
Add a new PnPOnline cmdlet to prepare the environment to pass to Connect-PnPOnline
For the second, thinking something like:

Add-PnPOnlineEnvironment -FromUrl https://management.azure.com/metadata/endpoints?api-version=2020-06-01
Connect-PnPOnline -Environment DiscoveredAzureEnvironment

Additional cmdlets, specifically Register-PnPManagementShellAccess and Register-PnPAzureADApp should pick up support from the additional environment support.

Describe alternatives you've considered
We are currently exploring using Microsoft Graph as an alternative, but there are two issues:

  1. We are not yet able to use Connect-MgGraph in this other national cloud.
  2. I'm not sure yet if we have a 100% mapping from PnP PowerShell cmdlets to Microsoft Graph cmdlets we intend to use. In particular, not sure if these cmdlets have Microsoft Graph PowerShell equivalents despite reviewing the documentation:
  • Register-PnPHubSite
  • Unregister-PnpHubsite
  • Add-PnPSiteCollectionAppCatalog
  • Remove-PnPSiteCollectionAppCatalog
  • Add-PnPHubToHubAssociation
  • Get-PnPHubSite
  • Add-PnPSiteCollectionAdmin

Additional context
Microsoft has additional Azure/O365 cloud environments beyond GCC High and DoD. For this reason, Microsoft has added environment discovery capability to Azure PowerShell via Discovering a new Azure environment via Uri using the Add-AzEnvironment cmdlet I can discover an environment via URL to retrieve the appropriate Graph, Azure AD, etc. endpoints for making calls, which is then used to specify as the environment when connecting with Connect-AzAccount.

Connect-PnPOnline, should allow customers to use PnPPowerShell ideally in the same manner:

Add-AzEnvironment -Autodiscover -Url https://management.azure.com/metadata/endpoints?api-version=2020-06-01 (What's returned will be different endpoints for each environment)
Connect-AzEnvironment -Environment DiscoveredAzureEnvX

@BernieEllis
Copy link
Author

PowerShell team, after making a similar request to PnPCore @jansenbe made the following commit last week: pnp/pnpcore@e818ffc.

It's different from what we suggested but looks to address the issue. Can the PowerShell team help adopt this same model if agreed or give thoughts on the discover from Uri pattern?

Thanks,
Bernarldo

@KoenZomers
Copy link
Collaborator

I guess we could do a similar thing like Bert did, but it will cost quite some hours to implement and test. Since this is a request from longer ago, are you still in need of this or have you found another way? In other words: is this still needed?

@BernieEllis
Copy link
Author

BernieEllis commented Jan 22, 2023 via email

gautamdsheth added a commit that referenced this issue Jul 25, 2023
Feature #2533: added support for custom Azure environments endpoints
@gautamdsheth
Copy link
Collaborator

gautamdsheth commented Jul 25, 2023

Hi @BernieEllis , finally managed to get it working.

It will now work starting with tomorrow's nightly build and the next major version whenever we release it. Will have to specify MicrosoftGraphEndpoint and AzureADLoginEndpoint parameters if you want it working.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants