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.
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.
Sign in to the Azure portal.
Locate and select your existing Stream Analytics job.
On the Stream Analytics job page, under the Job Topology heading, select Query to open the Query editor window.
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:
The following table is an example of data in the Raw format:
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.
To test your query against a specific time range of incoming events, select Select time range.
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.
Once the events are sampled for selected time range, they appear in the Input preview tab.
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.
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.
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.
Sign in to the Azure portal.
Locate your existing Stream Analytics job and select it.
On the Stream Analytics job page, under the Job Topology heading, select Query to open the Query editor window.
To test your query with a local file, select Upload sample input on the Input preview tab.
Upload your local file to test the query. You can only upload files with the JSON, CSV, or AVRO formats. Select OK.
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.
Select Test query to test your query against the uploaded sample file.
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.
When you use multiple outputs in the query, the results are shown based on selected output.
After you verify the results shown in the browser, you can Start the job.
Limitations
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.
C# UDF is not supported.
All testing will be run with a job that has one Streaming Unit.
The timeout size is one minute. So any query with a window size greater than one minute cannot get any data.
Machine learning is not supported.
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
Build an IoT solution by using Stream Analytics: this tutorial will guide you to build an end-to-end solution with a data generator that will simulate traffic at a toll booth.