你可能熟悉其中每个部分（作为现有 Power BI 功能）。You may be familiar with each piece as existing Power BI features.在生成内容包时，还需考虑其中每个方面的其他一些事项。请参阅下一节了解有关详细信息。When building a content pack, there are additional things to consider for each aspect, see each section below for more details.

查询Queries

对于模板内容包，在 Power BI Desktop 中开发的查询用于连接数据源和导入数据。For template content packs, queries developed in the Power BI Desktop are used to connect to your data source and import data.必须使用这些查询返回一致的架构，并且它们受支持以用于计划的数据刷新（不支持直接查询）。These queries are required to return a consistent schema and are supported for Scheduled Data refresh (direct query is not supported).

对于每个内容包，模板内容包仅支持一个数据源，因此请认真定义你的查询。Template content packs only support one data source per content pack so define your queries carefully.将单个数据源定义为需要相同的身份验证的源。A single data source is defined as a source that requires the same authentication.如果所有调用针对的是相同的 API 终结点且使用相同的身份验证，则可以在不同的查询中进行多次 API 调用。You can make multiple API calls in different queries if all the calls are to the same API endpoint and use the same authentication.Power BI 内容包不支持需要不同身份验证的多个源。Power BI content packs do not support multiple sources that require different authentications.

连接到 APIConnect to your API

需要从 Power BI Desktop 连接到你的 API 才能开始生成查询。To get started, you will need to connect to your API from Power BI Desktop to start building your queries.

可以使用 Power BI Desktop 中现成可用的数据连接器连接到 API。You can use the Data Connectors that are available out of the box in Power BI Desktop to connect to your API.可以使用 Web 数据连接器（获取数据 -> Web）连接到 Rest API 或 OData 连接器（获取数据 -> OData 数据源）来连接到 OData 数据源。You can use the Web Data Connector (Get Data -> Web) to connect to your Rest API or the OData connector (Get Data -> OData feed) to connect to your OData feed.请注意，这些连接器只有在你的 API 支持基本身份验证时才是现成可用的。Please note that these connectors will work out of the box only if your API supports Basic Authentication.

备注

如果你的 API 使用任何其他身份验证类型，如 OAuth 2.0 或 Web API 密钥，则需要开发你自己的数据连接器，以允许 Power BI Desktop 成功连接到 API，并对其进行身份验证。If your API uses any other authentication types, like OAuth 2.0 or Web API Key, then you will need to develop your own Data Connector to allow Power BI Desktop to successfully connects and authenticates to your API.有关如何为内容包开发你自己的数据连接器的详细信息，请查看此处的数据连接器文档。For details on how to develop your own Data Connector for your Content Pack, check the Data Connectors documentation here.

考虑源Consider the source

查询可定义将包含在数据模型中的数据。The queries define the data that will be included in the data model.根据你系统的大小，这些查询还应包括筛选器以确保客户处理适合你业务方案的可管理的查询量。Depending on the size of your system, these queries should also include filters to ensure your customers are dealing with a manageable size that fits your business scenario.

Power BI 内容包可并行执行多个查询，也可同时为多个用户执行查询。Power BI content packs can execute multiple queries in parallel and for multiple users concurrently.请提前规划你的限制条件和并发策略，并就如何使你的内容包具备容错能力向我们需求帮助。Plan ahead your throttling and concurrency strategy and ask us how to make your content pack fault tolerant.

架构实施Schema enforcement

确保你的查询能够弹性应对系统中发生的更改，刷新时的架构变更可破坏模型。Ensure your queries are resilient to changes in your system, changes in schema on refresh can break the model.如果源可能为某些查询返回 null/架构缺失结果，请考虑返回一个空表，或者引发一条对你的用户有意义的自定义错误消息。If the source could return null/missing schema result for some queries, consider returning an empty table or throw a custom error messages that is meaningful to your user.

参数Parameters

Power BI Desktop 中的参数允许你的用户提供用于自定义数据（由用户检索）的输入值。Parameters in Power BI Desktop allow your users to provide input values that customize the data retrieved by the user.提前考虑这些参数以避免在耗费时间生成详细的查询或报表之后返工。Think of the parameters upfront to avoid rework after investing time to build detailed queries or reports.

备注

模板内容包目前仅支持文本参数。Template content packs only support text parameters currently.在开发过程中可以使用其他参数类型，但在测试部分中中用户所提供的所有值将为文字内容。Other parameter types can be used during development but during the testing portion all values provided by the users will be literal.

其他查询提示Additional query tips

隐私级别目前在服务中不受支持 - 如果显示有关隐私级别的提示，你可能需要重新编写查询以使用相对路径Privacy levels are not currently supported in the service - if you get a prompt about privacy levels, you may need to re-write the query to use relative paths

数据模型Data Model

已进行完善定义的数据模型将确保你的客户可轻松直观地与内容包交互。A well-defined data model will ensure your customers can easily and intuitively interact with the content pack.在 Power BI Desktop 中创建数据模型。Create the data model in the Power BI Desktop.

备注

大部分基本建模（键入功能、列名）应在查询中完成。Much of the basic modelling (typing, column names) should be done in the queries.

问题解答Q&A

建模还将影响问题解答为客户提供结果的能力。The modelling will also affect how well Q&A can provide results for your customers.确保将同义词添加到常用列，并在查询中为你的列正确命名。Ensure you add synonyms to commonly used columns and that your columns are properly named in the queries.

其他数据模型提示Additional data model tips

所有值列已应用格式设置All value columns have formatting applied
>[!NOTE]
>应在查询中应用类型。Types should be applied in the query.

报表Reports

报表页提供了更多关于你内容包中数据的见解。The report pages offer additional insight into the data included in your content pack.使用报表中的页面来回答你的内容包正尝试解决的关键业务问题。Use the pages of the reports to answer the key business questions your content pack is trying to address.使用 Power BI Desktop 创建报表。Create the report using the Power BI Desktop.

备注

内容包中只能包含一个报表，可以利用不同页面调出你方案的特定部分。Only one report may be included in a content pack, take advantage of the different pages to call out particular sections of your scenario.

其他报表提示Additional report tips

对每个页面使用多个视觉对象以进行交叉筛选Use more than one visual per page for cross-filtering

元素最尽可能地位于客户端的的配色方案中Elements are in the client's color scheme to the extent possible

仪表板Dashboard

仪表板是与你客户的内容包交互的主要位置。The dashboard is the main point of interaction with your content pack for your customers.它应包括所含内容（尤其是你业务方案的重要指标）的概述。It should include an overview of the content included, especially the important metrics for your business scenario.

模板内容包目前需要对每个内容包使用单个报表和数据集。Template content packs currently require a single report and dataset per content pack.不要将多个报表/数据集的内容固定到内容包所使用的仪表板中。Do not pin content from multiple reports/datasets onto the dashboard used in the content pack.

其他仪表板提示Additional dashboard tips

在固定时保持相同的主题，以便你仪表板上的磁贴保持一致Maintain the same theme when pinning so that the tiles on your dashboard are consistent

将徽标固定到主题，以便使用者知道包的来源Pin a logo to the theme so consumers know where the pack is from

建议用于多数屏幕分辨率的布局是 5-6 个小磁贴的宽度Suggested layout to work with most screen resolutions is 5-6 small tiles wide