Skip to content

Commit d7344f6

Browse files
authored
Merge pull request #50214 from koumghar/myazurebranch
Myazurebranch
2 parents 4e81b86 + 6248cd8 commit d7344f6

File tree

1 file changed

+37
-7
lines changed

1 file changed

+37
-7
lines changed

articles/iot-edge/tutorial-store-data-sql-server.md

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,13 @@ The following steps show you how to create an IoT Edge function using Visual Stu
171171

172172
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.
173173

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.
175175
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:
177181

178182
```json
179183
"sql": {
@@ -188,7 +192,7 @@ A [Deployment manifest](module-composition.md) declares which modules the IoT Ed
188192
}
189193
```
190194

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:
192196

193197
* Windows:
194198

@@ -207,7 +211,7 @@ A [Deployment manifest](module-composition.md) declares which modules the IoT Ed
207211
>[!Tip]
208212
>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).
209213

210-
5. Save the **deployment.template.json** file.
214+
6. Save the **deployment.template.json** file.
211215

212216
## Build your IoT Edge solution
213217

@@ -261,13 +265,39 @@ On your IoT Edge device, run the following command to see the status of the modu
261265
iotedge list
262266
```
263267

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.
271+
272+
```PowerShell
273+
docker pull microsoft/mssql-server-windows-developer:latest
274+
```
275+
276+
```bash
277+
sudo docker pull microsoft/mssql-server-linux:2017-latest
278+
```
279+
280+
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+
264294
## Create the SQL database
265295

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

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

270-
1. In a command-line too, connect to your database.
300+
1. In a command-line tool, connect to your database.
271301
* Windows container:
272302

273303
```cmd

0 commit comments

Comments
 (0)