Skip to content

Support for National Clouds #357

Closed

Description

@georgend

Microsoft Graph has 5 National Clouds with variations in supported features. To be able to use msgraph-sdk-powershell we need to provide config choices allowing users to specify and/or switch Cloud environments as needed.
Suggested Changes
Add a new -Cloud parameter to Connect-Graph where -Cloud can be Global, US_GOV, US_DOD, China, Germany. This parameter will be optional and will default to Global This will switch the Endpoint used by the cmdlets to the corresponding Cloud Environments and Azure AD Endpoint as detailed below.
MSAL already has baked in support for different AD endpoints for the different National Clouds. Then pass the configured endpoint to MSAL (PublicClient|ConfidentialClient)ApplicationBuilders. through the WithAuthority() method overloads

Value
Cloud Name
Microsoft Graph Root Endpoint
Azure AD Endpoint

Global
Microsoft Graph global service
https://graph.microsoft.com
https://login.microsoftonline.com

US_GOV
Microsoft Graph for US Government L4
https://graph.microsoft.us
https://login.microsoftonline.us

US_DOD
Microsoft Graph for US Government L5 (DOD)
https://dod-graph.microsoft.us
https://login.microsoftonline.us

Germany
Microsoft Graph Germany
https://graph.microsoft.de
https://login.microsoftonline.de

China
Microsoft Graph China operated by 21Vianet
https://microsoftgraph.chinacloudapi.cn
https://login.chinacloudapi.cn

Add a new cmdlet Get-MgEnvironment that returns the above table of Values and Endpoints.
Add a new cmdlet to Set-MgEnvironment that sets the environment for the current session.
Set-MgEnvironment -Cloud US_GOV
To allow connecting to arbitrary clouds, users can pass the following parameters:-
Set-MgEnvironment -GraphEndpoint -AzureAdEndpoint
Connect-Graph -GraphEndpoint -AzureAdEndpoint ...other Connect-Graph parameters
ClientId parameter on Connect-Graph will also be a UserParameterSet
Update Invoke-GraphRequest to take -Cloud parameter.
Issues
AutoRest Powershell hardcodes the Url to be invoked in the cmdlets, that means we need to add a DelegatingHandler to rewrite the URL based on passed in endpoints.
cc DeVere Dyett (@ddyett) Darrel (@darrelmiller)
Related to #311, #93, #283
AB#5989

Activity

  1. ghost removed on Sep 1, 2020
  2. added this to the 1.0 GA milestone on Sep 1, 2020
  3. ddyett commented on Sep 1, 2020

    @ddyett
    Contributor

    is any work needed in the token caching layer to support this? Would Set-MgEnvironment clear caches for example?

  4. ddyett commented on Sep 1, 2020

    @ddyett
    Contributor

    Is there any scenario under which the baseurl should be passed in directly?

  5. georgend commented on Sep 1, 2020

    @georgend
    ContributorAuthor

    Is there any scenario under which the baseurl should be passed in directly?

    I do not see such a scenario since we know all the clouds.

  6. georgend commented on Sep 1, 2020

    @georgend
    ContributorAuthor

    is any work needed in the token caching layer to support this? Would Set-MgEnvironment clear caches for example?

    Yes, we can offer this option. and trigger auth as well.

  7. darrelmiller commented on Sep 2, 2020

    @darrelmiller
    Contributor

    finsharp There are more clouds. I think we should have an option to "bring your own" graph baseUrl and Auth Server URL.

    We should not try and base feature availability on what is in that doc page. More automated methods of cloud availability are coming and we should wait for that. All clouds should have the same set of cmdlets for the moment. This is how we handle all other SDKs currently.

  8. georgend commented on Sep 2, 2020

    @georgend
    ContributorAuthor

    finsharp There are more clouds. I think we should have an option to "bring your own" graph baseUrl and Auth Server URL.

    We should not try and base feature availability on what is in that doc page. More automated methods of cloud availability are coming and we should wait for that. All clouds should have the same set of cmdlets for the moment. This is how we handle all other SDKs currently.

    We can add those as parameters to the Set-Environment cmdlet, as a special parameter set to manage the different parameters sets.

  9. 7 remaining items

  10. peombwa commented on Sep 17, 2020

    @peombwa
    Member

    Invoke-GraphRequest should also support national clouds. Making a request to a national cloud using Invoke-GraphRequest yields the following error:

    Invoke-GraphRequest -Uri "https://graph.microsoft.de/beta/me" -Debug
    Invoke-GraphRequest: The pipeline has been stopped.
    Invoke-GraphRequest: Invalid Host graph.microsoft.de

    It looks like we are comparing the client's host uri to the request message uri's before sending a request. https://github.com/microsoftgraph/msgraph-sdk-powershell/blob/dev/src/Authentication/Authentication/Cmdlets/InvokeGraphRequest.cs#L859.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions