チュートリアル: クロス テナント分離レポートの作成 (プレビュー)

[この記事はプレリリース ドキュメントであり、変更されることがあります。]

このチュートリアルでは、Power Platform API (プレビュー) を使用して、クロス テナント分離レポート (プレビュー) を作成する方法について説明します。

このチュートリアルで学習する内容は次のとおりです:

  1. Power Platform API を使用して認証する
  2. レポートの作成
  3. テナントのすべてのレポートを一覧表示する
  4. 単一のレポートを取り込む

重要

  • これはプレビュー機能です。
  • プレビュー機能は運用環境での使用を想定しておらず、機能が制限される可能性があります。 これらの機能を公式リリースの前に使用できるようにすることで、顧客が一足先にアクセスし、そこからフィードバックを得ることができます。
  • この機能プレビュー期間中に、ホスト名とデータ コントラクトが変更される可能性があります。
  • テナント分離の詳細については、クロステナントの送受信の制限を参照してください。

ステップ 1. Power Platform API を使用して認証する

次の PowerShell スクリプトを使用して Power Platform API で認証する。

注意

グローバル管理者および Power Platform 管理者 Entra ID ロールを持つユーザーのみに、テナント分離影響レポートを実行する権限があります。

Import-Module "MSAL.PS"
$AuthResult = Get-MsalToken -ClientId '49676daf-ff23-4aac-adcc-55472d4e2ce0' -Scope 'https://api.powerplatform.com/.default'
$Headers = @{Authorization = "Bearer $($AuthResult.AccessToken)"}

ステップ 2. レポートの作成

次の PowerShell スクリプトを使用してレポートを作成する。

メモ

テナントごと、暦日ごとに 1 つのレポートのみ作成できます。

try 
{
    # Create a cross tenant connections report
    $tenantReportCreateResponse = Invoke-RestMethod -Method Post -Uri "https://api.powerplatform.com/governance/crossTenantConnectionReports?api-version=2022-03-01-preview" -Headers $Headers -Body ""
    $reportId = $tenantReportCreateResponse.reportId
    $reportStatus = $tenantReportCreateResponse.status

    Write-Host "Cross tenant connections report created with ID=$reportId and status=$reportStatus" 

} catch {
    # Dig into the exception to get the Response details.
    Write-Host "Response CorrelationId:" $_.Exception.Response.Headers["x-ms-correlation-id"]
    Write-Host "StatusCode:" $_.Exception.Response.StatusCode.value__ 
    Write-Host "StatusDescription:" $_.Exception.Response.StatusDescription
    $result = $_.Exception.Response.GetResponseStream()
        $reader = New-Object System.IO.StreamReader($result)
        $reader.BaseStream.Position = 0
        $reader.DiscardBufferedData()
        $responseBody = $reader.ReadToEnd();

        Write-Host $responseBody
}

Power Platform API 参照: クロステナント接続レポートの作成

ステップ 3. テナントのすべてのレポートを一覧表示する

次の PowerShell スクリプトを使用して、テナントで利用可能なすべてのレポートを一覧表示します。

try 
{
     # Get all available cross tenant connections reports for a tenant
    $tenantListReportResponse = Invoke-RestMethod -Method Get -Uri "https://api.powerplatform.com/governance/crossTenantConnectionReports?api-version=2022-03-01-preview" -Headers $Headers
    $report = $tenantListReportResponse | ConvertTo-Json -Depth 3 
    Write-Host $report 

} catch {
    # Dig into the exception to get the Response details.
    Write-Host "Response CorrelationId:" $_.Exception.Response.Headers["x-ms-correlation-id"]
    Write-Host "StatusCode:" $_.Exception.Response.StatusCode.value__ 
    Write-Host "StatusDescription:" $_.Exception.Response.StatusDescription
    $result = $_.Exception.Response.GetResponseStream()
        $reader = New-Object System.IO.StreamReader($result)
        $reader.BaseStream.Position = 0
        $reader.DiscardBufferedData()
        $responseBody = $reader.ReadToEnd();

        Write-Host $responseBody
}

Power Platform API 参照: クロステナント接続レポートの取得

ステップ 4. 単一のレポートを取り込む

次の PowerShell スクリプトを使用して、テナント内で使用される接続に関するテナントの単一レポートを取得します。

try 
{
   # Get one cross tenant connections report for a tenant
    $tenantListReportResponse = Invoke-RestMethod -Method Get -Uri "https://api.powerplatform.com/governance/crossTenantConnectionReports/{$reportId}?api-version=2022-03-01-preview" -Headers $Headers
    $report = $tenantListReportResponse | ConvertTo-Json -Depth 2 
    Write-Host $report
    Write-Host "" 

} catch {
    # Go through the exception to get the Response details.
    Write-Host "Response CorrelationId:" $_.Exception.Response.Headers["x-ms-correlation-id"]
    Write-Host "StatusCode:" $_.Exception.Response.StatusCode.value__ 
    Write-Host "StatusDescription:" $_.Exception.Response.StatusDescription
    $result = $_.Exception.Response.GetResponseStream()
        $reader = New-Object System.IO.StreamReader($result)
        $reader.BaseStream.Position = 0
        $reader.DiscardBufferedData()
        $responseBody = $reader.ReadToEnd();

        Write-Host $responseBody
}

Power Platform API 参照: クロス テナント接続レポートの一覧表示

関連項目

Power Platform API 参照 - クロス テナント接続レポートの一覧表示