Tutorial: Create cross-tenant isolation reports

This tutorial demonstrates how to use the programmability tools to create cross-tenant isolation reports. A cross-tenant connection report shows the external tenants that connections in your tenant reach, or that reach into your tenant. Use these reports to identify the tenants to add to your allow list before you restrict cross-tenant connections. For more information about tenant isolation, see Cross-tenant inbound and outbound restrictions.

In this tutorial, learn how to:

  • Sign in
  • Create a report
  • List all reports for the tenant
  • Fetch a single report
  • Understand what the report contains
  • Locate the environment for a reported connection

Prerequisites

  • An account with an admin role for your tenant, such as Power Platform administrator. The cross-tenant connection report endpoints don't support role-based access control (RBAC) in the Power Platform admin center. For more information, see Known limitations.
  • To use Power Automate or Azure Logic Apps, a connection to the Power Platform for Admins V2 connector.
  • To use the Power Platform CLI or PowerShell, the latest version of the Microsoft Power Platform CLI. The PowerShell scripts use it to get an access token.
  • To use PowerShell, PowerShell 7 or Windows PowerShell 5.1.
  • To use the C# or Python SDK, an app registration configured for the Power Platform API and the SDK package for your language:

Sign in

Sign in before you create or fetch reports. If you use Power Automate or Azure Logic Apps, skip this section. The connector uses the connection that you created.

Note

The pac governance commands that this tutorial uses are in preview.

Create an authentication profile, and sign in with your admin account. The pac governance commands in this tutorial use the selected authentication profile.

pac auth create

If you already have authentication profiles, run pac auth list to view them, and then run pac auth select --index <index> to select the profile for your tenant. For more information, see pac auth.

To sign in as a service principal, or to learn more about app registrations, see Authentication.

Create a report

Create a report for your tenant by using Power Automate, Azure Logic Apps, the Power Platform CLI, PowerShell, or the C# or Python SDK.

Note

You can create one report per tenant per calendar day. If your tenant already has a report for the current day, the request returns that report instead of creating a new one.

Use the following command to create the report.

pac governance create-cross-tenant-connection-report

Power Platform CLI reference: pac governance create-cross-tenant-connection-report

Save the reportId value. You use it to fetch the report later in this tutorial.

List all reports for the tenant

List the reports for your tenant to find report IDs and check the status of each report.

Use the following command to list all available reports for your tenant. To choose the columns in the table output, add --columns with a comma-separated list of response properties, such as --columns reportId,status,startDate,endDate.

pac governance list-cross-tenant-connection-reports

Power Platform CLI reference: pac governance list-cross-tenant-connection-reports

Fetch a single report

Reports are generated asynchronously. A new report starts with a status of Received or InProgress, and its connections are available after its status changes to Completed. If the status is still Received or InProgress, wait, and then fetch the report again. If the status is Failed, create the report again later.

Use the following command to fetch a single report for your tenant. Replace <report-id> with the reportId value from the create or list step. To see the complete response, including the connections array, add --json.

pac governance get-cross-tenant-connection-report --report-id "<report-id>"

Power Platform CLI reference: pac governance get-cross-tenant-connection-report

Understand what the report contains

Each report includes the following properties:

  • reportId: the identifier of the report.
  • status: the generation status of the report: Received, InProgress, Completed, or Failed.
  • requestDate: the date when the report was requested.
  • startDate and endDate: the reporting window that the report covers.
  • connections: the cross-tenant connections observed during the reporting window.
  • @odata.nextLink: when present, the URL of the next page of connections in the report.

Every entry in the connections array describes a cross-tenant connection and includes:

  • tenantId: the external tenant that the connection reaches.
  • connectionType: the direction of the connection, either outbound (from your tenant to the external tenant) or inbound.
  • connectionId: the identifier of the connection. This value matches the connection's name (the last segment of the connection's resource ID) in the environment where the connection lives.

Note

The report logs cross-tenant connection attempts observed during the reporting window, not only connections that currently exist. The report includes attempts that were blocked by tenant isolation on your tenant or on the target tenant. As a result, a connectionId in the report might not correspond to a connection that exists in any of your environments today. You can't locate blocked connection attempts (and connections that were later deleted) by using the steps in the next section.

Locate the environment for a reported connection

A report identifies each connection by connectionId, but it doesn't include the environment where the connection lives. To find the environment, enumerate the environments in your tenant, list each environment's connections, and match on the connection name.

Use the following PowerShell script to search your environments for a reported connectionId. The script uses the variables from the PowerShell sign-in script. Enumerate your environment IDs however you prefer—for example, from the Power Platform admin center—and provide the connectionId values from the report. The script ignores hyphens and letter case when it compares values, so differences in identifier formatting don't prevent a match.

# The connectionId values from the report that you fetched earlier.
# To search for every connection in that report, use: $reportConnectionIds = $connections.connectionId | Select-Object -Unique
$reportConnectionIds = @('<connection-id-1>', '<connection-id-2>')

# The environments in your tenant to search.
$environmentIds = @('<environment-id-1>', '<environment-id-2>')

foreach ($environmentId in $environmentIds)
{
    try
    {
        # List the connections in the environment.
        $uri = "$apiBaseUrl/connectivity/environments/$environmentId/connections?api-version=$apiVersion"
        $environmentConnections = (Invoke-RestMethod -Method Get -Uri $uri -Headers $headers).value

        foreach ($connectionId in $reportConnectionIds)
        {
            # The report's connectionId matches the end of the connection's 'name'.
            $normalizedId = $connectionId -replace '-', ''
            $matchingConnections = $environmentConnections | Where-Object { ($_.name -replace '-', '') -like "*$normalizedId" }
            foreach ($connection in $matchingConnections)
            {
                Write-Host "connectionId $connectionId is in environment $environmentId (connector: $($connection.properties.apiId), display name: $($connection.properties.displayName))"
            }
        }
    }
    catch
    {
        Write-Host "Couldn't list connections for environment ${environmentId}: $($_.Exception.Message)"
    }
}

If a reported connectionId isn't found in any environment, it was most likely a blocked attempt (see the previous note) or a connection that was deleted after the report was generated.

Power Platform API reference: List connections in an environment