Muokkaa

Jaa


Test an Azure Stream Analytics job in the portal

In Azure Stream Analytics, you can test your query without starting or stopping your job. You can test queries on incoming data from your streaming sources or upload sample data from a local file on Azure portal. You can also test queries locally from your local sample data or live data in Visual Studio and Visual Studio Code.

Automatically sample incoming data from input

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. 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. The serialization type for your data is automatically detected if its JSON or CSV. You can manually change it as well to JSON, CSV, AVRO by changing the option in the dropdown menu.

    b. Use the selector to view your data in Table or Raw format.

    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 Stream Analytics sample input in table format

    The following table is an example of data in the Raw format:

    Azure Stream Analytics sample input in raw format

  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 Stream Analytics sample test query results

  6. To test your query against a specific time range of incoming events, select Select time range.

    Azure Stream Analytics time range for incoming sample events

  7. Set the time range of the events you want to use to test your query and select Sample. Within that time frame, you can retrieve up to 1000 events or 1 MB, whichever comes first.

    Azure Stream Analytics set time range for incoming sample events

  8. Once the events are sampled for selected time range, they appear in the Input preview tab.

    Azure Stream Analytics view test results

  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

Instead of using live data, you can use sample data from a local file to test your Azure Stream Analytics query.

  1. 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.

    Screenshot shows the Upload sample input option.

  5. Upload your local file to test the query. You can only upload files with the JSON, CSV, or AVRO formats. Select OK.

    Screenshot shows the Upload sample data dialog box where you can select a file.

  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 Stream Analytics selected output

  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 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. The sample data API is throttled after five requests in a 15-minute window. After the end of the 15-minute window, you can do more sample data requests. This limitation is applied at the subscription level.

Troubleshooting

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