Create and provision an IoT Edge for Linux on Windows device at scale by using a TPM
Applies to: IoT Edge 1.4
Important
Azure IoT Edge 1.5 LTS and IoT Edge 1.4 are supported releases. IoT Edge 1.4 LTS is reaching the end of service on November 12, 2024. If you're on an earlier release, see Update IoT Edge.
This article provides instructions for autoprovisioning an Azure IoT Edge for Linux on Windows device by using a Trusted Platform Module (TPM). You can automatically provision Azure IoT Edge devices with the Azure IoT Hub device provisioning service. If you're unfamiliar with the process of autoprovisioning, review the provisioning overview before you continue.
This article outlines two methodologies. Select your preference based on the architecture of your solution:
- Autoprovision a Linux on Windows device with physical TPM hardware.
- Autoprovision a Linux on Windows device by using a simulated TPM. We recommend this methodology only as a testing scenario. A simulated TPM doesn't offer the same security as a physical TPM.
The tasks are as follows:
- Install IoT Edge for Linux on Windows.
- Retrieve the TPM information from your device.
- Create an individual enrollment for the device.
- Provision your device with its TPM information.
Prerequisites
Cloud resources
- An active IoT hub
- An instance of the IoT Hub device provisioning service in Azure, linked to your IoT hub
- If you don't have a device provisioning service instance, you can follow the instructions in the Create a new IoT Hub device provisioning service and Link the IoT hub and your device provisioning service sections of the IoT Hub device provisioning service quickstart.
- After you have the device provisioning service running, copy the value of ID Scope from the overview page. You use this value when you configure the IoT Edge runtime.
Device requirements
A Windows device with the following minimum requirements:
System Requirements
- Windows 101/11 (Pro, Enterprise, IoT Enterprise)
- Windows Server 20191/2022
1 Windows 10 and Windows Server 2019 minimum build 17763 with all current cumulative updates installed.
Hardware requirements
- Minimum Free Memory: 1 GB
- Minimum Free Disk Space: 10 GB
Virtualization support
- On Windows 10, enable Hyper-V. For more information, see Install Hyper-V on Windows 10.
- On Windows Server, install the Hyper-V role and create a default network switch. For more information, see Nested virtualization for Azure IoT Edge for Linux on Windows.
- On a virtual machine, configure nested virtualization. For more information, see nested virtualization.
Networking support
- Windows Server does not come with a default switch. Before you can deploy EFLOW to a Windows Server device, you need to create a virtual switch.
- Windows Desktop versions come with a default switch that can be used for EFLOW installation. If needed, you can create your own custom virtual switch.
Tip
If you want to use GPU-accelerated Linux modules in your Azure IoT Edge for Linux on Windows deployment, there are several configuration options to consider.
You will need to install the correct drivers depending on your GPU architecture, and you may need access to a Windows Insider Program build. To determine your configuration needs and satisfy these prerequisites, see GPU acceleration for Azure IoT Edge for Linux on Windows.
Make sure you take the time to satisfy the prerequisites for GPU acceleration now. You will need to restart the installation process if you decide you want GPU acceleration during installation.
Developer tools
Prepare your target device for the installation of Azure IoT Edge for Linux on Windows and the deployment of the Linux virtual machine:
Set the execution policy on the target device to
AllSigned
. You can check the current execution policy in an elevated PowerShell prompt using the following command:Get-ExecutionPolicy -List
If the execution policy of
local machine
is notAllSigned
, you can set the execution policy using:Set-ExecutionPolicy -ExecutionPolicy AllSigned -Force
For more information on the Azure IoT Edge for Linux on Windows PowerShell module, see the PowerShell functions reference.
Note
TPM 2.0 is required when you use TPM attestation with the device provisioning service.
You can only create individual, not group, device provisioning service enrollments when you use a TPM.
Install IoT Edge
Deploy Azure IoT Edge for Linux on Windows on your target device.
Note
The following PowerShell process outlines how to deploy IoT Edge for Linux on Windows onto the local device. To deploy to a remote target device using PowerShell, you can use Remote PowerShell to establish a connection to a remote device and run these commands remotely on that device.
In an elevated PowerShell session, run either of the following commands depending on your target device architecture to download IoT Edge for Linux on Windows.
X64/AMD64
$msiPath = $([io.Path]::Combine($env:TEMP, 'AzureIoTEdge.msi')) $ProgressPreference = 'SilentlyContinue' Invoke-WebRequest "https://aka.ms/AzEFLOWMSI_1_4_LTS_X64" -OutFile $msiPath
ARM64
$msiPath = $([io.Path]::Combine($env:TEMP, 'AzureIoTEdge.msi')) $ProgressPreference = 'SilentlyContinue' Invoke-WebRequest "https://aka.ms/AzEFLOWMSI_1_4_LTS_ARM64" -OutFile $msiPath
Install IoT Edge for Linux on Windows on your device.
Start-Process -Wait msiexec -ArgumentList "/i","$([io.Path]::Combine($env:TEMP, 'AzureIoTEdge.msi'))","/qn"
You can specify custom IoT Edge for Linux on Windows installation and VHDX directories by adding
INSTALLDIR="<FULLY_QUALIFIED_PATH>"
andVHDXDIR="<FULLY_QUALIFIED_PATH>"
parameters to the install command. For example, if you want to use the D:\EFLOW folder for installation and the D:\EFLOW-VHDX for the VHDX, you can use the following PowerShell cmdlet.Start-Process -Wait msiexec -ArgumentList "/i","$([io.Path]::Combine($env:TEMP, 'AzureIoTEdge.msi'))","/qn","INSTALLDIR=D:\EFLOW", "VHDXDIR=D:\EFLOW-VHDX"
Set the execution policy on the target device to
AllSigned
if it is not already. See the PowerShell prerequisites for commands to check the current execution policy and set the execution policy toAllSigned
.Create the IoT Edge for Linux on Windows deployment. The deployment creates your Linux virtual machine and installs the IoT Edge runtime for you.
Deploy-Eflow
Tip
By default, the
Deploy-Eflow
command creates your Linux virtual machine with 1 GB of RAM, 1 vCPU core, and 16 GB of disk space. However, the resources your VM needs are highly dependent on the workloads you deploy. If your VM does not have sufficient memory to support your workloads, it will fail to start.You can customize the virtual machine's available resources using the
Deploy-Eflow
command's optional parameters. This is required to deploy EFLOW on a device with the minimum hardware requirements.For example, the following command creates a virtual machine with 1 vCPU core, 1 GB of RAM (represented in MB), and 2 GB of disk space:
Deploy-Eflow -cpuCount 1 -memoryInMB 1024 -vmDataSize 2
For information about all the optional parameters available, see PowerShell functions for IoT Edge for Linux on Windows.
Warning
By default, the EFLOW Linux virtual machine has no DNS configuration. Deployments using DHCP will try to obtain the DNS configuration propagated by the DHCP server. Please check your DNS configuration to ensure internet connectivity. For more information, see AzEFLOW-DNS.
You can assign a GPU to your deployment to enable GPU-accelerated Linux modules. To gain access to these features, you need to install the prerequisites detailed in GPU acceleration for Azure IoT Edge for Linux on Windows.
To use a GPU passthrough, add the gpuName, gpuPassthroughType, and gpuCount parameters to your
Deploy-Eflow
command. For information about all the optional parameters available, see PowerShell functions for IoT Edge for Linux on Windows.Warning
Enabling hardware device passthrough may increase security risks. Azure recommends a device mitigation driver from your GPU's vendor, when applicable. For more information, see Deploy graphics devices using discrete device assignment.
Enter 'Y' to accept the license terms.
Enter 'O' or 'R' to toggle Optional diagnostic data on or off, depending on your preference.
Once the deployment is complete, the PowerShell window reports Deployment successful.
After a successful deployment, you are ready to provision your device.
There are some steps to prepare your device for provisioning with TPM. Leave your deployment open while you prepare your device. You'll return to your deployment later in the article.
Enable TPM passthrough
The IoT Edge for Linux on Windows VM has a TPM feature that can be enabled or disabled. By default, it's disabled. When this feature is enabled, the VM can access the host machine's TPM.
Open PowerShell in an elevated session.
If you haven't already, set the execution policy on your device to
AllSigned
so that you can run the IoT Edge for Linux on Windows PowerShell functions.Set-ExecutionPolicy -ExecutionPolicy AllSigned -Force
Turn on the TPM feature.
Set-EflowVmFeature -feature 'DpsTpm' -enable
Retrieve the TPM information from your device
To provision your device, you need an Endorsement key for your TPM chip and Registration ID for your device. You provide this information to your instance of the device provisioning service so that the service can recognize your device when it tries to connect.
The endorsement key is unique to each TPM chip. It is obtained from the TPM chip manufacturer associated with it. You can derive a unique registration ID for your TPM device by, for example, creating an SHA-256 hash of the endorsement key.
IoT Edge for Linux on Windows provides a PowerShell script to help retrieve this information from your TPM. To use the script, follow these steps on your device:
Open PowerShell in an elevated session.
Run the command.
Get-EflowVmTpmProvisioningInfo | Format-List
Create a device provisioning service enrollment
Use your TPM's provisioning information to create an individual enrollment in the device provisioning service.
When you create an enrollment in the device provisioning service, you have the opportunity to declare an Initial Device Twin State. In the device twin, you can set tags to group devices by any metric used in your solution, like region, environment, location, or device type. These tags are used to create automatic deployments.
Tip
The steps in this article are for the Azure portal, but you can also create individual enrollments by using the Azure CLI. For more information, see az iot dps enrollment. As part of the CLI command, use the edge-enabled flag to specify that the enrollment is for an IoT Edge device.
In the Azure portal, go to your instance of the IoT Hub device provisioning service.
Under Settings, select Manage enrollments.
Select Add individual enrollment, and then complete the following steps to configure the enrollment:
For Mechanism, select TPM.
Provide the Endorsement key and Registration ID that you copied from your VM or physical device.
Provide an ID for your device if you want. If you don't provide a device ID, the registration ID is used.
Select True to declare that your VM or physical device is an IoT Edge device.
Choose the linked IoT hub that you want to connect your device to, or select Link to new IoT Hub. You can choose multiple hubs, and the device will be assigned to one of them according to the selected assignment policy.
Add a tag value to the Initial Device Twin State if you want. You can use tags to target groups of devices for module deployment. For more information, see Deploy IoT Edge modules at scale.
Select Save.
Now that an enrollment exists for this device, the IoT Edge runtime can automatically provision the device during installation.
Provision the device with its cloud identity
Open an elevated PowerShell session on the Windows device.
Provision your device by using the Scope ID that you collected from your instance of the device provisioning service.
Provision-EflowVM -provisioningType "DpsTpm" -scopeId "SCOPE_ID_HERE"
If you enrolled the device using a custom Registration Id, you must specify that registration ID as well when provisioning:
Provision-EflowVM -provisioningType "DpsTpm" -scopeId "SCOPE_ID_HERE" -registrationId "REGISTRATION_ID_HERE"
Verify successful installation
Verify that IoT Edge for Linux on Windows was successfully installed and configured on your IoT Edge device.
If the runtime started successfully, you can go into your IoT hub and start deploying IoT Edge modules to your device.
You can verify that the individual enrollment that you created in the device provisioning service was used. Go to your device provisioning service instance in the Azure portal. Open the enrollment details for the individual enrollment that you created. Notice that the status of the enrollment is assigned and the device ID is listed.
Use the following commands on your device to verify that the IoT Edge installed and started successfully.
Connect to your IoT Edge for Linux on Windows VM by using the following command in your PowerShell session:
Connect-EflowVm
Note
The only account allowed to SSH to the VM is the user who created it.
After you're signed in, you can check the list of running IoT Edge modules by using the following Linux command:
sudo iotedge list
If you need to troubleshoot the IoT Edge service, use the following Linux commands.
If you need to troubleshoot the service, retrieve the service logs.
sudo iotedge system logs
Use the
check
tool to verify configuration and connection status of the device.sudo iotedge check
Note
On a newly provisioned device, you may see an error related to IoT Edge Hub:
× production readiness: Edge Hub's storage directory is persisted on the host filesystem - Error
Could not check current state of edgeHub container
This error is expected on a newly provisioned device because the IoT Edge Hub module isn't running. To resolve the error, in IoT Hub, set the modules for the device and create a deployment. Creating a deployment for the device starts the modules on the device including the IoT Edge Hub module.
Uninstall IoT Edge for Linux on Windows
If you want to remove the Azure IoT Edge for Linux on Windows installation from your device, use the following commands.
- Open Settings on Windows
- Select Add or Remove Programs
- Select Azure IoT Edge app
- Select Uninstall
Next steps
The device provisioning service enrollment process lets you set the device ID and device twin tags at the same time as you provision the new device. You can use those values to target individual devices or groups of devices by using automatic device management.
Learn how to deploy and monitor IoT Edge modules at scale by using the Azure portal or the Azure CLI.