Hello @Vibha , Please as part of Prerequisite, create an AAD app and provide the Redirect URI as per the instructions.
Below image shows how i registered my app in AAD.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Code snippet:
using System;
using Azure.DigitalTwins.Core;
using Azure.Identity;
using System.Threading.Tasks;
using System.IO;
using System.Collections.Generic;
using Azure;
//using Azure.DigitalTwins.Core.Models;
using Azure.DigitalTwins.Core.Serialization;
using System.Text.Json;
namespace ADT
{
class Program
{
static async Task Main(string[] args)
{
Console.WriteLine("Hello World!");
string clientId = "xxxxxxxxxxxx";
string tenantId = "xxxxxxxxxxxx";
string adtInstanceUrl = "https://xxxxxxx.digitaltwins.azure.net";
var credentials = new InteractiveBrowserCredential(tenantId, clientId);
DigitalTwinsClient client = new DigitalTwinsClient(new Uri(adtInstanceUrl), credentials);
Console.WriteLine($"Service client created – ready to go");
Console.WriteLine();
Console.WriteLine($"Upload a model");
var typeList = new List<string>();
string dtdl = File.ReadAllText("sample.json");
typeList.Add(dtdl);
// Upload the model to the service
try
{
await client.CreateModelsAsync(typeList);
Console.WriteLine($"Model Uploaded Successfully");
}
catch (RequestFailedException rfe)
{Console.WriteLine($"{rfe.Message}");}
}
}
}
Hello @Vibha , Please as part of Prerequisite, create an AAD app and provide the Redirect URI as per the instructions.
Below image shows how i registered my app in AAD.