Azure.DigitalTwins.Core 1.4.0

The ID prefix of this package has been reserved for one of the owners of this package by Prefix Reserved
.NET Standard 2.0
dotnet add package Azure.DigitalTwins.Core --version 1.4.0
NuGet\Install-Package Azure.DigitalTwins.Core -Version 1.4.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Azure.DigitalTwins.Core" Version="1.4.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Azure.DigitalTwins.Core --version 1.4.0
#r "nuget: Azure.DigitalTwins.Core, 1.4.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Azure.DigitalTwins.Core as a Cake Addin
#addin nuget:?package=Azure.DigitalTwins.Core&version=1.4.0

// Install Azure.DigitalTwins.Core as a Cake Tool
#tool nuget:?package=Azure.DigitalTwins.Core&version=1.4.0

Azure IoT Digital Twins client library for .NET

This library provides access to the Azure Digital Twins service for managing twins, models, relationships, etc.

Source code | Package (nuget)

Getting started

The complete Microsoft Azure SDK can be downloaded from the Microsoft Azure downloads page, and it ships with support for building deployment packages, integrating with tooling, rich command line tooling, and more.

For the best development experience, developers should use the official Microsoft NuGet packages for libraries. NuGet packages are regularly updated with new functionality and hotfixes.

Install the package

Install the Azure Digital Twins client library for .NET with NuGet:

dotnet add package Azure.DigitalTwins.Core

View the package details at


Authenticate the Client

In order to interact with the Azure Digital Twins service, you will need to create an instance of a TokenCredential class and pass it to the constructor of your DigitalTwinsClient.

Key concepts

Azure Digital Twins Preview is an Azure IoT service that creates comprehensive models of the physical environment. It can create spatial intelligence graphs to model the relationships and interactions between people, spaces, and devices.

You can learn more about Azure Digital Twins by visiting Azure Digital Twins Documentation

Thread safety

We guarantee that all client instance methods are thread-safe and independent of each other (guideline). This ensures that the recommendation of reusing client instances is always safe, even across threads.

Additional concepts

Client options | Accessing the response | Long-running operations | Handling failures | Diagnostics | Mocking | Client lifetime


You can familiarize yourself with different APIs using samples for Digital Twins.

Source code folder structure


The Digital Twins public client, DigitalTwinsClient, and the additional configuration options, DigitalTwinsClientOptions, that can be sent to the Digital Twins service.


The code generated by autorest using the swagger file defined in the autorest config file.

To regenerate the code, run the powershell script generate.ps1.

Any time the client library code is updated, the following scripts need to be run:


The customzied code written to override the following behavior of auto-generated code:

  • Rename some of the generated types, eg. GetModelsOptions
  • Declare some of the generated types as internal, instead of the autorest default of public.
  • Declare some methods to accept input parameters as strings instead of objects.
  • Declare some methods to return the response as strings instead of objects.


Model classes useful for use with the Digital Twins client operations.


Assembly properties required for running unit tests.


Serialization helpers provided to help serialize/deserialize commonly used types within the Digital Twins service.


All service operations will throw RequestFailedException on failure reported by the service, with helpful error codes and other information.

For example, use the GetModelAsync operation to check if the model exists before creating it, catch only when that specific HttpStatusCode is specified.

    Response<ModelData> desiredModel = await DigitalTwinsClient.GetModelAsync(desiredModelId);
catch (RequestFailedException ex) when (ex.Status == (int)HttpStatusCode.NotFound)
    // Model does not exist, so create it.

Next steps

See implementation examples with our code samples.


This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit

When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact with any additional questions or comments.

Product Versions
.NET net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows net7.0 net7.0-android net7.0-ios net7.0-maccatalyst net7.0-macos net7.0-tvos net7.0-windows
.NET Core netcoreapp2.0 netcoreapp2.1 netcoreapp2.2 netcoreapp3.0 netcoreapp3.1
.NET Standard netstandard2.0 netstandard2.1
.NET Framework net461 net462 net463 net47 net471 net472 net48 net481
MonoAndroid monoandroid
MonoMac monomac
MonoTouch monotouch
Tizen tizen40 tizen60
Xamarin.iOS xamarinios
Xamarin.Mac xamarinmac
Xamarin.TVOS xamarintvos
Xamarin.WatchOS xamarinwatchos
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (7)

Showing the top 5 NuGet packages that depend on Azure.DigitalTwins.Core:

Package Downloads

Package Description

Microsoft.DigitalWorkplace.DigitalTwins.QueryBuilder The ID prefix of this package has been reserved for one of the owners of this package by

A C# query builder for Azure Digital Twins based on Azure Digital Twins SDK.


Domain Model C# Code Generator Library for Azure Digital Twins as External Storage

Microsoft.SmartPlaces.Facilities.IngestionManager The ID prefix of this package has been reserved for one of the owners of this package by

This is library injects data from one DTDL based graph, then converts and inserts the data into another DTDL base graph.

Microsoft.SmartPlaces.Facilities.IngestionManager.Mapped The ID prefix of this package has been reserved for one of the owners of this package by

Support for converting from a Mapped DTDL-based Ontology to a different DTDL Based Ontology

GitHub repositories (3)

Showing the top 3 popular GitHub repositories that depend on Azure.DigitalTwins.Core:

Repository Stars
Enterprise HealthChecks for ASP.NET Core Diagnostics Package
How to implement a streaming at scale solution in Azure
AZ-220: Microsoft Azure IoT Developer
Version Downloads Last updated
1.4.0 84,459 7/9/2022
1.4.0-beta.1 3,185 3/25/2022
1.3.0-beta.2 2,373 8/6/2021
1.3.0-beta.1 169 8/4/2021
1.2.2 174,786 4/12/2021
1.2.1 11,616 2/4/2021
1.2.0 88,666 11/16/2020
1.0.1 1,957 11/5/2020
1.0.0 2,071 10/30/2020
1.0.0-preview.3 13,334 7/13/2020
1.0.0-preview.2 7,321 6/8/2020