![]() |
VOOZH | about |
dotnet tool install --global atc-azure-digitaltwin --version 3.0.0
dotnet new tool-manifestif you are setting up this repo
dotnet tool install --local atc-azure-digitaltwin --version 3.0.0
#tool dotnet:?package=atc-azure-digitaltwin&version=3.0.0
nuke :add-package atc-azure-digitaltwin --version 3.0.0
A .NET library and CLI tool for managing Azure Digital Twins — providing DTDL model validation, twin lifecycle management, relationship handling, event route configuration, telemetry publishing, and bulk import.
ServiceCollection extensions for seamless dependency injection setupInstall the NuGet package:
dotnet add package Atc.Azure.DigitalTwin
var digitalTwinService = serviceProvider.GetRequiredService<IDigitalTwinService>();
// Retrieve a twin
var twin = await digitalTwinService.GetTwinAsync("my-twin-id");
// Create a relationship
var (succeeded, errorMessage) = await digitalTwinService.CreateRelationshipAsync(
"source-twin-id",
"target-twin-id",
"relatesTo");
public void ConfigureServices(IServiceCollection services)
{
services.AddSingleton(new DigitalTwinOptions
{
TenantId = "your_tenant_id",
InstanceUrl = "your_instance_url",
});
services.ConfigureDigitalTwinsClient();
}
Comprehensive CRUD operations for models, twins, relationships, event routes, telemetry, components, and bulk import within an Azure Digital Twins instance.
var digitalTwinService = serviceProvider.GetRequiredService<IDigitalTwinService>();
// Query twins
var twins = await digitalTwinService.GetTwinsAsync("SELECT * FROM DIGITALTWINS", cancellationToken);
// Update a twin with JSON Patch
var patchDocument = new JsonPatchDocument();
patchDocument.AppendReplace("/temperature", 25.0);
await digitalTwinService.UpdateTwinAsync("my-twin-id", patchDocument, cancellationToken: cancellationToken);
// Manage event routes
await digitalTwinService.CreateOrReplaceEventRouteAsync(
"my-route",
"my-endpoint",
filter: "type = 'Microsoft.DigitalTwins.Twin.Update'",
cancellationToken: cancellationToken);
// Publish telemetry
await digitalTwinService.PublishTelemetryAsync("my-twin-id", "{\"temperature\": 25.0}");
// Get a twin component
var component = await digitalTwinService.GetComponentAsync<JsonElement>("my-twin-id", "thermostat");
// Bulk import from blob storage
var job = await digitalTwinService.ImportGraphAsync(
"my-job-id",
new Uri("https://storage.blob.core.windows.net/container/input.ndjson"),
new Uri("https://storage.blob.core.windows.net/container/output.ndjson"));
Local DTDL model storage, loading from directories, validation, and dependency-aware ordering.
var modelRepositoryService = serviceProvider.GetRequiredService<IModelRepositoryService>();
var modelsPath = new DirectoryInfo("path/to/models");
var isValid = await modelRepositoryService.ValidateModelsAsync(modelsPath, cancellationToken);
if (isValid)
{
await modelRepositoryService.LoadModelContentAsync(modelsPath, cancellationToken);
// Get models in dependency order (base models first)
var orderedContent = modelRepositoryService.GetModelsContentInDependencyOrder();
}
Parses JSON DTDL models into Digital Twin interface definitions with validation.
var parser = serviceProvider.GetRequiredService<IDigitalTwinParser>();
var (succeeded, interfaces) = await parser.ParseAsync(jsonModels);
if (succeeded)
{
foreach (var (dtmi, entity) in interfaces!)
{
Console.WriteLine($"Parsed: {dtmi}");
}
}
dotnet tool install --global atc-azure-digitaltwin
dotnet tool update --global atc-azure-digitaltwin
The CLI is organized into command groups:
# Validate models from a directory
atc-azure-digitaltwin model validate -d <directory-path>
# Create all models (dependency-ordered)
atc-azure-digitaltwin model create all --tenantId <tenant-id> -a <adt-instance-url> -d <directory-path>
# Create single model
atc-azure-digitaltwin model create single --tenantId <tenant-id> -a <adt-instance-url> -d <directory-path> -m <model-id>
# Get all models
atc-azure-digitaltwin model get all --tenantId <tenant-id> -a <adt-instance-url>
# Decommission a model
atc-azure-digitaltwin model decommission --tenantId <tenant-id> -a <adt-instance-url> -m <model-id>
# Delete all models
atc-azure-digitaltwin model delete all --tenantId <tenant-id> -a <adt-instance-url>
# Count twins by model
atc-azure-digitaltwin twin count --tenantId <tenant-id> -a <adt-instance-url>
# Create a twin
atc-azure-digitaltwin twin create --tenantId <tenant-id> -a <adt-instance-url> -t <twin-id> -m <model-id> -modelVersion <version> --jsonPayload <json>
# Get a twin
atc-azure-digitaltwin twin get --tenantId <tenant-id> -a <adt-instance-url> -t <twin-id>
# Update a twin with JSON Patch
atc-azure-digitaltwin twin update --tenantId <tenant-id> -a <adt-instance-url> -t <twin-id> --jsonPatch <json-patch>
# Delete all twins
atc-azure-digitaltwin twin delete all --tenantId <tenant-id> -a <adt-instance-url>
# Manage relationships
atc-azure-digitaltwin twin relationship create --tenantId <tenant-id> -a <adt-instance-url> --source-twinId <src> --target-twinId <tgt> --relationshipName <name>
atc-azure-digitaltwin twin relationship get all --tenantId <tenant-id> -a <adt-instance-url> -t <twin-id>
# Get/update twin components
atc-azure-digitaltwin twin component get --tenantId <tenant-id> -a <adt-instance-url> -t <twin-id> -c <component-name>
atc-azure-digitaltwin twin component update --tenantId <tenant-id> -a <adt-instance-url> -t <twin-id> -c <component-name> --jsonPatch <json-patch>
# Create an event route
atc-azure-digitaltwin route create --tenantId <tenant-id> -a <adt-instance-url> -e <route-id> --endpointName <endpoint>
# Get all event routes
atc-azure-digitaltwin route get all --tenantId <tenant-id> -a <adt-instance-url>
# Delete an event route
atc-azure-digitaltwin route delete --tenantId <tenant-id> -a <adt-instance-url> -e <route-id>
# Run an ADT query
atc-azure-digitaltwin query --tenantId <tenant-id> -a <adt-instance-url> -q "SELECT * FROM DIGITALTWINS"
# Publish telemetry for a twin
atc-azure-digitaltwin telemetry publish --tenantId <tenant-id> -a <adt-instance-url> -t <twin-id> -p '{"temperature": 25.0}'
# Create a bulk import job
atc-azure-digitaltwin import create --tenantId <tenant-id> -a <adt-instance-url> --jobId <job-id> --inputBlobUri <input-uri> --outputBlobUri <output-uri>
# Get import job status
atc-azure-digitaltwin import get single --tenantId <tenant-id> -a <adt-instance-url> --jobId <job-id>
# List all import jobs
atc-azure-digitaltwin import get all --tenantId <tenant-id> -a <adt-instance-url>
# Cancel a running import job
atc-azure-digitaltwin import cancel --tenantId <tenant-id> -a <adt-instance-url> --jobId <job-id>
# Delete an import job
atc-azure-digitaltwin import delete --tenantId <tenant-id> -a <adt-instance-url> --jobId <job-id>
Use --help on any command for detailed options:
atc-azure-digitaltwin --help
atc-azure-digitaltwin model --help
atc-azure-digitaltwin twin relationship get --help
See the for a complete example demonstrating model validation, twin creation, querying, and cleanup using the DTDL models in the .
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 net10.0 is compatible. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
This package has no dependencies.