Skip to content

Commit 343e279

Browse files
committed
Removed env from create options, added to desire properties
1 parent 3b94193 commit 343e279

File tree

3 files changed

+7
-47
lines changed

3 files changed

+7
-47
lines changed

articles/iot-edge/how-to-use-create-options.md

Lines changed: 2 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ services: iot-edge
1313

1414
# How to configure container create options for IoT Edge modules
1515

16-
The **createOptions** parameter in the deployment manifest enables you to configure the module containers at runtime. This parameter expands your control over the modules and allows for tasks like passing environment variables to the module, allowing or restricting the module's access to the host device's resources, or configuring networking.
16+
The **createOptions** parameter in the deployment manifest enables you to configure the module containers at runtime. This parameter expands your control over the modules and allows for tasks like allowing or restricting the module's access to the host device's resources, or configuring networking.
1717

1818
IoT Edge modules are implemented as Docker-compatible containers on your IoT Edge device. Docker offers many options for creating containers, and those options apply to IoT Edge modules, too. For more information, see [Docker container create options](https://docs.docker.com/engine/api/v1.32/#operation/ContainerCreate).
1919

@@ -53,7 +53,7 @@ If you use the Azure IoT Tools extensions for Visual Studio or Visual Studio Cod
5353
"createOptions": "{\"HostConfig\":{\"PortBindings\":{\"5671/tcp\":[{\"HostPort\":\"5671\"}],\"8883/tcp\":[{\"HostPort\":\"8883\"}],\"443/tcp\":[{\"HostPort\":\"443\"}]}}}"
5454
```
5555

56-
Another tip for formatting createOptions is to use the `docker inspect` command. As part of your development process, run the module locally using `docker run <container name>`. Once you have the module working the way you want it, run `docker inspect <container name>`. This command outputs the module details in JSON format. Find the parameters that you configured, and copy the JSON formatting. For example:
56+
One tip for writing create options is to use the `docker inspect` command. As part of your development process, run the module locally using `docker run <container name>`. Once you have the module working the way you want it, run `docker inspect <container name>`. This command outputs the module details in JSON format. Find the parameters that you configured, and copy the JSON. For example:
5757

5858
![Results of docker inspect edgeHub](./media/how-to-use-create-options/docker-inspect-edgehub.png)
5959

@@ -64,7 +64,6 @@ Container create options enable many scenarios, but here are some that come up m
6464
* [Give modules access to host storage](how-to-access-host-storage-from-module.md)
6565
* [Map host port to module port](#map-host-port-to-module-port)
6666
* [Restrict module memory and CPU usage](#restrict-module-memory-and-cpu-usage)
67-
* [Create environment variables in modules](#create-environment-variables-in-modules)
6867

6968
### Map host port to module port
7069

@@ -123,49 +122,6 @@ Once stringified for the final deployment manifest, these values would look like
123122
"createOptions":"{\"HostConfig\":{\"Memory\":268435456,\"MemorySwap\":536870912,\"CpuPeriod\":25000}}"
124123
```
125124

126-
### Create environment variables in modules
127-
128-
If you need to pass variables to your modules at runtime, you can create environment variables inside the module using the create options. These variables can be called from the module using an operating system get environment command. You can declare environment variables using the **Env** setting in the [Docker container create options](https://docs.docker.com/engine/api/v1.32/#operation/ContainerCreate).
129-
130-
In the template.json format, an environment variable is declared with the following example:
131-
132-
```json
133-
"createOptions": {
134-
"Env": [
135-
"variable1=100",
136-
"variable2=200"
137-
]
138-
}
139-
```
140-
141-
Once stringified for the final deployment manifest, these values would look like the following example:
142-
143-
```json
144-
"createOptions": "{\"Env\":[\"variable1=100\",\"variable2=200\"]}"
145-
```
146-
147-
>[!TIP]
148-
>You can pass environment variables to a module in two locations in the deployment manifest. The first is in the create options, and the second is as part of the module definition. For example:
149-
>
150-
>```json
151-
>"modules": {
152-
> "moduleA": {
153-
> "version": "1.0",
154-
> "type": "docker",
155-
> "status": "running",
156-
> "restartPolicy": "always",
157-
> "env": {
158-
> "variable1": {"value": "100"},
159-
> "variable2": {"value": "200"},
160-
> },
161-
> "settings": {
162-
> "image": "${MODULES.moduleA.arm32v7}",
163-
> "createOptions": { }
164-
> }
165-
> }
166-
>}
167-
>```
168-
169125
## Next steps
170126

171127
For more examples of create options in action, see the following IoT Edge samples:

articles/iot-edge/module-composition.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: Learn how a deployment manifest declares which modules to deploy, h
44
author: kgremban
55
manager: philmea
66
ms.author: kgremban
7-
ms.date: 05/28/2019
7+
ms.date: 03/26/2020
88
ms.topic: conceptual
99
ms.service: iot-edge
1010
services: iot-edge
@@ -247,6 +247,9 @@ The following example shows what a valid deployment manifest document may look l
247247
"type": "docker",
248248
"status": "running",
249249
"restartPolicy": "always",
250+
"env": {
251+
"tempLimit": {"value": "100"}
252+
},
250253
"settings": {
251254
"image": "myacr.azurecr.io/filtermodule:latest",
252255
"createOptions": "{}"

articles/iot-edge/module-edgeagent-edgehub.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ The module twin for the IoT Edge agent is called `$edgeAgent` and coordinates th
5050
| modules.{moduleId}.status | {"running" \| "stopped"} | Yes |
5151
| modules.{moduleId}.restartPolicy | {"never" \| "on-failure" \| "on-unhealthy" \| "always"} | Yes |
5252
| modules.{moduleId}.imagePullPolicy | {"on-create" \| "never"} | No |
53+
| modules.{moduleId}.env | A list of environment variables to pass to the module. Takes the format `"<name>": {"value": "<value>"}` | No |
5354
| modules.{moduleId}.settings.image | The URI to the module image. | Yes |
5455
| modules.{moduleId}.settings.createOptions | A stringified JSON containing the options for the creation of the module container. [Docker create options](https://docs.docker.com/engine/api/v1.32/#operation/ContainerCreate) | No |
5556
| modules.{moduleId}.configuration.id | The ID of the deployment that deployed this module. | IoT Hub sets this property when the manifest is applied using a deployment. Not part of a deployment manifest. |

0 commit comments

Comments
 (0)