Repository navigation
Description
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
ddyett commentedon Sep 1, 2020
is any work needed in the token caching layer to support this? Would Set-MgEnvironment clear caches for example?
ddyett commentedon Sep 1, 2020
Is there any scenario under which the baseurl should be passed in directly?
georgend commentedon Sep 1, 2020
I do not see such a scenario since we know all the clouds.
georgend commentedon Sep 1, 2020
Yes, we can offer this option. and trigger auth as well.
darrelmiller commentedon Sep 2, 2020
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.
georgend commentedon Sep 2, 2020
We can add those as parameters to the
Set-Environmentcmdlet, as a special parameter set to manage the different parameters sets.7 remaining items
peombwa commentedon Sep 17, 2020
Invoke-GraphRequest should also support national clouds. Making a request to a national cloud using
Invoke-GraphRequestyields the following error: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.