具有 DirectQuery 的 Azure SQL 数据库Azure SQL Database with DirectQuery

了解如何直接连接到 Azure SQL 数据库并使用实时数据创建报表。Learn how you can connect directly to Azure SQL Database and create reports that use live data. 你可以在源中(不是在 Power BI 中)保存数据。You can keep your data at the source and not in Power BI.

借助 DirectQuery,查询会在你浏览报表视图中的数据时发送回 Azure SQL 数据库。With DirectQuery, queries are sent back to your Azure SQL Database as you explore the data in the report view. 对于熟悉数据库以及它们连接到的实体的用户,建议使用此体验。This experience is suggested for users who are familiar with the databases and entities they connect to.

注意:Notes:

  • 在连接时指定完全限定的服务器名称(请参阅下文以了解详细信息)Specify the fully qualified server name when connecting (see below for more details)
  • 确保数据库的防火墙规则配置为允许访问 Azure 服务Ensure firewall rules for the database are configured to "Allow access to Azure services"
  • 每个操作(例如选择列或添加筛选器)都会将查询发送回数据库Every action such as selecting a column or adding a filter will send a query back to the database
  • 磁贴每小时刷新一次(刷新不需要进行计划)。Tiles are refreshed every hour (refresh does not need to be scheduled). 连接时可以在“高级设置”中对此进行调整。This can be adjusted in the Advanced settings when you connect.
  • 问答不可用于 DirectQuery 数据集Q&A is not available for DirectQuery datasets
  • 不会自动选取架构更改Schema changes afre not picked up automatically

随着我们继续改进体验,这些限制和说明可能会发生变化。These restrictions and notes may change as we continue to improve the experiences. 下面详细介绍了用于连接的步骤。The steps to connect are detailed below.

Power BI Desktop 和 DirectQueryPower BI Desktop and DirectQuery

若要使用 DirectQuery 连接到 Azure SQL 数据库,则必须使用 Power BI Desktop。In order to connect to Azure SQL Database using DirectQuery, you will need to use Power BI Desktop. 这种方法提供了更多灵活性和功能。This approach provides additional flexability and capabilities. 使用 Power BI Desktop 创建的报表随后可以发布到 Power BI 服务。Reports created using Power BI Desktop can then be published to the Power BI service. 可了解如何在 Power BI Desktop 内使用 DirectQuery 连接到 Azure SQL 数据库的详细信息。You can learn more about how to connect to Azure SQL Database using DirectQuery within Power BI Desktop.

单一登录Single sign-on

将 Azure SQL DirectQuery 数据集发布到服务后,可以通过 Azure Active Directory (Azure AD) OAuth2 为最终用户启用单一登录 (SSO)。After you publish an Azure SQL DirectQuery dataset to the service, you can enable single sign-on (SSO) via Azure Active Directory (Azure AD) OAuth2 for your end users.

若要启用 SSO,请转到数据集的设置,打开“数据源”选项卡,然后选中“SSO”框。To enable SSO, go to settings for the dataset, open the Data Sources tab, and check the SSO box.

配置 Azure SQL DQ 对话框

启用“SSO”选项后,如果用户访问基于数据源生成的报表,则 Power BI 会在查询中将这些用户的已经过身份验证的 Azure AD 凭据发送到 Azure SQL 数据库。When the SSO option is enabled and your users access reports built atop the data source, Power BI sends their authenticated Azure AD credentials in the queries to the Azure SQL database. 这样,Power BI 便可以遵守在数据源级别配置的安全设置。This enables Power BI to respect the security settings that are configured at the data source level.

SSO 选项针对使用此数据源的所有数据集生效。The SSO option takes affect across all datasets that use this data source. 它不影响用于导入方案的身份验证方法。It does not affect the authentication method used for import scenarios.

查找参数值Finding Parameter Values

可以在 Azure 门户中找到你的完全限定的服务器名称和数据库名称。Your fully qualified server name and database name can be found in the Azure Portal.

后续步骤Next steps

在 Power BI Desktop 中使用 DirectQueryUse DirectQuery in Power BI Desktop
Power BI 入门Get started with Power BI
获取 Power BI 的数据Get Data for Power BI
更多问题?More questions? 尝试参与 Power BI 社区Try the Power BI Community