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/iot-edge/tutorial-store-data-sql-server.md
+37-7Lines changed: 37 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -171,9 +171,13 @@ The following steps show you how to create an IoT Edge function using Visual Stu
171
171
172
172
A [Deployment manifest](module-composition.md) declares which modules the IoT Edge runtime will install on your IoT Edge device. You added the code to make a customized Function module in the previous section, but the SQL Server module is already built. You just need to tell the IoT Edge runtime to include it, then configure it on your device.
173
173
174
-
1. In the Visual Studio Code explorer, open the **deployment.template.json** file.
174
+
1. In the Visual Studio Code explorer, open the **deployment.template.json** file.
175
175
2. Find the **moduleContent.$edgeAgent.properties.desired.modules** section. There should be two modules listed: **tempSensor**, which generates simulated data, and your **sqlFunction** module.
176
-
3. Add the following code to declare a third module:
176
+
3. If you're on a Windows machine, modify the **sqlFunction.settings.image** section.
177
+
```json
178
+
"image": "${MODULES.sqlFunction.windows-amd64}"
179
+
```
180
+
1. Add the following code to declare a third module:
177
181
178
182
```json
179
183
"sql": {
@@ -188,7 +192,7 @@ A [Deployment manifest](module-composition.md) declares which modules the IoT Ed
188
192
}
189
193
```
190
194
191
-
4. Depending on the operating system of your IoT Edge device, update the **sql.settings** parameters with the following code:
195
+
5. Depending on the operating system of your IoT Edge device, update the **sql.settings** parameters with the following code:
192
196
193
197
* Windows:
194
198
@@ -207,7 +211,7 @@ A [Deployment manifest](module-composition.md) declares which modules the IoT Ed
207
211
>[!Tip]
208
212
>Any time that you create a SQL Server container in a production environment, you should [change the default system administrator password](https://docs.microsoft.com/sql/linux/quickstart-install-connect-docker#change-the-sa-password).
209
213
210
-
5. Save the **deployment.template.json** file.
214
+
6. Save the **deployment.template.json** file.
211
215
212
216
## Build your IoT Edge solution
213
217
@@ -261,13 +265,39 @@ On your IoT Edge device, run the following command to see the status of the modu
261
265
iotedge list
262
266
```
263
267
268
+
## Pull SQL Container Image from Docker
269
+
270
+
Before you connect to your database, if you don't already have a container image of SQL Server Container, you can run this command to pull it from the Docker Hub. Since we are using the SQL container in this tutorial, we can't connect to the database unless we have this component present and running. Otherwise, Docker will not find a SQL container to connect to. Make sure if you're on Windows, Docker is using Windows containers, and for Linux, use Linux containers.
Afterwards, we need to run the container image with Docker.
281
+
282
+
```PowerShell
283
+
docker run -d -p 1433:1433 -e sa_password=<SA_PASSWORD> -e ACCEPT_EULA=Y microsoft/mssql-server-windows-developer
284
+
```
285
+
286
+
```bash
287
+
sudo docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=<YourStrong!Passw0rd>' \
288
+
-p 1433:1433 --name sql \
289
+
-d microsoft/mssql-server-linux:2017-latest
290
+
```
291
+
292
+
Run `iotedge list`, you should see the sql component now running with the other modules. If not, it helps to re-run the [IoT Edge runtime](https://docs.microsoft.com/en-us/azure/iot-edge/how-to-install-iot-edge-windows-with-windows).
293
+
264
294
## Create the SQL database
265
295
266
-
When you apply the deployment manifest to your device, you get three modules running. The tempSensor module generates simulated environment data. The sqlFunction module takes the data and formats it for a database.
296
+
When you apply the deployment manifest to your device, you get three modules running. The tempSensor module generates simulated environment data. The sqlFunction module takes the data and formats it for a database.
267
297
268
-
This section guides you through setting up the SQL database to store the temperature data.
298
+
This section guides you through setting up the SQL database to store the temperature data.
269
299
270
-
1. In a command-line too, connect to your database.
300
+
1. In a command-line tool, connect to your database.
0 commit comments