Make use of the TPM 2.0 in your Azure IoT Edge device to provision it using a Azure Device Provisioning Service.
This executable helps you to register your device TPM as an individual enrollment on a Azure Device Provisioning Service.
Pass Device Provisioning Service ID_Scope and RegistrationID as a command-prompt argument
Usage: [sudo] dotnet ProvisionTpm.dll <IDScope> <RegistrationID> <SkipTest:Y|N>
Note: Run this 'As Administrator' (Windows Powershell) or 'SUDO' (Linux)
The follow prerequisites are in place:
- Have a TPM 2.0 placed in your device
- Run Windows 10 1809 or a recent Linux verison
- Have a DPS created within your Azure subscription
- Get the ID Scope of your DPS
- Create a unique RegistrationID for your device
- Enable Windows feature for Containers or have Docker CE installed (needed at runtime)
The application is divided in two steps:
- Run this application with the ID scope and the RegistrationID and the optional device client test
- Retrieve an Endorsement key of your TPM
- The application asks you to press a key after the folloing steps (You can skip step 4 - 8 if executed already)
- Switch to the Azure Portal
- In your Azure Device Provisioning Service please go to 'Manage enrollments' and select 'Individual Enrollments'
- Select 'Add individual enrollment' and fill in:
- Mechanism 'TPM'
- Endorsement key
- Registration ID
- Switch over to the IoT Edge device enrollemnt is needed
- Set IoT Hub Device ID to the RegistrationId or any other valid DeviceID
- Check if the correct IoT Hub is selected
- Save this individual enrollment
- Within the application, press a key
- See how the applicaiton ends
Within the Azure portal, see that the device is registered now.
This tool should be working both on Windows and Linux due to the usage of .Net Core.
This tool is tested on:
- Windows 10 Enterprise 1809
- Windows 10 IoT Enterprise 1809
- Ubuntu 18.04
If you get this 'TbsCommandBlocked' execption during the execution of the application:
Unhandled Exception: Microsoft.Azure.Devices.Provisioning.Client.ProvisioningTransportException: AMQP transport exception ---> Tpm2Lib.TpmException: Error {TbsCommandBlocked} was returned for command ActivateCredential.
then check if you are running it as Adminsitrator or 'SU'.
This example is based on the TPM Example in: github.com/Azure-Samples/azure-iot-samples-csharp/tree/master/provisioning/Samples/device