ArcGIS Pro 3.4 API Reference Guide
ArcGIS.Desktop.Core Namespace / ArcGISPortalManager Class / GetActivePortal Method
Example Version

GetActivePortal Method
Get the currently active portal. This is the portal that has been set as the Active Portal either via the API or on the "Portals" backstage tab.
Syntax
public ArcGISPortal GetActivePortal()

Return Value

Remarks
If an active portal has never been set then, by default, the active portal will be ArcgisOnline
Example
ArcGISPortalManager: Get the Current Active Portal
var active_portal = ArcGISPortalManager.Current.GetActivePortal();
string uri = active_portal.PortalUri.ToString();
Requirements

Target Platforms: Windows 11, Windows 10

ArcGIS Pro version: 3 or higher.
See Also