Power BI Collection迁移至Embedded后旧API方法可用性及替代方案咨询
First off, the short answer: your old Workspace Collection-specific API methods are no longer supported, and they'll stop working entirely once Workspace Collections are retired. You'll need to migrate to the modern Power BI Embedded API (based on the workspace model) using the latest NuGet packages.
Let's break down replacements for each of your existing calls, plus key migration notes:
API Method Replacements
All new methods target a workspace ID (instead of the old workspaceCollection + workspaceId pair) and are part of the updated PowerBIClient from the latest Microsoft.PowerBI.Api package.
| Old Method | New Replacement |
|---|---|
client.Reports.GetReportsAsync(this.workspaceCollection, this.workspaceId) | client.Reports.GetReportsInGroupAsync(workspaceId) |
client.Reports.DeleteReportAsync(this.workspaceCollection, this.workspaceId, report.Id) | client.Reports.DeleteReportInGroupAsync(workspaceId, report.Id) |
client.Imports.PostImportFileWithHttpMessage(this.workspaceCollection,this.workspaceId,File.OpenRead(localPath), "Main Report") | client.Imports.PostImportFileInGroupWithHttpMessageAsync(workspaceId, File.OpenRead(localPath), "Main Report") |
client.Datasets.GetGatewayDatasourcesAsync(workspaceCollection, workspaceId, dataset.Id) | client.Datasets.GetGatewayDatasourcesInGroupAsync(workspaceId, dataset.Id) |
client.Gateways.PatchDatasourceAsync(workspaceCollection,workspaceId,datasources.Value[0].GatewayId,datasources.Value[0].Id, delta) | client.Gateways.PatchDatasourceInGroupAsync(workspaceId, gatewayId, datasourceId, delta) |
client.Datasets.GetDatasetsAsync(workspaceCollection, workspaceId) | client.Datasets.GetDatasetsInGroupAsync(workspaceId) |
Critical Migration Notes
Update NuGet Packages
- Replace
Microsoft.PowerBI.Apiandpowerbi.corewith the latest version ofMicrosoft.PowerBI.Api(v3 as of now). You'll also needMicrosoft.Identity.Clientfor Azure AD authentication, since the old Workspace Collection access keys are no longer valid.
- Replace
Authentication Changes
- Instead of using a Workspace Collection access key, you'll authenticate using an Azure AD service principal (or user identity) to get an access token. Initialize your
PowerBIClientwith this token:var tokenCredentials = new TokenCredentials(accessToken, "Bearer"); var client = new PowerBIClient(new Uri("https://api.powerbi.com/"), tokenCredentials);
- Instead of using a Workspace Collection access key, you'll authenticate using an Azure AD service principal (or user identity) to get an access token. Initialize your
Workspace Model Shift
- Workspace Collections have been replaced with standard Power BI workspaces in your tenant. You'll need to ensure your migrated reports/datasets are in a dedicated workspace, and use that workspace's ID for all API calls.
Deprecation Timeline
- Microsoft has already deprecated Workspace Collection APIs, and they'll be fully retired once the service is shut down. Don't rely on the old methods continuing to work—prioritize migrating to the new API as soon as possible.
内容的提问来源于stack exchange,提问作者daxu

