在门户中测试 Azure 流分析作业Test an Azure Stream Analytics job in the portal

在 Azure 流分析中,无需启动或停止作业即可测试查询。In Azure Stream Analytics, you can test your query without starting or stopping your job. 可以对流源中的传入数据测试查询,也可以从 Azure 门户上的本地文件上传示例数据。You can test queries on incoming data from your streaming sources or upload sample data from a local file on Azure Portal.

来自输入的自动示例传入数据Automatically sample incoming data from input

Azure 流分析自动从流输入中提取事件。Azure Stream Analytics automatically fetches events from your streaming inputs. 可以针对默认示例运行查询,或者为示例设置特定的期限。You can run queries on the default sample or set a specific time frame for the sample.

  1. 登录到 Azure 门户。Sign in to the Azure portal.

  2. 找到并选择现有的流分析作业。Locate and select your existing Stream Analytics job.

  3. 在“流分析作业”页上的“作业拓扑”标题下,选择“查询”以打开“查询编辑器”窗口。On the Stream Analytics job page, under the Job Topology heading, select Query to open the Query editor window.

  4. 若要查看传入事件的示例列表,请使用文件图标选择输入,示例事件将自动显示在“输入预览”中。To see a sample list of incoming events, select the input with file icon and the sample events will automatically appear in the Input preview.

    a.a. 如果数据的序列化类型为 JSON 或 CSV,系统会自动检测到该类型。The serialization type for your data is automatically detected if its JSON or CSV. 还可以通过更改下拉菜单中的选项,手动将序列化类型更改为 JSON、CSV 或 AVRO。You can manually change it as well to JSON, CSV, AVRO by changing the option in the dropdown menu.

    b.b. 使用选择器查看“表”或“原始”格式的数据。Use the selector to view your data in Table or Raw format.

    c.c. 如果显示的数据不是最新的,请选择“刷新”查看最新事件。If your data shown isn't current, select Refresh to see the latest events.

    下表显示了采用“表”格式的数据示例:The following table is an example of data in the Table format:

    采用表格式的 Azure 流分析输入示例

    下表显示了“原始”格式的数据示例:The following table is an example of data in the Raw format:

    采用原始格式的 Azure 流分析输入示例

  5. 若要使用传入数据测试查询,请选择“测试查询”。To test your query with incoming data, select Test query. 结果将显示在“测试结果”选项卡中。还可以选择“下载结果”来下载结果。Results appear in the Test results tab. You can also select Download results to download the results.

    Azure 流分析中的示例测试查询结果

  6. 若要针对传入事件的特定时间范围测试查询,请选择“选择时间范围”。To test your query against a specific time range of incoming events, select Select time range.

    传入示例事件的 Azure 流分析时间范围

  7. 设置用于测试查询的事件的时间范围,然后选择“示例”。Set the time range of the events you want to use to test your query and select Sample. 在此期限内,最多可以检索 1000 个事件或 1 MB 的数据大小(以先达到的限制为准)。Within that time frame, you can retrieve up to 1000 events or 1 MB, whichever comes first.

    在 Azure 流分析中设置传入示例事件的时间范围

  8. 根据所选时间范围对事件采样后,这些事件将显示在“输入预览”选项卡中。Once the events are sampled for selected time range, they appear in the Input preview tab.

    在 Azure 流分析中查看测试结果

  9. 选择“重置”,查看传入事件的示例列表。Select Reset to see the sample list of incoming events. 如果选择“重置”,选择的时间范围将会丢失。If you select Reset, your time range selection will be lost. 选择“测试查询”以测试查询,然后在“测试结果”选项卡中查看结果。Select Test query to test your query and review the results in the Test results tab.

  10. 更改查询后,请选择“保存查询”以测试新的查询逻辑。When you make changes to your query, select Save query to test the new query logic. 这样就可以反复修改查询,并再次对其进行测试,以查看输出有何变化。This allows you to iteratively modify your query and test it again to see how the output changes.

  11. 确认结果显示在浏览器中后,可以 启动 作业。After you verify the results shown in the browser, you're ready to Start the job.

从本地文件上传示例数据Upload sample data from a local file

可以使用本地文件中的示例数据(而不是实时数据)来测试 Azure 流分析查询。Instead of using live data, you can use sample data from a local file to test your Azure Stream Analytics query.

  1. 登录到 Azure 门户。Sign in to the Azure portal.

  2. 找到现有流分析作业并选择它。Locate your existing Stream Analytics job and select it.

  3. 在“流分析作业”页上的“作业拓扑”标题下,选择“查询”以打开“查询编辑器”窗口。On the Stream Analytics job page, under the Job Topology heading, select Query to open the Query editor window.

  4. 若要使用本地文件测试查询,请在“输入预览”选项卡上选择“上传示例输入”。To test your query with a local file, select Upload sample input on the Input preview tab.

    屏幕截图显示了“上传示例输入”选项。

  5. 上传本地文件以测试查询。Upload your local file to test the query. 只能上传采用 JSON、CSV 或 AVRO 格式的文件。You can only upload files with the JSON, CSV, or AVRO formats. 选择“确定”。Select OK.

    屏幕截图显示了“上传示例数据”对话框,你可在其中选择文件。

  6. 上传文件后,还可以在窗体中查看表格式或原始格式的文件内容。As soon as you upload the file, you can also see the file contents in the form as a table or in it's raw format. 如果选择“重置”,示例数据将还原为上一部分所述的传入输入数据。If you select Reset, the sample data will return to the incoming input data explained in the previous section. 随时可以上传任何其他文件来测试查询。You can upload any other file to test the query at any time.

  7. 选择“测试查询”,以针对上传的示例文件测试查询。Select Test query to test your query against the uploaded sample file.

  8. 将根据查询显示测试结果。Test results are shown based on your query. 可以更改查询,然后选择“保存查询”来测试新的查询逻辑。You can change your query and select Save query to test the new query logic. 这样就可以反复修改查询,并再次对其进行测试,以查看输出有何变化。This allows you to iteratively modify your query and test it again to see how the output changes.

  9. 在查询中使用多个输出时,将根据所选输出显示结果。When you use multiple outputs in the query, the results are shown based on selected output.

    Azure 流分析中选定的输出

  10. 确认结果显示在浏览器中后,可以 启动 作业。After you verify the results shown in the browser, you can Start the job.

限制Limitations

  1. 门户测试中不支持时间策略:Time policy is not supported in portal testing:

    • 无序:将对所有传入事件进行排序。Out-of-order: all incoming events will be ordered.
    • 延迟到达:由于流分析只能使用现有数据进行测试,因此不会出现延迟到达事件。Late arrival: There will not be late arrival event since Stream Analytics can only use existing data for testing.
  2. 不支持 C# UDF。C# UDF is not supported.

  3. 所有测试都将在具有一个流单元的作业下运行。All testing will be run with a job that has one Streaming Unit.

  4. 超时大小为一分钟。The timeout size is one minute. 因此,任何窗口大小超过一分钟的查询都无法获取任何数据。So any query with a window size greater than one minute cannot get any data.

  5. 不支持机器学习。Machine learning is not supported.

  6. 在 15 分钟时段内,示例数据 API 将在发出 5 个请求后受到限制。The sample data API is throttled after five requests in a 15-minute window. 在 15 分钟时段结束后,你可执行更多示例数据请求。After the end of the 15-minute window, you can do more sample data requests. 此限制在订阅级别实施。This limitation is applied at the subscription level.

疑难解答Troubleshooting

  1. 如果遇到“提取结果时出现网络连接问题。If you get this error �There was a network connectivity issue when fetching the results. 请检查你的网络和防火墙设置。”错误,请按照以下步骤操作:Please check your network and firewall settings.�, follow the steps below:
  1. 如果遇到“请求大小过大。If you get this error "The request size is too big. 请减小输入数据大小,然后重试。”错误,请执行以下步骤:Please reduce the input data size and try again.", follow the steps below:
  • 减小输入大小 - 使用更小的示例文件或更小的时间范围测试查询。Reduce input size - Test your query with smaller size sample file or with a smaller time range.
  • 减小查询大小 - 若要测试选定的查询,请选择查询的一部分,然后单击“测试选定的查询”。Reduce query size - To test a selection of query, select a portion of query then click Test selected query.

后续步骤Next steps