This page contains Windows bias

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:
⚠️ missing_linux_example
⚠️ windows_first
Summary:
The tutorial consistently refers to using a 'console window' and provides all command-line examples in a generic 'cmd/sh' block, but does not provide any Linux- or macOS-specific instructions, troubleshooting, or environment notes. There are tips and notes for Visual Studio (a Windows-centric IDE), but no equivalent guidance for Linux editors or tools. The documentation implicitly assumes a Windows environment or at least Windows patterns, with no explicit Linux parity.
Recommendations:
  • Explicitly mention that all commands work on Linux/macOS terminals as well as Windows Command Prompt/PowerShell.
  • Provide Linux/macOS-specific notes where appropriate (e.g., file paths, terminal commands, environment variable setting).
  • Include troubleshooting tips for common Linux/macOS issues (such as permissions or .NET SDK installation differences).
  • Offer editor/IDE tips for Linux users (e.g., VS Code, JetBrains Rider) alongside Visual Studio notes.
  • Clarify that the .NET SDK and Azure Digital Twins tools are cross-platform, and link to platform-specific installation guides where relevant.
GitHub Create pull request

Scan History

Date Scan ID Status Bias Status
2025-07-12 23:44 #41 in_progress ❌ Biased
2025-07-12 00:58 #8 cancelled ✅ Clean
2025-07-10 05:06 #7 processing ✅ Clean

Flagged Code Snippets

This command restores the dependencies on first run, and then executes the program. * If no error occurs, the program prints: "Service client created - ready to go". * Since there isn't yet any error handling in this project, if there are any issues, you see an exception thrown by the code. [!INCLUDE [Azure Digital Twins: DefaultAzureCredential known issue note](includes/digital-twins-defaultazurecredential-note.md)] ### Upload a model Azure Digital Twins has no intrinsic domain vocabulary. You use *models* to define the types of elements in your environment that you can represent in Azure Digital Twins. [Models](concepts-models.md) are similar to classes in object-oriented programming languages; they provide user-defined templates for [digital twins](concepts-twins-graph.md) to follow and instantiate later. They're written in a JSON-like language called *Digital Twins Definition Language (DTDL)*. The first step in creating an Azure Digital Twins solution is defining at least one model in a DTDL file. In the directory where you created your project, create a new .json file called *SampleModel.json*. Paste in the following file body: :::code language="json" source="~/digital-twins-docs-samples/models/SampleModel.json"::: > [!TIP] > If you're using Visual Studio for this tutorial, you might want to select the newly created JSON file and set the **Copy to Output Directory** property in the Property inspector to **Copy if Newer** or **Copy Always**. This property value enables Visual Studio to find the JSON file with the default path when you run the program with F5 during the rest of the tutorial. > [!TIP] > You can check model documents to make sure the DTDL is valid using the [DTDLParser library](https://www.nuget.org/packages/DTDLParser). For more about using this library, see [Parse and validate models](how-to-parse-models.md). Next, add some more code to *Program.cs* to upload the model you created into your Azure Digital Twins instance. First, add a few `using` statements to the top of the file: :::code language="csharp" source="~/digital-twins-docs-samples/sdks/csharp/fullClientApp.cs" id="Model_dependencies"::: Next, prepare to use the asynchronous methods in the C# service SDK, by changing the `Main` method signature to allow for async execution. :::code language="csharp" source="~/digital-twins-docs-samples/sdks/csharp/fullClientApp.cs" id="Async_signature"::: > [!NOTE] > Using `async` isn't strictly required, as the SDK also provides synchronous versions of all calls. This tutorial practices using `async`. Next comes the first bit of code that interacts with the Azure Digital Twins service. This code loads the DTDL file you created from your disk, and then uploads it to your Azure Digital Twins service instance. Paste in the following code under the authorization code you added earlier. :::code language="csharp" source="~/digital-twins-docs-samples/sdks/csharp/fullClientApp_excerpt_model.cs" id="ClientExcerptModel"::: In your command window, run the program with this command:
## Get started with project code In this section, you begin writing the code for your new app project to work with Azure Digital Twins. The actions covered include: * Authenticating against the service * Uploading a model * Catching errors * Creating digital twins * Creating relationships * Querying digital twins There's also a section showing the complete code at the end of the tutorial. You can use this section as a reference to check your program as you go. To begin, open the file *Program.cs* in any code editor. You see a minimal code template that looks something like this: :::image type="content" source="media/tutorial-code/starter-template.png" alt-text="Screenshot of a snippet of sample code in a code editor." lightbox="media/tutorial-code/starter-template-large.png"::: First, add some `using` lines at the top of the code to pull in necessary dependencies. :::code language="csharp" source="~/digital-twins-docs-samples/sdks/csharp/fullClientApp.cs" id="Azure_Digital_Twins_dependencies"::: Next, you add code to this file to fill out some functionality. ### Authenticate against the service The first thing your app needs to do is authenticate against the Azure Digital Twins service. Then, you can create a service client class to access the SDK functions. To authenticate, you need the host name of your Azure Digital Twins instance. In *Program.cs*, paste the following code below the "Hello, World!" print line in the `Main` method. Set the value of `adtInstanceUrl` to your Azure Digital Twins instance host name. :::code language="csharp" source="~/digital-twins-docs-samples/sdks/csharp/fullClientApp.cs" id="Authentication_code"::: Save the file. In your command window, run the code with this command: