-
Notifications
You must be signed in to change notification settings - Fork 408
Fix Power Apps endpoints for government clouds #5404
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| using PnP.Framework; | ||
| using System; | ||
| using PnP.Framework; | ||
| using PnP.PowerShell.Commands.Utilities.REST; | ||
| using System.Linq; | ||
| using PnP.Framework.Diagnostics; | ||
|
|
@@ -26,6 +27,7 @@ public static string GetPowerAutomateEndpoint(AzureEnvironment environment) | |
| AzureEnvironment.USGovernmentHigh => "https://high.api.flow.microsoft.us", | ||
| AzureEnvironment.USGovernmentDoD => "https://api.flow.appsplatform.us", | ||
| AzureEnvironment.PPE => "https://api.flow.microsoft.com", | ||
| AzureEnvironment.BleuCloud or AzureEnvironment.DelosCloud or AzureEnvironment.GovSGCloud => throw GetUnsupportedPowerPlatformCloudException(environment), | ||
| _ => "https://api.flow.microsoft.com" | ||
| }; | ||
| } | ||
|
|
@@ -41,15 +43,37 @@ public static string GetPowerAppsEndpoint(AzureEnvironment environment) | |
| { | ||
| AzureEnvironment.Production => "https://api.powerapps.com", | ||
| AzureEnvironment.Germany => "https://api.powerapps.com", | ||
| AzureEnvironment.China => "https://api.powerautomate.cn", | ||
| AzureEnvironment.China => "https://api.powerapps.cn", | ||
| AzureEnvironment.USGovernment => "https://gov.api.powerapps.us", | ||
| AzureEnvironment.USGovernmentHigh => "https://high.api.powerapps.us", | ||
| AzureEnvironment.USGovernmentDoD => "https://api.apps.appsplatform.us", | ||
| AzureEnvironment.PPE => "https://api.powerapps.com", | ||
| AzureEnvironment.BleuCloud or AzureEnvironment.DelosCloud or AzureEnvironment.GovSGCloud => throw GetUnsupportedPowerPlatformCloudException(environment), | ||
| _ => "https://api.powerapps.com" | ||
| }; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Returns the audience URL for acquiring tokens for Power Apps APIs based on the Azure Environment | ||
| /// </summary> | ||
| /// <param name="environment">Azure Environment to indicate the type of cloud to target</param> | ||
| /// <returns>Audience URL for acquiring tokens for Power Apps APIs</returns> | ||
| public static string GetPowerAppsServiceEndpoint(AzureEnvironment environment) | ||
| { | ||
| return environment switch | ||
| { | ||
| AzureEnvironment.Production => "https://service.powerapps.com", | ||
| AzureEnvironment.Germany => "https://service.powerapps.com", | ||
| AzureEnvironment.China => "https://service.powerapps.cn", | ||
| AzureEnvironment.USGovernment => "https://gov.service.powerapps.us", | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I validated this against Microsoft sources and I don't think this change is correct. The current |
||
| AzureEnvironment.USGovernmentHigh => "https://high.service.powerapps.us", | ||
| AzureEnvironment.USGovernmentDoD => "https://service.apps.appsplatform.us", | ||
| AzureEnvironment.PPE => "https://service.powerapps.com", | ||
| AzureEnvironment.BleuCloud or AzureEnvironment.DelosCloud or AzureEnvironment.GovSGCloud => throw GetUnsupportedPowerPlatformCloudException(environment), | ||
| _ => "https://service.powerapps.com" | ||
| }; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Returns the BaseUrl for calling into the Business Applications APIs based on the Azure Environment | ||
| /// </summary> | ||
|
|
@@ -66,10 +90,16 @@ public static string GetBapEndpoint(AzureEnvironment environment) | |
| AzureEnvironment.USGovernmentHigh => "https://high.api.bap.microsoft.us", | ||
| AzureEnvironment.USGovernmentDoD => "https://api.bap.appsplatform.us", | ||
| AzureEnvironment.PPE => "https://api.bap.microsoft.com", | ||
| AzureEnvironment.BleuCloud or AzureEnvironment.DelosCloud or AzureEnvironment.GovSGCloud => throw GetUnsupportedPowerPlatformCloudException(environment), | ||
| _ => "https://api.bap.microsoft.com" | ||
| }; | ||
| } | ||
|
|
||
| private static NotSupportedException GetUnsupportedPowerPlatformCloudException(AzureEnvironment environment) | ||
| { | ||
| return new NotSupportedException($"Power Platform endpoints for AzureEnvironment '{environment}' are not currently documented or supported."); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Returns the default Power Platform environment | ||
| /// </summary> | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I validated this together with the endpoint mapping comment and I don't think
service.powerapps.usis the correct audience to add here. The first-party Power Apps admin module recognizesgov.api.powerapps.uswith thehttps://gov.service.powerapps.us/audience, and Microsoft Learn documents the same GCC resource URI. Keepinggov.service.powerapps.usclassified as PowerApps is therefore intentional.