```html Deploy an Application to Azure IoT Edge

Azure IoT Edge Documentation

Prerequisites

Setup Development Environment

Install the Azure IoT Edge extension for the CLI and log in to your Azure account.

az extension add --name azure-iot
az login
az iot hub set-modules --subscription <SUB_ID> --resource-group <RG_NAME> --name <IOT_HUB_NAME>

Create IoT Edge Module

Generate a new module project using the template.

mkdir edge-modules && cd edge-modules
iotedgehubdev init
iotedgehubdev new --name temperature-sensor --template csharp

Build & Push Container

Build the Docker image and push it to Azure Container Registry (ACR).

# Build
docker build -t <ACR_NAME>.azurecr.io/temperature-sensor:1.0 .

# Login to ACR
az acr login --name <ACR_NAME>

# Push
docker push <ACR_NAME>.azurecr.io/temperature-sensor:1.0

Deploy via IoT Hub

Create a deployment manifest that references the newly pushed image.

{
  "modulesContent": {
    "$edgeAgent": {
      "properties.desired": {
        "modules": {
          "temperature-sensor": {
            "settings": {
              "image": "<ACR_NAME>.azurecr.io/temperature-sensor:1.0",
              "createOptions": {}
            },
            "type": "docker",
            "status": "running",
            "restartPolicy": "always"
          }
        }
      }
    }
  }
}

Apply the deployment:

az iot edge deployment create \
  --deployment-id temp-deploy \
  --hub-name <IOT_HUB_NAME> \
  --content deployment.json \
  --target-condition "tags.environment='dev'" \
  --priority 10

Verify Deployment

Check the module status on the edge device.

iotedge list

You should see temperature-sensor in a running state.

Troubleshooting

```