使用逻辑应用进行刷新Refresh with Logic Apps

使用逻辑应用和 REST 调用,可以针对 Azure Analysis 表格模型执行自动数据刷新操作,包括同步查询横向扩展的只读副本。By using Logic Apps and REST calls, you can perform automated data refresh operations on your Azure Analysis tabular models, including synchronization of read-only replicas for query scale-out.

若要详细了解如何将 REST API 与 Azure Analysis Services 配合使用,请参阅使用 REST API 执行异步刷新To learn more about using REST APIs with Azure Analysis Services, see Asynchronous refresh with the REST API.

AuthenticationAuthentication

所有调用必须使用有效的 Azure Active Directory (OAuth 2) 令牌进行身份验证。All calls must be authenticated with a valid Azure Active Directory (OAuth 2) token. 本文中的示例将使用服务主体 (SPN) 对 Azure Analysis Services 进行身份验证。The examples in this article will use a Service Principal (SPN) to authenticate to Azure Analysis Services. 有关详细信息,请参阅使用 Azure 门户创建服务主体To learn more, see Create a service principal by using Azure portal.

设计逻辑应用Design the logic app

Important

以下示例假设已禁用 Azure Analysis Services 防火墙。The following examples assume that the Azure Analysis Services firewall is disabled. 如果启用了防火墙,则必须将请求发起程序的公共 IP 地址加入 Azure Analysis Services 防火墙的允许列表。If the firewall is enabled, the public IP address of the request initiator must be whitelisted in the Azure Analysis Services firewall. 若要详细了解每个区域的 Azure 逻辑应用 IP 范围,请参阅 Azure 逻辑应用的限制和配置信息To learn more about Azure Logic Apps IP ranges per region, see Limits and configuration information for Azure Logic Apps.

必备条件Prerequisites

创建服务主体 (SPN)Create a Service Principal (SPN)

若要了解如何创建服务主体,请参阅使用 Azure 门户创建服务主体To learn about creating a Service Principal, see Create a service principal by using Azure portal.

在 Azure Analysis Services 中配置权限Configure permissions in Azure Analysis Services

创建的服务主体必须对服务器拥有服务器管理员权限。The Service Principal you create must have server administrator permissions on the server. 有关详细信息,请参阅将服务主体添加到服务器管理员角色To learn more, see Add a service principal to the server administrator role.

配置逻辑应用Configure the Logic App

在此示例中,逻辑应用设计为在收到 HTTP 请求时触发。In this example, the Logic App is designed to trigger when a HTTP request is received. 这样,就可以使用业务流程工具(例如 Azure 数据工厂)来触发 Azure Analysis Services 模型刷新。This will enable the use of an orchestration tool, such as Azure Data Factory, to trigger the Azure Analysis Services model refresh.

创建逻辑应用后:Once you have created a Logic App:

  1. 在逻辑应用设计器中,选择“收到 HTTP 请求时”作为第一个操作。 In the Logic App designer, choose the first action as When a HTTP request is received.

    添加已收到 HTTP 请求时的活动

    保存逻辑应用后,此步骤将会填充 HTTP POST URL。This step will populate with the HTTP POST URL once the Logic App is saved.

  2. 添加新步骤并搜索 HTTPAdd a new step and search for HTTP.

    添加 HTTP 活动

    添加 HTTP 活动

  3. 选择“HTTP”以添加此操作。 Select HTTP to add this action.

    添加 HTTP 活动

按如下所示配置 HTTP 活动:Configure the HTTP activity as follows:

propertiesProperty Value
方法Method POSTPOST
URIURI https://服务器区域 /servers/aas 服务器名称 /models/数据库名称 /refresheshttps://your server region/servers/aas server name/models/your database name/refreshes

例如:https://chinanorth.asazure.chinacloudapi.cn/servers/myserver/models/AdventureWorks/refreshesFor example: https://chinanorth.asazure.chinacloudapi.cn/servers/myserver/models/AdventureWorks/refreshes
标头Headers Content-Type、application/jsonContent-Type, application/json

标头
正文Body 若要详细了解如何构建请求正文,请参阅使用 REST API - POST /refreshes 执行异步刷新To learn more about forming the request body, see Asynchronous refresh with the REST API - POST /refreshes.
身份验证Authentication Active Directory OAuthActive Directory OAuth
租户Tenant 填写你的 Azure Active Directory 租户 IDFill in your Azure Active Directory TenantId
受众Audience https://*.asazure.chinacloudapi.cnhttps://*.asazure.chinacloudapi.cn
客户端 IDClient ID 输入你的服务主体名称客户端 IDEnter your Service Principal Name ClientID
凭据类型Credential Type 机密Secret
机密Secret 输入你的服务主体名称机密Enter your Service Principal Name Secret

示例:Example:

已完成 HTTP 活动

现在请测试该逻辑应用。Now test the Logic App. 在逻辑应用设计器中单击“运行”。 In the Logic App designer, click Run.

测试逻辑应用

通过 Azure 数据工厂使用逻辑应用Consume the Logic App with Azure Data Factory

保存逻辑应用后,请查看收到 HTTP 请求时活动,然后复制现在生成的 HTTP POST URLOnce the Logic App is saved, review the When a HTTP request is received activity and then copy the HTTP POST URL that is now generated. Azure 数据工厂可以使用此 URL 发出异步调用来触发逻辑应用。This is the URL that can be used by Azure Data Factory to make the asynchronous call to trigger the Logic App.

下面是执行此操作的示例 Azure 数据工厂 Web 活动。Here's an example Azure Data Factory Web Activity that does this action.

数据工厂 Web 活动

使用独立的逻辑应用Use a self-contained Logic App

如果你不打算使用数据工厂等业务流程工具来触发模型刷新,可将逻辑应用设置为按计划触发刷新。If you don't plan on using an Orchestration tool such as Data Factory to trigger the model refresh, you can set the logic app to trigger the refresh based on a schedule.

沿用上面的示例,请删除第一个活动,并将其替换为“计划”活动。 Using the example above, delete the first activity and replace it with a Schedule activity.

计划活动

计划活动

本示例将使用“重复周期”。 This example will use Recurrence.

添加活动后,配置“间隔”和“频率”,然后添加新参数并选择“在这些时间”。 Once the activity has been added, configure the Interval and Frequency, then add a new parameter and choose At these hours.

计划活动

选择所需的小时数。Select the wanted hours.

计划活动

保存逻辑应用。Save the Logic App.

后续步骤Next steps

示例Samples
REST APIREST API