You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/stream-analytics/quick-create-visual-studio-code.md
+39-77Lines changed: 39 additions & 77 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,18 +1,17 @@
1
1
---
2
-
title: Quickstart - Create a Stream Analytics job using Visual Studio Code
2
+
title: Create a Stream Analytics job using Visual Studio Code
3
3
description: This quickstart shows you how to create a Stream Analytics job using the ASA extension for Visual Studio Code.
4
4
ms.service: azure-stream-analytics
5
5
author: ahartoon
6
6
ms.author: anboisve
7
-
ms.date: 07/17/2023
7
+
ms.date: 12/17/2024
8
8
ms.topic: quickstart
9
9
ms.custom: mvc, mode-ui
10
10
#Customer intent: As an IT admin/developer, I want to create a Stream Analytics job, configure input and output, and analyze data by using Visual Studio Code.
11
11
---
12
12
13
13
# Quickstart: Create a Stream Analytics job using Visual Studio Code
14
-
15
-
This quickstart shows you how to create, run and submit an Azure Stream Analytics (ASA) job using the ASA Tools extension for Visual Studio Code in your local machine. You learn to build an ASA job that reads real-time streaming data from IoT Hub and filters events with a temperature greater than 27°. The output results are sent to a file in blob storage. The input data used in this quickstart is generated by a Raspberry Pi online simulator.
14
+
In this quickstart, you create, run and submit an Azure Stream Analytics (ASA) job using the ASA Tools extension for Visual Studio Code in your local machine. You learn to build an ASA job that reads real-time streaming data from IoT Hub and filters events with a temperature greater than 27°. The output results are sent to a file in blob storage. The input data used in this quickstart is generated by a Raspberry Pi online simulator.
16
15
17
16
> [!NOTE]
18
17
> Visual Studio Code tools don't support jobs in the China East, China North, Germany Central, and Germany NorthEast regions.
@@ -37,50 +36,16 @@ This quickstart shows you how to create, run and submit an Azure Stream Analytic
37
36
> [!NOTE]
38
37
> The ASA Tools extension will automatically sign you in every time you open VS Code. If your account has two-factor authentication, we recommend that you use phone authentication rather than using a PIN. To sign out your Azure account, press `Ctrl + Shift + P` and enter `Azure: Sign Out`.
39
38
40
-
## Prepare the input data
41
-
42
-
Before defining the Stream Analytics job, you should prepare the input data. The real-time sensor data is ingested to IoT Hub, which later configured as the job input. To prepare the input data required by the job, follow these steps:
43
-
44
-
1. Sign in to the [Azure portal](https://portal.azure.com/).
45
-
2. Select **Create a resource > Internet of Things > IoT Hub**.
46
-
47
-
:::image type="content" source="./media/quick-create-visual-studio-code/create-resource-iot-hub-menu.png" alt-text="Screenshot showing the Create Resource page for Iot Hub.":::
48
-
49
-
3. On the **IoT Hub** page, enter the following information:
50
-
***Subscription**, select your Azure subscription.
51
-
***Resource group**, select an existing resource group or create a new resource group.
52
-
***IoT hub name**, enter a name for your IoT hub.
53
-
***Region**, select the region that's closest to you.
54
-
55
-
:::image type="content" source="./media/quick-create-visual-studio-code/create-iot-hub.png" alt-text="Screenshot showing the IoT Hub page for creation.":::
56
-
57
-
4. Go to **Management** page, for **Pricing and scale tier**, select **F1: Free tier**, if it's still available on your subscription. For more information, see [Azure IoT Hub pricing](https://azure.microsoft.com/pricing/details/iot-hub/).
58
-
59
-
:::image type="content" source="./media/quick-create-visual-studio-code/iot-management-page.png" alt-text="Screenshot showing the IoT Hub management page.":::
60
-
61
-
5. Select **Review + create**. Review your IoT hub information and select **Create**. This process may take a few minutes to deploy your IoT hub.
62
-
63
-
6. After your IoT hub is created, select **Go to resource** to navigate to the **IoT Hub** page. '
64
-
65
-
7. On the **IoT Hub** page, select **Devices** on the left menu, and then select **\+ Add Device**.
66
-
67
-
:::image type="content" source="./media/quick-create-visual-studio-code/add-device-menu.png" alt-text="Screenshot showing the Add Device button on the Devices page.":::
68
-
9. Enter a **Device ID** and select **Save**.
69
-
70
-
:::image type="content" source="./media/quick-create-visual-studio-code/add-device-iot-hub.png" alt-text="Screenshot showing the Add Device page.":::
71
-
10. Once the device is created, you should see the device from the **IoT devices** list. Select **Refresh** button on the page if you don't see it.
72
-
73
-
:::image type="content" source="./media/quick-create-visual-studio-code/select-device.png" alt-text="Screenshot showing the selection of the device on the Devices page.":::
74
-
11. Select your device from the list. Copy **Primary Connection String** and save it to a notepad to use later.
39
+
## Run the IoT simulator
75
40
76
-
:::image type="content" source="./media/quick-create-visual-studio-code/save-iot-device-connection-string.png" alt-text="Screenshot showing the primary connection string of the device you created.":::
41
+
1. Open the [Raspberry Pi Azure IoT Online Simulator](https://azure-samples.github.io/raspberry-pi-web-simulator/).
42
+
2. Replace the placeholder in Line 15 with the Azure IoT Hub device connection string you saved in a previous section.
43
+
3. Select **Run**. The output should show the sensor data and messages that are being sent to your IoT Hub.
77
44
78
-
## Run the IoT simulator
79
-
1. Open the [Raspberry Pi Azure IoT Online Simulator](https://azure-samples.github.io/raspberry-pi-web-simulator/) in a new browser tab.
80
-
2. Replace the placeholder in line 15 with the IoT hub device connection string that you saved earlier.
81
-
3. Select **Run**. The output should show the sensor data and messages that are being sent to your IoT hub.
45
+
:::image type="content" source="./media/stream-analytics-quick-create-portal/ras-pi-connection-string.png" lightbox="./media/stream-analytics-quick-create-portal/ras-pi-connection-string.png" alt-text="Screenshot showing the **Raspberry Pi Azure IoT Online Simulator** page with the sample query.":::
82
46
83
-
:::image type="content" source="./media/quick-create-visual-studio-code/ras-pi-connection-string.png" lightbox="./media/quick-create-visual-studio-code/ras-pi-connection-string.png" alt-text="Screenshot showing the Raspberry Pi Azure IoT Online Simulator with output.":::
47
+
> [!IMPORTANT]
48
+
> Select **Reset** after a few minutes to reset the connection string.
84
49
85
50
## Create blob storage
86
51
@@ -106,11 +71,11 @@ Before defining the Stream Analytics job, you should prepare the input data. The
106
71
107
72
:::image type="content" source="./media/quick-create-visual-studio-code/create-new-project.png" alt-text="Screenshot showing the selection of ASA: Create New Project in the command palette.":::
108
73
109
-
2. Enter your project name, like **myASAproj**, and select a folder for your project.
74
+
1. Enter your project name, like **myASAproj**, and select a folder for your project.
110
75
111
76
:::image type="content" source="./media/quick-create-visual-studio-code/create-project-name.png" alt-text="Screenshot showing entering an ASA project name.":::
112
77
113
-
3. An ASA project is added to your workspace. It consists of three folders: **Inputs**, **Outputs**, and **Functions**. It also has the query script **(*.asaql)**, a **JobConfig.json** file, and an **asaproj.json** configuration file.
78
+
1. An ASA project is added to your workspace. It consists of three folders: **Inputs**, **Outputs**, and **Functions**. It also has the query script **(*.asaql)**, a **JobConfig.json** file, and an **asaproj.json** configuration file.
114
79
115
80
:::image type="content" source="./media/quick-create-visual-studio-code/asa-project-files.png" alt-text="Screenshot showing Stream Analytics project files in Visual Studio Code.":::
116
81
@@ -139,22 +104,21 @@ Before defining the Stream Analytics job, you should prepare the input data. The
139
104
:::image type="content" source="./media/quick-create-visual-studio-code/add-input-from-inputs-folder.png" lightbox="./media/quick-create-visual-studio-code/add-input-from-inputs-folder.png" alt-text="Screenshot showing the ASA: Add input menu in Visual Studio Code.":::
140
105
141
106
Or press **Ctrl+Shift+P** to open the command palette and enter **ASA: Add Input**.
142
-
143
107
2. Choose **IoT Hub** for the input type.
144
108
145
109
:::image type="content" source="./media/quick-create-visual-studio-code/iot-hub.png" lightbox="./media/quick-create-visual-studio-code/iot-hub.png" alt-text="Screenshot showing the selection of your IoT hub in VS Code command palette.":::
110
+
3. Choose **Select from Azure subscriptions** from the drop-down menu, and then press **ENTER**.
111
+
1. Enter **Input** for the name, and then press **ENTER**.
112
+
1. Under **Inputs** folder, you see an **IoTHub1.json** file is created.
113
+
1. In the JSON file, confirm that **Input** is specified **Name**.
114
+
1. In the JSON editor for **Input.json**, choose **Select from your subscriptions**, and then select your Azure subscription that has the IoT hub.
146
115
147
-
3. Select an ASA script **\*.asaql** and **Azure Subscriptions** from the drop-down menu, and then press **ENTER**.
148
-
149
-
4. Under **Inputs** folder, you see an **IoTHub1.json** file is created. Replace settings with following suggested values and keep default values for fields not mentioned here.
116
+
:::image type="content" source="./media/quick-create-visual-studio-code/select-from-your-azure-subscriptions.png" lightbox="./media/quick-create-visual-studio-code/select-from-your-azure-subscriptions.png" alt-text="Screenshot showing the JSON editor with Select from your subscriptions link.":::
117
+
1. In the JSON editor, choose **Select an IoT Hub**, and then select the IoT hub you created.
150
118
151
-
|Setting|Suggested Value|Description|
152
-
|-------|---------------|-----------|
153
-
|Name|**Input**|This input name is used for **FROM** statement in the query.|
154
-
|IotHubNamespace|**spiothub**|Name of your IoT hub. The IoT hub names are automatically detected if you **Select from your subscription**.|
155
-
|SharedAccessPolicyName|**iothubowner**||
156
-
157
-
:::image type="content" source="./media/quick-create-visual-studio-code/iothub-configuration.png" lightbox="./media/quick-create-visual-studio-code/iothub-configuration.png" alt-text="Screenshot showing the IoT Hub configuration in VS Code.":::
119
+
:::image type="content" source="./media/quick-create-visual-studio-code/select-iot-hub-json.png" lightbox="./media/quick-create-visual-studio-code/select-iot-hub-json.png" alt-text="Screenshot showing the JSON editor with Select an IoT Hub link.":::
120
+
1. By default, the `SharedAccessPolicyName` should be set to `iothubowner`. If not, choose **Select a Shared Access Policy Name** link, and then select **iothubowner** from the drop-down list.
121
+
1. The `SharedAccessPolicyKey` value should be automatically set.
158
122
159
123
<!-- You can use the CodeLens feature to help you enter a string, select from a drop-down list, or change the text directly in the file. The following screenshot shows **Select from your Subscriptions** as an example. The credentials are auto-listed and saved in local credential manager.
160
124
@@ -172,17 +136,13 @@ Before defining the Stream Analytics job, you should prepare the input data. The
172
136
173
137
## Configure job output
174
138
175
-
1. Press **Ctrl+Shift+P** to open the command palette and enter **ASA: Add Output**.
176
-
2. Choose **Data Lake Storage Gen2/Blob Storage** for the sink type.
177
-
3. Select the query script using this output.
178
-
4. Enter **BlobStorage1** as output file name.
179
-
5. Edit the settings using the following values. Keep default values for fields not mentioned here.
180
-
181
-
|Setting|Suggested value|Description|
182
-
|-------|---------------|-----------|
183
-
|Name|**Output**| This output name is used for **INTO** statement in the query.|
184
-
|Storage Account|**spstorageaccount0901**|Choose or enter the name of your storage account. Storage account names are automatically detected if they're created in the same subscription.|
185
-
|Container|**spcontainer**|Select the existing container that you created in your storage account.|
139
+
1. Right-click **Outputs** in the explorer, and select **ASA: Add Output**.
140
+
2. Choose **Data Lake Storage Gen2/Blob Storage** for the sink type in the drop-down list.
141
+
1. Choose **Select from Azure subscriptions**
142
+
1. Enter **Output** for the name of the alias and press ENTER. This output name is used for **INTO** statement in the query.
143
+
1. In the JSON editor for **Output.json**, choose **Select from your subscriptions**, and then select your Azure subscription that has the Azure Storage account
144
+
1. If you need to change the storage account that's automatically filled, choose **Select a Storage account**, and then select your Azure Storage account. Storage account names are automatically detected if they're created in the same subscription.
145
+
1. If you need to change the container name, choose **Select a container**, and select the blob container you created.
186
146
187
147
<!-- |Path Pattern|output|Enter the name of a file path to be created within the container.| -->
188
148
@@ -194,30 +154,32 @@ Before defining the Stream Analytics job, you should prepare the input data. The
194
154
195
155
Script compilation checks syntax and generates the Azure Resource Manager templates for automatic deployment.
196
156
197
-
1. Right-click the script and select **ASA: Compile Script**.
157
+
1. Right-click the script file in the explorer window, point to **ASA: Compile Script**, and then select **ASA: ARM Template V2 (recommended)**.
198
158
199
159
:::image type="content" source="./media/quick-create-visual-studio-code/compile-script-2.png" lightbox="./media/quick-create-visual-studio-code/compile-script-2.png" alt-text="Screenshot showing the compilation of script option from the Stream Analytics explorer in VS Code.":::
200
-
201
160
2. After compilation, you see a **Deploy** folder under your project with two Azure Resource Manager templates. These two files are used for automatic deployment.
202
161
203
162
:::image type="content" source="./media/quick-create-visual-studio-code/deployment-templates.png" lightbox="./media/quick-create-visual-studio-code/deployment-templates.png" alt-text="Screenshot showing the generated deployment templates in the project folder.":::
204
-
205
163
3. Select **Submit to Azure** in the query editor.
206
164
207
-
:::image type="content" source="./media/quick-create-visual-studio-code/submit-job.png" lightbox="./media/quick-create-visual-studio-code/submit-job.png" alt-text="Screenshot showing the submit job button to submit the Stream Analytics job to Azure.":::
208
-
209
-
Then follow the instructions to complete the process: **Select subscription > Select a job > Create New Job > Enter job name > Choose resource group and region.**
165
+
:::image type="content" source="./media/quick-create-visual-studio-code/submit-job.png" lightbox="./media/quick-create-visual-studio-code/submit-job.png" alt-text="Screenshot showing the Submit job button to submit the Stream Analytics job to Azure.":::
166
+
3. In the **Submit** window, follow these steps:
167
+
1. Select your Azure **subscription**.
168
+
1. Select an Azure **resource group**.
169
+
1. Select the **region** where you want to create the Stream Analytics job.
4. Select **Publish to Azure** and complete. Wait for it to open a new tab **Cloud Job View** showing your job's status.
212
174
213
175
:::image type="content" source="./media/quick-create-visual-studio-code/publish-to-azure.png" lightbox="./media/quick-create-visual-studio-code/publish-to-azure.png" alt-text="Screenshot showing the publish to Azure button in VS Code.":::
214
176
215
177
## Start the Stream Analytics job and check output
216
178
217
-
1. On the **Cloud Job View** tab, select **Start** to run your job in the cloud. This process may take a few minutes to complete.
179
+
1. On the **Cloud Job View** tab, select **Start** to run your job in the cloud.
218
180
219
181
:::image type="content" source="./media/quick-create-visual-studio-code/start-asa-job-vs-code.png" lightbox="./media/quick-create-visual-studio-code/start-asa-job-vs-code.png" alt-text="Screenshot showing the Start job button in the Cloud view page.":::
220
-
182
+
1. On the **Start streaming job** window, select **OK**. This process might take a few minutes to complete.
221
183
2. If your job starts successfully, the job status is changed to **Running**. You can see a logical diagram showing how your ASA job is running.
222
184
223
185
:::image type="content" source="./media/quick-create-visual-studio-code/job-running-status.png" lightbox="./media/quick-create-visual-studio-code/job-running-status.png" alt-text="Screenshot showing the job running status in VS Code.":::
Copy file name to clipboardExpand all lines: articles/stream-analytics/stream-analytics-quick-create-portal.md
+9-8Lines changed: 9 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -49,6 +49,15 @@ Before defining the Stream Analytics job, you should prepare the input data. The
49
49
50
50
:::image type="content" source="./media/stream-analytics-quick-create-portal/save-iot-device-connection-string.png" lightbox="./media/stream-analytics-quick-create-portal/save-iot-device-connection-string.png" alt-text="Screenshot showing the copy button next to device connection string.":::
51
51
52
+
## Run the IoT simulator
53
+
54
+
1. Open the [Raspberry Pi Azure IoT Online Simulator](https://azure-samples.github.io/raspberry-pi-web-simulator/).
55
+
2. Replace the placeholder in Line 15 with the Azure IoT Hub device connection string you saved in a previous section.
56
+
3. Select **Run**. The output should show the sensor data and messages that are being sent to your IoT Hub.
57
+
58
+
:::image type="content" source="./media/stream-analytics-quick-create-portal/ras-pi-connection-string.png" lightbox="./media/stream-analytics-quick-create-portal/ras-pi-connection-string.png" alt-text="Screenshot showing the **Raspberry Pi Azure IoT Online Simulator** page with the sample query.":::
59
+
60
+
52
61
## Create blob storage
53
62
54
63
1. From the upper left-hand corner of the Azure portal, select **Create a resource**. Select **Storage** under **Categories** on the left menu, and then select **Storage account**.
@@ -129,14 +138,6 @@ In this section, you configure an IoT Hub device input to the Stream Analytics j
129
138
130
139
:::image type="content" source="./media/stream-analytics-quick-create-portal/add-asa-query.png" lightbox="./media/stream-analytics-quick-create-portal/add-asa-query.png" alt-text="Screenshot showing the **Query** page with the sample query.":::
131
140
132
-
## Run the IoT simulator
133
-
134
-
1. Open the [Raspberry Pi Azure IoT Online Simulator](https://azure-samples.github.io/raspberry-pi-web-simulator/).
135
-
2. Replace the placeholder in Line 15 with the Azure IoT Hub device connection string you saved in a previous section.
136
-
3. Select **Run**. The output should show the sensor data and messages that are being sent to your IoT Hub.
137
-
138
-
:::image type="content" source="./media/stream-analytics-quick-create-portal/ras-pi-connection-string.png" lightbox="./media/stream-analytics-quick-create-portal/ras-pi-connection-string.png" alt-text="Screenshot showing the **Raspberry Pi Azure IoT Online Simulator** page with the sample query.":::
139
-
140
141
## Start the Stream Analytics job and check the output
141
142
142
143
1. Return to the job overview page in the Azure portal, and select **Start job**.
0 commit comments