Test Stream Analytics queries locally with sample data using Visual Studio Code
You can use Azure Stream Analytics tools for Visual Studio Code to test your Stream Analytics jobs locally with sample data. The output results can be found as JSON files in the LocalRunOutputs folder of your project.
For more information, see Overview of local Stream Analytics runs in Visual Studio Code with ASA Tools.
Prerequisites
Install .NET core SDK and restart Visual Studio Code.
Use this quickstart to learn how to create a Stream Analytics job using Visual Studio Code.
Prepare sample data
You need to prepare sample input data files first. If you already have some sample data files on your machine, you can skip this step and move on to the next one.
Click Preview data in your input configuration file from the top line. Some input data will be fetched from IoT Hub and shown in the preview window.
Once the data is shown, select Save as to save the data to a local file.
Define a local input
Select input.json under Inputs folder in your Stream Analytics project. Then select Add local input from the top line.
You can also use Ctrl+Shift+P to open the command palette and enter ASA: Add Input.
Select Local Input.
Select + New Local Input.
Enter the same input alias that you used in your query.
In the newly generated LocalInput_Input.json file, enter the file path where your local data file is located.
Select Preview Data to preview the input data. The serialization type (JSON or CSV) for your data is automatically detected. Use the selector to view your data in Table or Raw format. The following table is an example of data in the Table format:
The following table is an example of data in the Raw format:
Run queries locally
Return to your query editor, and select Run locally. Then select Use local input from the dropdown list.
The result is shown in the right window. You can select Run to test again. You can also select Open in folder to see the result files in file explorer and further open them with other tools. The result files are only available in JSON format.
Next steps
- Overview of local Stream Analytics runs in Visual Studio Code with ASA Tools
- Test Stream Analytics queries locally against live stream input by using Visual Studio Code
- Explore Azure Stream Analytics jobs with Visual Studio Code (preview)
- Set up CI/CD pipelines and unit testing by using the npm package
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for