About This Page
This page is part of the Azure documentation. It contains code examples and configuration instructions for working with Azure services.
Bias Analysis
Bias Types:
⚠️
windows_first
⚠️
missing_linux_example
⚠️
windows_tools
⚠️
powershell_heavy
Summary:
The documentation page exhibits a strong Windows bias. It consistently assumes a Windows development environment, especially in the C and C# sections, with prerequisites and instructions focused on Windows-only tools (e.g., Visual Studio, .NET Core on Windows, Simulator.exe). Linux and macOS alternatives are only briefly referenced via external links, and there are no inline, step-by-step instructions or examples for those platforms. The use of Windows command prompts and references to Windows-specific executables further reinforce this bias. There is also a lack of parity in providing Linux/macOS-specific build and run instructions, and troubleshooting tips are Windows-centric.
Recommendations:
- Provide explicit, inline instructions for Linux and macOS environments for each supported language, not just links to external SDK docs.
- Include Linux/macOS equivalents for all Windows-specific tools (e.g., suggest GCC/Clang and CMake for C, Mono or .NET Core for C#, and how to run the TPM simulator on non-Windows platforms).
- Show examples of building and running the TPM simulator and SDK samples on Linux/macOS, including terminal commands and any required dependencies.
- Avoid assuming Visual Studio or Windows command prompts as the default; offer cross-platform alternatives (e.g., VS Code, JetBrains Rider, or CLI-based workflows).
- List prerequisites for all major platforms in the main documentation, not just in external links.
- Where troubleshooting is discussed, include common issues and solutions for Linux/macOS users.
Create pull request
Flagged Code Snippets
This operation could take several minutes to complete.
6. When the operation is complete, run the following commands from the `azure-iot-sdk-c` directory:
>[!TIP]
>If `cmake` does not find your C++ compiler, you may get build errors while running the above command. If that happens, try running the command in the [Visual Studio command prompt](/dotnet/framework/tools/developer-command-prompt-for-vs).
2. When the build succeeds, the last few output lines look similar to the following output:
3. Go to the root folder of the git repository you cloned.
4. Run the [TPM](/windows/device-security/tpm/trusted-platform-module-overview) simulator using the path shown below.

3. Open a second command prompt.
4. In the second command prompt, navigate to the root folder and build the sample dependencies.
3. Save the file.
4. Use the following commands to build the project, navigate to the target folder, and execute the created .jar file (replace `{version}`with your version of Java):
5. When the program begins running, it will display the *_Endorsement key_* and *_Registration ID_*. Copy these values for the next section. Make sure to leave the program running.
::: zone-end
::: zone pivot="programming-language-csharp"
In this section, you'll build and execute a sample that reads the endorsement key from your TPM 2.0 hardware security module. This value will be used for device enrollment with your Device Provisioning Service instance.
1. In a command prompt, change directories to the project directory for the TPM device provisioning sample.
::: zone-end
::: zone pivot="programming-language-nodejs"
1. Open a Git CMD or Git Bash command-line environment.
2. Clone the [azure-utpm-c](https://github.com/Azure/azure-utpm-c) GitHub repository using the following command:
::: zone-end
::: zone pivot="programming-language-ansi-c, programming-language-nodejs, programming-language-java"
## Build and run the TPM device simulator
In this section, you'll build and run the TPM simulator. This simulator listens over a socket on ports 2321 and 2322. Don't close the command window. You'll need to keep this simulator running until the end of this quickstart.
::: zone-end
::: zone pivot="programming-language-ansi-c"
1. Run the following command to build Azure IoT C SDK that includes the TPM device simulator sample code. A Visual Studio solution for the simulated device is generated in the `cmake` directory. This sample provides a TPM [attestation mechanism](concepts-service.md#attestation-mechanism) via Shared Access Signature (SAS) Token authentication.
The simulator doesn't display any output. Let it continue to run as it simulates a TPM device.
::: zone-end
::: zone pivot="programming-language-nodejs"
1. Go to the GitHub root folder.
2. Run the [TPM](/windows/device-security/tpm/trusted-platform-module-overview) simulator to be the [HSM](https://azure.microsoft.com/blog/azure-iot-supports-new-security-hardware-to-strengthen-iot-security/) for the simulated device.
> [!NOTE]
> There are some known issues to installing the above packages. To resolve these issues, run `npm install --global --production windows-build-tools` using a command prompt in **Run as administrator** mode, run `SET VCTargetsPath=C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140` after replacing the path with your installed version, and then rerun the above installation commands.
>
5. Install all required packages running the following command at your command prompt in the **registerdevice** folder:
11. Run the sample.
12. The output window displays the **_Endorsement key_** and the **_Registration ID_** needed for device enrollment. Copy these values.
::: zone-end
::: zone pivot="programming-language-java"
1. Run the [TPM](/windows/device-security/tpm/trusted-platform-module-overview) simulator to be the [HSM](https://azure.microsoft.com/blog/azure-iot-supports-new-security-hardware-to-strengthen-iot-security/) for the simulated device.
2. Select **Allow Access**. The simulator listens over a socket on ports 2321 and 2322. Don't close this command window; you need to keep this simulator running until the end of this quickstart guide.
::: zone-end
::: zone pivot="programming-language-ansi-c, programming-language-csharp, programming-language-java"
<a id="simulatetpm"></a>
## Read cryptographic keys from the TPM device
::: zone-end
::: zone pivot="programming-language-ansi-c, programming-language-java"
In this section, you'll build and execute a sample that reads the endorsement key and registration ID from the TPM simulator you left running, and is still listening over ports 2321 and 2322. These values will be used for device enrollment with your Device Provisioning Service instance.
::: zone-end
::: zone pivot="programming-language-ansi-c"
1. Launch Visual Studio.
2. Open the solution generated in the *cmake* folder named `azure_iot_sdks.sln`.
3. On the Visual Studio menu, select **Build** > **Build Solution** to build all projects in the solution.
4. In Visual Studio's *Solution Explorer* window, navigate to the **Provision\_Tools** folder. Right-click the **tpm_device_provision** project and select **Set as Startup Project**.
5. On the Visual Studio menu, select **Debug** > **Start without debugging** to run the solution. The app reads and displays a **_Registration ID_** and an **_Endorsement key_**. Note or copy these values. These will be used in the next section for device enrollment.
::: zone-end
::: zone pivot="programming-language-java"
1. Sign in to the Azure portal, select the **All resources** button on the left-hand menu and open your Device Provisioning Service. Note your _ID Scope_ and _Provisioning Service Global Endpoint_.

2. Edit `src/main/java/samples/com/microsoft/azure/sdk/iot/ProvisioningTpmSample.java` to include your _ID Scope_ and _Provisioning Service Global Endpoint_ as noted before.
7. Right-click the **prov\_dev\_client\_sample** project and select **Set as Startup Project**.
8. On the Visual Studio menu, select **Debug** > **Start without debugging** to run the solution. In the prompt to rebuild the project, select **Yes**, to rebuild the project before running.
The following output is an example of the provisioning device client sample successfully booting up, and connecting to a Device Provisioning Service instance to get IoT hub information and registering:
::: zone-end
::: zone pivot="programming-language-csharp"
1. In the Azure portal, select the **Overview** tab for your Device Provisioning Service.
2. Copy the **_ID Scope_** value.

3. In a command prompt, change directories to the project directory for the TPM device provisioning sample.