将 Azure 流分析与 Azure Synapse Analytics 中的专用 SQL 池配合使用Use Azure Stream Analytics with dedicated SQL pool in Azure Synapse Analytics

Azure 流分析是一种完全托管的服务,可以在云中通过流式数据进行低延迟、高度可用、可缩放且复杂的事件处理。Azure Stream Analytics is a fully managed service providing low-latency, highly available, scalable complex event processing over streaming data in the cloud. 可以通过阅读 Azure 流分析简介了解基础知识。You can learn the basics by reading Introduction to Azure Stream Analytics. 然后,可以参考开始使用 Azure 流分析教程,了解如何使用流分析创建端到端解决方案。You can then learn how to create an end-to-end solution with Stream Analytics by following the Get started using Azure Stream Analytics tutorial.

本文介绍如何使用专用 SQL 池作为 Azure 流分析作业的输出接收器(用于高吞吐量数据引入)。In this article, you will learn how to use your dedicated SQL pool as an output sink for high throughput data ingestion with Azure Stream Analytics jobs.

先决条件Prerequisites

  • Azure 流分析作业 - 若要创建 Azure 流分析作业,请按照 Azure 流分析入门教程中的步骤执行以下操作:Azure Stream Analytics Job - To create an Azure Stream Analytics job, follow the steps in the Get started using Azure Stream Analytics tutorial to :

    1. 创建事件中心输入Create an Event Hub input
    2. 配置并启动事件生成器应用程序Configure and start event generator application
    3. 预配流分析作业Provision a Stream Analytics job
    4. 指定作业输入和查询Specify job input and query
  • 专用 SQL 池 - 要新建专用 SQL 池,请遵循快速入门:创建专用 SQL 池中的步骤。Dedicated SQL pool - To create a new dedicated SQL pool, follow the steps in the Quickstart: Create a dedicated SQL pool.

将流输出指定为指向专用 SQL 池Specify streaming output to point to your dedicated SQL pool

步骤 1Step 1

在 Azure 门户中转到流分析作业,单击“作业拓扑”菜单下的“输出” 。From the Azure portal, go to your Stream Analytics job and click on Outputs under the Job topology menu.

步骤 2Step 2

单击“添加”按钮,然后从下拉菜单中选择“SQL 数据库” 。Click on the Add button and choose SQL Database from the drop down menu.

选择 SQL 数据库

步骤 3Step 3

输入以下值:Enter the following values:

  • 输出别名:输入此作业输出的友好名称。Output Alias: Enter a friendly name for this job output.
  • 订阅Subscription:
    • 如果专用 SQL 池与流分析作业位于同一订阅中,请单击“从订阅中选择 SQL 数据库”。If your dedicated SQL pool is in the same subscription as the Stream Analytics job, click on *Select SQL Database from your subscriptions . 如果专用 SQL 池位于其他订阅中,请单击“手动提供 SQL 数据库设置”。 If your dedicated SQL pool is in a different subscription, click on Provide SQL Database settings manually.
  • 数据库:从下拉列表中选择目标数据库。Database: Select the destination database from the drop down list.
  • 用户名:指定具有数据库写入访问权限的帐户的用户名。User Name: Specify the user name of an account that has write permissions for the database.
  • 密码:提供指定的用户帐户的密码。Password: Provide the password for the specified user account.
  • Table:指定数据库中目标表的名称。Table: Specify the name of the target table in the database.
  • 单击“保存”按钮 click on the Save button

已填写的“SQL 数据库”窗体

步骤 4Step 4

在运行测试之前,需要在专用 SQL 池中创建表。Before you can run a test, you will need to create the table in your dedicated SQL pool. 使用 SQL Server Management Studio (SSMS) 或所选的查询工具运行以下表创建脚本。Run the following table creation script using SQL Server Management Studio (SSMS) or your choice of query tool.

CREATE TABLE SensorLog
(
    RecordType VARCHAR(2)
    , SystemIdentity VARCHAR(2)
    , FileNum INT
    , SwitchNum VARCHAR(50)
    , CallingNum VARCHAR(25)
    , CallingIMSI VARCHAR(25)
    , CalledNum VARCHAR(25)
    , CalledIMSI VARCHAR(25)
    , DateS VARCHAR(25)
    , TimeS VARCHAR(25)
    , TimeType INT
    , CallPeriod INT
    , CallingCellID VARCHAR(25)
    , CalledCellID VARCHAR(25)
    , ServiceType VARCHAR(25)
    , [Transfer] INT
    , IncomingTrunk VARCHAR(25)
    , OutgoingTrunk VARCHAR(25)
    , MSRN VARCHAR(25)
    , CalledNum2 VARCHAR(25)
    , FCIFlag VARCHAR(25)
    , callrecTime VARCHAR(50)
    , EventProcessedUtcTime VARCHAR(50)
    , PartitionId int
    , EventEnqueuedUtcTime VARCHAR(50)
    )
WITH (DISTRIBUTION = ROUND_ROBIN)

步骤 5Step 5

在流分析作业的 Azure 门户上,单击作业名称。On the Azure portal for Stream Analytics job, click on your job name. 单击“输出详细信息”窗格中的“测试”按钮 。Click on the Test _ button in the _Output details*_ pane.

“输出详细信息”中的“测试”按钮 成功连接到数据库后,门户中会显示通知。Test button on Outpout details When the connection to the database succeeds, you will see a notification in the portal.

步骤 6Step 6

单击“作业拓扑”下的“查询”菜单并更改查询,以便将数据插入已创建的流输出中 。Click on the Query menu under Job topology and change the query to insert data into the Stream output you created. 单击“测试选定的查询”按钮以测试查询。Click on the Test selected query button to test your query. 如果查询测试成功,请单击“保存查询”按钮。Click Save Query button when your query test is successful.

保存查询

步骤 7Step 7

启动 Azure 流分析作业。Start the Azure Stream Analytics job. 单击“概览”菜单上的“启动”按钮 。Click on the Start button on the Overview menu.

启动流分析作业

单击“启动作业”窗格中的“启动”按钮。Click the _ Start* button on the start job pane.

单击“启动”

后续步骤Next steps

有关集成的概述,请参阅集成其他服务For an overview of integration, see Integrate other services. 有关更多开发技巧,请参阅专用 SQL 池的设计决策和编码技术For more development tips, see Design decisions and coding techniques for dedicated SQL pool.