教程:创建跨租户隔离报告(预览版)
[本文为预发布文档,可能会发生变化。]
本教程演示了如何使用 Power Platform API(预览版)来创建跨租户隔离报告。
在本教程中,您将学习如何:
重要提示
- 这是一项预览功能。
- 预览功能不适合生产使用且功能可能受限。 这些功能在正式发布之前推出,以便客户可以提前使用并提供反馈。
- 在此功能预览期间,主机名和数据契约可能会更改。
- 有关租户隔离的更多详细信息,请参阅跨租户入站和出站限制。
步骤 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 脚本创建报告。
备注
每个日历日每个租户只能创建一份报告。
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 参考:列出跨租户连接报告