嵌入 Power BI 仪表板、报表和磁贴Embed your Power BI dashboards, reports and tiles

了解在应用程序中嵌入 Power BI 内容所需的步骤。Learn about the steps you need to take to embed Power BI content within your application.

Microsoft 发布了 Power BI Premium,这是基于容量的全新许可模型,让用户可以更灵活地访问、共享和分发内容。Microsoft announced Power BI Premium, a new capacity-based licensing model that increases flexibility for how users access, share and distribute content. 产品/服务还为 Power BI 服务提高其他可伸缩性和性能。The offering also delivers additional scalability and performance to the Power BI service. 还发布了 Power BI Embedded,可方便用户在 Microsoft Azure 中创建容量。Power BI Embedded was also announced that allows for creating capacity within Microsoft Azure. Power BI Embedded 主要面向应用和客户。Power BI Embedded is focused on your application and your customers.

本文将介绍如何为组织和客户嵌入 Power BI 内容。This article will look at embedding your Power BI content for both your organization and your customers. 两种方案的步骤相似。The steps are similar between the two scenarios. 如果是专为客户嵌入内容的步骤,则会有标注。Callouts will be made when a step is specific to embedding for your customer.

为了实现此操作,你的应用程序需要完成以下几个步骤。There are a few steps you have to do with your application to make this possible. 我们会完成所需的步骤,方便你在应用程序中创建和使用嵌入内容。We will go through the steps needed to allow you to create and use embedded content within your application.

备注

Power BI API 仍以组的形式引用应用工作区。The Power BI APIs still refer to app workspaces as groups. 对组的任何引用都意味着正使用应用工作区工作。Any references to groups mean that you are working with app workspaces.

步骤 1:设置嵌入式分析开发环境Step 1: Setup your embedded analytics development environment

在开始将仪表板和报表嵌入到应用程序中之前,需要确保环境已设置为允许嵌入。Before you start embedding dashboards and reports into your application, you need to make sure your environment is setup to allow for embedding. 在设置过程中,需要执行以下操作。As part of the setup, you will need to do the following.

备注

Power BI 容量对应用开发毫无影响。Power BI capacity is not required for development of your application. 应用程序的开发人员将需要具有 Power BI Pro 许可证。The developers of the application will need to have a Power BI Pro license.

Azure Active Directory 租户Azure Active Directory tenant

需要一个 Azure Active Directory (Azure AD) 租户才可嵌入 Power BI 中的项目。You will need an Azure Active Directory (Azure AD) tenant in order to embed items from Power BI. 此租户必须至少有一个 Power BI Pro 用户。This tenant must have at least one Power BI Pro user. 还需要在租户内定义 Azure AD 应用。You will also need to define an Azure AD app within the tenant. 可以使用现有 Azure AD 租户,也可创建一个专用于嵌入的新租户。You can make use of an existing Azure AD tenant or create a new one specifically for embedding purposes.

若要为客户嵌入内容,需要确定要使用的租户设置。You will need to determine what tenant setup to use if you are embedding for your customers.

  • 使用现有公司 Power BI 租户?Use your existing corporate Power BI tenant?
  • 为应用程序使用单独的租户?Use a separate tenant for your application?
  • 为每个客户使用单独的租户?Use a separate tenant for each customer?

如果不想使用现有租户,则可以决定为应用程序或每个客户创建一个新租户,请参阅创建 Azure Active Directory 租户如何获取 Azure Active Directory 租户If you do not want to use an existing tenant, you can decide to create a new tenant for your application, or one for each customer, see Create an Azure Active Directory tenant or How to get an Azure Active Directory tenant.

创建 Power BI Pro 用户帐户Create a Power BI Pro user account

只需要一个 Power BI Pro 帐户即可嵌入内容。You only need a single Power BI Pro account to embed content. 但是,你可能想要有几个对各项目具有特定访问权限的不同用户。However, you may want to have a few different users that have specific access to items. 下面介绍租户中可能需要考虑的用户。Here is a look at possible users to consider within your tenant.

租户中将需要存在以下帐户,并需要向其分配 Power BI Pro 许可证。The following accounts will need to exist within your tenant and have a Power BI Pro license assigned to them. 需要 Power BI Pro 许可证才能与 Power BI 中的应用工作区配合使用。A Power BI Pro license is required to work with app workspaces within Power BI.

组织/租户管理员用户An organization/tenant admin user

若要为客户嵌入内容,建议应用不要使用组织/租户全局管理员用户作为帐户。It is recommended that your organization/tenant Global Admin user should not be used as account your application uses if embedding for your customers. 这是为了最大限度地减少应用帐户在租户中拥有的访问权限。This is to minimize access that the application account has within your tenant. 建议将管理员用户设置为出于嵌入内容目的而创建的所有应用工作区的管理员。It is recommended that the admin user be an admin of all app workspaces created for the purpose of embedding.

将创建内容的分析师帐户Accounts for analysts that will create content

你可能有多个为 Power BI 创建内容的用户。You may have multiple users that create content for Power BI. 对于创建内容并将内容部署到 Power BI 的每个分析师,都将需要一个相应的 Power BI Pro 帐户。You will need a Power BI Pro account for each analyst that is creating and deploying content to Power BI.

用于为客户嵌入内容的应用主用户帐户An application master user account for embedding for your customers

主帐户是为客户嵌入内容时,应用将使用的帐户。The master account is the account your application will use when embedding content for your customers. 此方案通常适用于 ISV 应用。The scenario is typically for ISV applications. 主帐户实际上是组织中唯一需要的帐户。The master account is really the only required account you need within your organization. 此外可用作管理员和分析师帐户,但不建议这样做。It can also be used as the admin and analyst account, but it is not recommended. 应用程序的后端将存储此帐户的凭据,并将其用于获取与 Power BI API 一起使用的 Azure AD 身份验证令牌。Your application's backend will store the credentials for this account and use it for acquiring an Azure AD auth token for use with the Power BI APIs. 此帐户可用于生成应用要对客户使用的嵌入令牌。This account will be used to generate an embed token for the application to use for your customers.

主帐户只是拥有用于应用的 Power BI Pro 许可证的常规用户。The master account is just a regular user with a Power BI Pro license that you use with your application. 此帐户必须是用于嵌入内容的应用工作区的管理员。The account must be an admin of the app workspace that is being used for embedding.

应用注册和权限App registration and permissions

必须向 Azure AD 注册应用,才能执行 REST API 调用。You will need to register your application with Azure AD in order to make REST API calls. 有关详细信息,请参阅注册 Azure AD 应用以便嵌入 Power BI 内容For more information, see Register an Azure AD app to embed Power BI content.

创建应用工作区Create app workspaces

若要为客户嵌入仪表板和报表,必须将这些仪表板和报表置于应用工作区中。If you are embedding dashboards and reports for your customers, those dashboards and reports have to be placed within an app workspace. 上面提到的主帐户必须是应用工作区的管理员。The master account, that was mentioned above, must be an admin of the app workspace.

  1. 首先,创建工作区。Start by creating the workspace. 选择“工作区” > “创建应用工作区”。Select Workspaces > Create app workspace.

    创建应用工作区

    这里将放置你和你的同事协作处理的内容。This will be the place to put content that you and your colleagues collaborate on.

  2. 为工作区命名。Give the workspace a name. 如果对应的“工作区 ID”不可用,则进行编辑以给定一个唯一的 ID。If the corresponding Workspace ID isn't available, edit it to come up with a unique ID.

    这也是应用的名称。This will be the name of the app, too.

    命名工作区

  3. 需要设置几个选项。You have a few options to set. 如果你选择“公开”,则组织中的任何人都可以看到工作区内容。If you choose Public, anyone in your organization can see what’s in the workspace. 而如果选择“专用”,则意味着只有工作区的成员可以查看其内容。Private, on the other hand, means only members of the workspace can see its contents.

    设置专用或公用

    创建组后,将不能更改公共/私有设置。You can't change the Public/Private setting after you've created the group.

  4. 还可以选择成员是可以“编辑”还是具有“仅查看”访问权限。You can also choose if members can edit or have view-only access.

    设置编辑或仅查看

    仅向应用工作区添加用户,以便他们能够编辑内容。Only add people to the app workspace so they can edit the content. 如果他/她只是要查看内容,请勿将其添加到工作区。If they're only going to view the content, don't add them to the workspace. 可以在发布应用时对其进行添加。You can include them when you publish the app.

  5. 添加你要允许其访问工作区的用户的电子邮件地址,然后选择“添加”。Add email addresses of people you want to have access to the workspace, and select Add. 无法添加组别名,只能添加单个用户别名。You can’t add group aliases, just individuals.

  6. 确定每个人员的身份是成员还是管理员。Decide whether each person is a member or an admin.

    设置成员或管理员

    管理员可以编辑工作区本身,包括添加其他成员。Admins can edit the workspace itself, including adding other members. 成员可以编辑工作区中的内容,除非他们只具有“仅查看”访问权限。Members can edit the content in the workspace, unless they have view-only access. 管理员和成员均可以发布应用。Both admins and members can publish the app.

  7. 选择保存Select Save.

Power BI 创建工作区并将其打开。Power BI creates the workspace and opens it. 它显示在你作为成员的工作区的列表中。It appears in the list of workspaces you’re a member of. 作为管理员,你可以选择省略号(…) 返回并进行更改,添加新成员或更改其权限。Because you’re an admin, you can select the ellipsis (…) to go back and make changes to it, adding new members or changing their permissions.

编辑工作区

创建并上传报表Create and upload your reports

可使用 Power BI Desktop 创建报表和数据集,然后将这些报表发布到应用工作区。You can create your reports and datasets using Power BI Desktop and then publish those reports to an app workspace. 发布报表的最终用户需要拥有 Power BI Pro 许可证才可发布到应用工作区。The end user publishing the reports need to have a Power BI Pro license in order to publish to an app workspace.

步骤 2:嵌入内容Step 2: Embed your content

在应用程序内,需要对 Power BI 进行身份验证。Within your application, you will need to authenticate with Power BI. 若要为客户嵌入内容,将在应用中存储主帐户的凭据。If you are embedding content for your customers, you will store the credentials for the master account within your application. 有关详细信息,请参阅对用户进行身份验证并获取 Power BI 应用的 Azure AD 访问令牌For more information, see Authenticate users and get an Azure AD access token for your Power BI app.

通过身份验证后,在应用中使用 Power BI REST API 和 JavaScript API,将仪表板和报表嵌入应用中。Once authenticated, within your application, use the Power BI REST APIs and JavaScript APIs to embed dashboards and reports into your application.

若要为组织嵌入内容,请参阅以下演练:For embedding for your organization, see the following walkthroughs:

若要为客户嵌入内容(通常适合 ISV),请参阅以下演练:For embeding with your customers, which is typical for ISVs, see the following:

为客户嵌入内容时,必须使用嵌入令牌。When embedding for your customers, an embed token is required. 有关详细信息,请参阅 GenerateTokenTo learn more see, GenerateToken.

步骤 3:将解决方案提升到生产环境Step 3: Promote your solution to production

迁移到生产环境还需要额外执行几步。Moving to production requires a few extra steps.

为组织嵌入内容Embedding for your organization

若要为组织嵌入内容,只需让人们知道如何转到应用即可。If you are embedding for your organization, you only need to let people know how to get to your application.

免费用户可以使用从应用工作区(组)嵌入的内容,前提是相应工作区受容量支持。Free users can consume content that is embedded from an app workspace (group), if that workspace is backed by capacity. 将免费用户列为应用工作区(组)的成员,否则将看到 401 未授权错误。List the Free user as a member of app workspace (group), otherwise you receive a 401 unauthorized error. 下表列出了 Office 365 中可用的 Power BI Premium SKU。The following table lists the available Power BI Premium SKUs available within Office 365.

容量节点Capacity Node 总核心数Total cores
(后端 + 前端)(Backend + frontend)
后端核心数Backend Cores 前端核心数Frontend Cores DirectQuery/实时连接限制DirectQuery/live connection limits 高峰时间的最大显示页数Max page renders at peak hour
EM3EM3 4 个虚拟核心4 v-cores 2 个核心,10GB RAM2 cores, 10GB RAM 2 个核心2 cores 601-1,200601-1,200
P1P1 8 个虚拟核心8 v-cores 4 核,25 GB RAM4 cores, 25GB RAM 4 核4 cores 每秒 30 个30 per second 1,201-2,4001,201-2,400
P2P2 16 个虚拟核心16 v-cores 8 核,50 GB RAM8 cores, 50GB RAM 8 核8 cores 每秒 60 个60 per second 2,401-4,8002,401-4,800
P3P3 32 个虚拟核心32 v-cores 16 核,100 GB RAM16 cores, 100GB RAM 16 核16 cores 每秒 120 个120 per second 4,801-96004,801-9600

备注

在租户中,只有作为全局管理员或帐单管理员才能购买 Power BI Premium。You must be a Global or Billing Admin, within your tenant, in order to purchase Power BI Premium. 有关如何购买 Power BI Premium 的信息,请参阅如何购买 Power BI PremiumFor information on how to purchase Power BI Premium, see How to purchase Power BI Premium.

为客户嵌入内容Embedding for your customers

若要为客户嵌入内容,请执行以下操作。If you are embedding for your customers, do the following.

  • 如果使用单独的租户进行开发,必须确保应用工作区以及仪表板和报表可用于生产环境。If you are using a separate tenant for development, then you must make sure your app workspaces, along with dashboards and reports, are available in your production environment. 请务必在 Azure AD 中为生产租户创建应用,并按照第 1 步所述分配适当应用权限。Make sure that you create the application in Azure AD for your production tenant and assign the proper app permissions as indicated in Step 1.
  • 购买符合需求的容量。Purchase a capacity that fits your needs. 请参阅下表,了解可能需要的 Power BI Embedded 容量 SKU。You can use the table below to understand which Power BI Embedded capacity SKU you may need. 有关详细信息,请参阅嵌入式分析容量规划白皮书For more details, see Embedded analytics capacity planning whitepaper. 准备购买时,可以在 Microsoft Azure 门户中完成购买。When you are ready to purchase, you can do so within the Microsoft Azure portal. 若要详细了解如何创建 Power BI Embedded 容量,请参阅在 Azure 门户中创建 Power BI Embedded 容量For details on how to create Power BI Embedded capacity, see Create Power BI Embedded capacity in the Azure portal.

重要

由于嵌入令牌仅用于开发测试,因此 Power BI 主帐户生成的嵌入令牌数量有限。Because embed tokens are intended for development testing only, the number of embed tokens a Power BI master account can generate is limited. 对于嵌入生产方案,必须购买容量A capacity must be purchased for production embedding scenarios. 购买容量后便不会限制嵌入令牌生成。There is no limit to embed token generation when a capacity is purchased.

容量节点Capacity Node 总核心数Total cores
(后端 + 前端)(Backend + frontend)
后端核心数Backend Cores 前端核心数Frontend Cores DirectQuery/实时连接限制DirectQuery/live connection limits 高峰时间的最大显示页数Max page renders at peak hour
A1A1 1 个虚拟核心1 v-cores 0.5 个核心,3GB RAM.5 cores, 3GB RAM 0.5 个核心.5 cores 每秒 5 个5 per second 1-3001-300
A2A2 2 个虚拟核心2 v-cores 1 个核心,5GB RAM1 core, 5GB RAM 单核1 core 每秒 10 个10 per second 301-600301-600
A3A3 4 个虚拟核心4 v-cores 2 个核心,10GB RAM2 cores, 10GB RAM 2 个核心2 cores 每秒 15 个15 per second 601-1,200601-1,200
A4A4 8 个虚拟核心8 v-cores 4 核,25 GB RAM4 cores, 25GB RAM 4 核4 cores 每秒 30 个30 per second 1,201-2,4001,201-2,400
A5A5 16 个虚拟核心16 v-cores 8 核,50 GB RAM8 cores, 50GB RAM 8 核8 cores 每秒 60 个60 per second 2,401-4,8002,401-4,800
A6A6 32 个虚拟核心32 v-cores 16 核,100 GB RAM16 cores, 100GB RAM 16 核16 cores 每秒 120 个120 per second 4,801-96004,801-9600
  • 编辑应用工作区,并在“高级”下为它分配容量。Edit the app workspace and assign it to a capacity under advanced.

    为应用工作区分配容量

  • 将更新后的应用部署到生产环境,并开始嵌入 Power BI 仪表板和报表。Deploy your updated application to production and begin embedding Power BI dashboards and reports.

管理员设置Admin settings

全局管理员或 Power BI 服务管理员可以为租户启用或禁用 REST API。Global Admins, or Power BI service administrators, can turn the ability to use the REST APIs, on or off for a tenant. Power BI 管理员可以为整个组织或各个安全组设定此设置。Power BI admins can set this setting for the entire organization, or for individual security groups. 默认情况下,为整个组织启用此功能。It is enabled for the entire organization by default. 此操作通过 Power BI 管理门户完成。This is done through the Power BI admin portal.

后续步骤Next steps

使用 Power BI 嵌入Embedding with Power BI
如何将 Power BI Embedded 工作区集合内容迁移到 Power BIHow to migrate Power BI Embedded workspace collection content to Power BI
什么是 Power BI Premium?Power BI Premium - what is it?
如何购买 Power BI PremiumHow to purchase Power BI Premium
JavaScript API Git 存储库JavaScript API Git repo
Power BI C# Git 存储库Power BI C# Git repo
JavaScript 嵌入示例JavaScript embed sample
嵌入式分析容量规划白皮书Embedded analytics capacity planning whitepaper
Power BI Premium 白皮书Power BI Premium whitepaper

更多问题?More questions? 尝试咨询 Power BI 社区Try asking the Power BI Community