Integrate Azure Digital Twins with Ansys Twin Builder

Published Nov 10 2021 09:00 AM 2,800 Views
Microsoft

Digital Twins are virtual representations of real-world entities and processes, synchronized at a specified frequency and fidelity to track the past, provide deeper insights into the present, predict and influence future behavior. Simulation is the killer application that allows you to predict the future states of your digital twin. Those simulations can then goal seek to find optimizations that are too complex to find by monitoring the physical environment alone. Once the simulation is completed, you can apply the insights that you have gained back to the real digital twin and affect inputs into the physical environment.

 

Physics-based simulations integrate physical principals such as hydraulics, collision detection, rigid body dynamics and motion into the modeling and learning process. Combining data-driven modeling approaches with physics-based approaches while building digital twin and IoT solutions allows us to create virtual sensors to “measure” missing data, perform what-ifs before applying a solution, analyze accurate and deterministic predictions based on physical principles and explore causality and failure modes using physics.

 

ANSYS is a leader in the simulation world. ANSYS Twin Builder combines the power of physics-based simulations with analytics-driven digital twins. Tata Consultancy Services, ANSYS Twin Builder and Microsoft Azure IoT teams came together to integrate physics-based simulations with Azure Digital Twins and IoT data.  

 

This article is meant to provide guidelines to developers whose goal is to implement physics-based simulations for their digital twin solutions leveraging the integration between Ansys Twin Builder and Azure Digital Twins.

 

Here is a diagram showing how Azure Digital Twins and Ansys Twin Builder Runtime could take part in an end-to-end IoT solution:

 

Simulation based digital twin architectureSimulation based digital twin architecture

 

In this article, we will focus on how to implement the integration between Azure Digital Twins and the Ansys Twin Builder runtime:

 

blog_image2.png

 

You can use Azure Digital Twins to represent your asset hierarchy. It helps you keep twin data as well as a live execution environment where you can create endpoints and subscribe to twin change events. The twin can be anything based on your functional requirements and conforming to the domain specific ontology.

 

In the above example, the updates in the digital twin on specific models trigger an event that invokes the Ansys Digital Twin Runtime and the results are saved back to the Azure Digital Twins instance.

 

Twin processor will be the core function or integrator between the Azure Digital Twins instance and the Ansys Digital Twin Runtime. Please find the process diagram below.

 

Simulation execution process flowSimulation execution process flow

 

Ansys Twin Builder and Ansys Twin Deployer will be used to generate the models representing the asset to monitor and export a digital twin runtime that can be made available in the environment to run the simulations. Ansys Digital Twin Runtime exposes multiple APIs (interface specification is attached to this article), all of which should be invoked in a specific order to get the response from Ansys as described in the architecture section.

 

In a “real” digital twin application, the digital twin instance is connected to IoT data streams to keep the digital twin “alive” and there would be a continuous evaluation of the simulation runtime based on the new data coming from the connected assets. In some cases, you might have a static digital twin where you might not have IoT data streams yet and the simulation models might be static and need to be evaluated one single time. Depending on your case, the sequence of core functions to invoke on the Ansys Digital Twin runtime from the Twin Processor function are listed below:

 

  • Initialization phase
    1. Receive twin update
    2. Prepare the requested parameters and inputs to invoke the Ansys Digital Twin Runtime
    3. Invoke the Ansys Digital Twin Runtime API
      1. Invoke model load API
      2. Invoke model instantiate API
      3. Invoke set parameters API
      4. Invoke set inputs API
      5. Invoke model initialize API
      6. Invoke get output API  (if your digital twin is static, invoke close API and stop at step v and don’t execute the “running phase”)
    4. Prepare the simulation result object
    5. Update the digital twin with the simulation result
  • Running phase
    1. Receive Twin update
    2. Prepare the requested inputs to invoke Ansys Digital Twin Runtime
    3. Invoke Ansys Digital Twin Runtime API
      1. Invoke simulation step or simulation batch API
    4. Prepare the simulation result object
    5. Update the digital twin with the simulation result
  • Closing phase
    1. Invoke close API

 

Running Ansys Digital Twin Runtime Service

 

Ansys Digital Twin Runtime is made available in a “tar.gz” format of Docker image. We need to run the container from the GZip file. For that, we need to first load that Docker image into an Azure Container Registry. The instructions to create an Azure Container Registry can be found here.

 

As a pre-requisite, you will need to upload the tar.gz file to any repository. Then, you can use the below YAML code in Azure Devops to create a pipeline for that process. You need to specify <Your Repo Folder Path> and <Your Container Registry Id> in the script below. You can then run the pipeline to create a Docker container on the specified Azure Container Registry:

 

# Variable 'Source_FileName' was defined in the Variables tab
# Variable 'Source_ImageName' was defined in the Variables tab
# Variable 'Source_Tag' was defined in the Variables tab
# Variable 'Target_ACR' was defined in the Variables tab
# Variable 'Target_ImageName' was defined in the Variables tab
# Variable 'Target_Tag' was defined in the Variables tab
resources:
  repositories:
  - repository: self
    type: git
    ref: <Your Repo Folder Path>
jobs:
- job: Job_1
  displayName: Docker push
  pool:
    vmImage: ubuntu-16.04
  steps:
  - checkout: self
  - task: CopyFiles@2
    displayName: Copy Files From Repo
    inputs:
      SourceFolder: DockerImage
      TargetFolder: $(build.artifactstagingdirectory)
  - task: Docker@2
    displayName: login
    inputs:
      containerRegistry: <Your Container Registry Id>
      command: login
  - task: CmdLine@2
    displayName: Command Line Script
    inputs:
      script: "docker image load --input $(build.artifactstagingdirectory)/$(Source_FileName)\n\ndocker image ls\n   \ndocker image tag $(Source_ImageName):$(Source_Tag) $(Target_ACR)/$(Target_ImageName):$(Target_Tag)\n\ndocker push $(Target_ACR)/$(Target_ImageName):$(Target_Tag)"
  - task: Docker@2
    displayName: logout
    inputs:
      containerRegistry: <Your Container Registry Id>
      command: logout

 

As a second step, you will need to create an App Service in Azure with Docker based deployment. While creating the App Service, you can select the new Docker image as the application source.

 

Now your Ansys Digital Twin Runtime service is ready to serve the requests.

 

Twin Processor Azure Function Implementation

 

This function plays the role of integrator which will be invoked with Azure Digital Twin event trigger. You can follow the steps here to set up the endpoints, routes and create the Azure Function that watches for twin life cycle events that should trigger the Ansys Digital Twin Runtime and reflect the changes back to the Azure Digital Twins instance.

 

Once the Azure Function receives any specific trigger to call the Ansys Digital Twin Runtime, it needs to prepare the request body with specific parameters and invoke services in sequence. As an initial setup you can specify the URLs as follows:

_loadUrl = _config["Ansys  BaseUrl"] + "/restAPI/load_model";
_instantiateUrl = _config["Ansys  BaseUrl"] + "/restAPI/instantiate_model";
_initializeUrl = _config["Ansys  BaseUrl"] + "/restAPI/initialize_model";
_setParametersUrl = _config["Ansys  BaseUrl"] + "/restAPI/set_parameters";
_setInputsUrl = _config["Ansys  BaseUrl"] + "/restAPI/set_inputs";
_simulationStepUrl = _config["Ansys  BaseUrl"] + "/restAPI/simulation_step ";
_simulationBatchUrl = _config["Ansys  BaseUrl"] + "/restAPI/simulation_batch ";_getOutputsUrl = _config["Ansys  BaseUrl"] + "/restAPI/get_outputs";
_closeUrl = _config["Ansys  BaseUrl"] + "/restAPI/close_model";

 

Then you can invoke the below APIs. You need to call the “Close Model” API in case any failure happens in the sequence, to unload the model. You can use the below code snippet for this:

 

status = await Ansys  LoadAsync(AnsysModelId, token);
 if (!status)
{
await Ansys  CloseAsync(AnsysModelId, token);
return (false, null);
}

 

Invoke - Load Model API

 

You can use the code snippet provided below to load the Ansys Digital Twin Runtime model:

private async Task<bool> AnsysLoadAsync(string AnsysModelId, CancellationToken token)
{
Uri loadUri = new Uri(_loadUrl).AddQueryParameter("modelname", AnsysModelId);
HttpResponseMessage response = await _httpClinetAdapter.GetAsync(loadUri, token);
return response.IsSuccessStatusCode;
}

 

Invoke - Model Instantiate API

 

You can use the code snippet provided below to instantiate the Ansys Digital Twin Runtime model:

private async Task<bool> AnsysInstantiateAsync(string AnsysModelId, CancellationToken token)
{
Uri loadUri = new Uri(_instantiateUrl).AddQueryParameter("modelname", AnsysModelId);
HttpResponseMessage response = await _httpClinetAdapter.GetAsync(loadUri, token);
return response.IsSuccessStatusCode;
}

 

 Invoke - Set Parameters API

 

You can use the code snippet provided below to set parameters for the  Ansys Digital Twin Runtime model:

private async Task<bool> AnsysSetParametersAsync(string AnsysModelId, string parameters, CancellationToken token)
{
Uri loadUri = new Uri(_setParametersUrl);
SimulationRequest simulationRequest = new SimulationRequest
{
ModelName = AnsysModelId,
Parameters = parameters
};
string content = JsonConvert.SerializeObject(simulationRequest);
using StringContent stringContent = new StringContent(content, Encoding.UTF8, "application/json");
HttpResponseMessage response = await _httpClinetAdapter.PostAsync(loadUri, stringContent, token);
string jsonResponse = await response.Content.ReadAsStringAsync();
return response.IsSuccessStatusCode;
}

 

Invoke - Set Inputs API

 

You can use the code snippet provided below to set inputs for the Ansys Digital Twin Runtime model:

private async Task<bool> AnsysSetInputsAsync(string AnsysModelId, string inputs, CancellationToken token)
{
Uri loadUri = new Uri(_setInputsUrl);
SimulationRequest simulationRequest = new SimulationRequest
{
ModelName = AnsysModelId,
Inputs = inputs
};
string content = JsonConvert.SerializeObject(simulationRequest);
using StringContent stringContent = new StringContent(content, Encoding.UTF8, "application/json");
HttpResponseMessage response = await _httpClinetAdapter.PostAsync(loadUri, stringContent, token);
string jsonResponse = await response.Content.ReadAsStringAsync();
return response.IsSuccessStatusCode;
}

 

Invoke - Model Initialize API

 

You can use the code snippet provided below to initialize the Ansys Digital Twin Runtime model:

private async Task<bool> AnsysInitializeAsync(string AnsysModelId, CancellationToken token)
{
Uri loadUri = new Uri(_initializeUrl).AddQueryParameter("modelname", AnsysModelId);
HttpResponseMessage response = await _httpClinetAdapter.GetAsync(loadUri, token);
return response.IsSuccessStatusCode;
}

 

 Invoke – Simulation Step API

 

You can use the code snippet provided below to simulate one step with the Ansys Digital Twin Runtime model:

private async Task<bool> AnsysSimulationStepAsync(string AnsysModelId, string inputs, string endtime, CancellationToken token)
{
Uri loadUri = new Uri(_simulationStep Url);
SimulationRequest simulationRequest = new SimulationRequest
{
ModelName = AnsysModelId,
Inputs = inputs
Endtime = endtime
};
string content = JsonConvert.SerializeObject(simulationRequest);
using StringContent stringContent = new StringContent(content, Encoding.UTF8, "application/json");
HttpResponseMessage response = await _httpClinetAdapter.PostAsync(loadUri, stringContent, token);
string jsonResponse = await response.Content.ReadAsStringAsync();
return (response.IsSuccessStatusCode, jsonResponse);

}

 

Invoke – Simulation Batch API

 

You can use the code snippet provided below to simulate a batch of data at once with the Ansys Digital Twin Runtime model:

private async Task<bool> AnsysSimulationBatchAsync(string AnsysModelId, string inputs, CancellationToken token)
{
Uri loadUri = new Uri(_simulationStep Url);
SimulationRequest simulationRequest = new SimulationRequest
{
ModelName = AnsysModelId,
Inputs = inputs
};
string content = JsonConvert.SerializeObject(simulationRequest);
using StringContent stringContent = new StringContent(content, Encoding.UTF8, "application/json");
HttpResponseMessage response = await _httpClinetAdapter.PostAsync(loadUri, stringContent, token);
string jsonResponse = await response.Content.ReadAsStringAsync();
return (response.IsSuccessStatusCode, jsonResponse);
}

 

Invoke - Get Output API

 

You can use the code snippet provided below to get output from the Ansys Digital Twin Runtime:

private async Task<(bool, string)> AnsysGetOutputsAsync(string AnsysModelId, CancellationToken token)
{
Uri loadUri = new Uri(_getOutputsUrl).AddQueryParameter("modelname", AnsysModelId);
HttpResponseMessage response = await _httpClinetAdapter.GetAsync(loadUri, token);
string jsonResponse = await response.Content.ReadAsStringAsync();
return (response.IsSuccessStatusCode, jsonResponse);
}

 

Now you have the results from the Ansys Digital Twin Runtime API, which can be used to update the digital twin.

 

Invoke – Close Model API

 

You can use the code snippet provided below to close the model in the Ansys Digital Twin Runtime:

private async Task<bool> AnsysCloseAsync(string AnsysModelId, CancellationToken token)
{
Uri loadUri = new Uri(_closeUrl).AddQueryParameter("modelname", AnsysModelId);
HttpResponseMessage response = await _httpClinetAdapter.GetAsync(loadUri, token);
return response.IsSuccessStatusCode;
}

 

We have completed the Ansys Digital Twin Runtime invocation. To ease and automate the process, you can deploy the Twin Processor function based on a Docker image and create a devops pipeline for it. You can use below YAML to create a Docker based application for the Twin Processor function. You need to specify <Your Container Registry Id> in the script below:

jobs:
- job: Twin Processor Docker Push
  displayName: AgentJob1
  pool:
    vmImage: ubuntu-16.04
  steps:
  - checkout: self
  - task: DotNetCoreCLI@2
    displayName: dotnet restore
    inputs:
      command: restore
      projects: TwinProcessor.sln
  - task: DotNetCoreCLI@2
    displayName: dotnet build
    inputs:
      projects: TwinProcessor.sln
      arguments: --configuration Release
  - task: CopyFiles@2
    displayName: 'Copy Files to: $(Build.ArtifactStagingDirectory)'
    inputs:
      TargetFolder: $(Build.ArtifactStagingDirectory)
  - task: Docker@2
    displayName: login
    inputs:
      containerRegistry: <Your Container Registry Id>
      command: login
  - task: Docker@2
    displayName: buildAndPush
    inputs:
      containerRegistry: <Your Container Registry Id>
      repository: ADTTwinProcessor
      Dockerfile: TwinProcessDockerfile
  - task: Docker@2
    displayName: logout
    inputs:
      containerRegistry: <Your Container Registry Id>
      command: logout
  - task: PublishBuildArtifacts@1
    displayName: 'Publish Artifact: drop'
    enabled: False

 

The above pipeline will create a Docker container for your Twin Processor Azure Function.

 

Build your own simulation based digital twins

 

Learn more about simulation based digital twins and start building your own with Azure Digital Twins and Ansys Twin Builder Free Trial

 

Please keep the discussion going. Leave your questions and comments below.

 

%3CLINGO-SUB%20id%3D%22lingo-sub-2939616%22%20slang%3D%22en-US%22%3EIntegrate%20Azure%20Digital%20Twins%20with%20Ansys%20Twin%20Builder%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2939616%22%20slang%3D%22en-US%22%3E%3CP%20class%3D%22lia-align-justify%22%3EDigital%20Twins%20are%20virtual%20representations%20of%20real-world%20entities%20and%20processes%2C%20synchronized%20at%20a%20specified%20frequency%20and%20fidelity%20to%20track%20the%20past%2C%20provide%20deeper%20insights%20into%20the%20present%2C%20predict%20and%20influence%20future%20behavior.%20Simulation%20is%20the%20killer%20application%20that%20allows%20you%20to%20predict%20the%20future%20states%20of%20your%20digital%20twin.%20Those%20simulations%20can%20then%20goal%20seek%20to%20find%20optimizations%20that%20are%20too%20complex%20to%20find%20by%20monitoring%20the%20physical%20environment%20alone.%20Once%20the%20simulation%20is%20completed%2C%20you%20can%20apply%20the%20insights%20that%20you%20have%20gained%20back%20to%20the%20real%20digital%20twin%20and%20affect%20inputs%20into%20the%20physical%20environment.%3C%2FP%3E%0A%3CP%20class%3D%22lia-align-justify%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20class%3D%22lia-align-justify%22%3EPhysics-based%20simulations%20integrate%20physical%20principals%20such%20as%20hydraulics%2C%20collision%20detection%2C%20rigid%20body%20dynamics%20and%20motion%20into%20the%20modeling%20and%20learning%20process.%20Combining%20data-driven%20modeling%20approaches%20with%20physics-based%20approaches%20while%20building%20digital%20twin%20and%20IoT%20solutions%20allows%20us%20to%20create%20virtual%20sensors%20to%20%E2%80%9Cmeasure%E2%80%9D%20missing%20data%2C%20perform%20what-ifs%20before%20applying%20a%20solution%2C%20analyze%20accurate%20and%20deterministic%20predictions%20based%20on%20physical%20principles%20and%20explore%20causality%20and%20failure%20modes%20using%20physics.%3C%2FP%3E%0A%3CP%20class%3D%22lia-align-justify%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20class%3D%22lia-align-justify%22%3E%3CA%20href%3D%22https%3A%2F%2Fwww.ansys.com%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3EANSYS%3C%2FA%3E%20is%20a%20leader%20in%20the%20simulation%20world.%20%3CA%20href%3D%22https%3A%2F%2Fwww.ansys.com%2Fproducts%2Fdigital-twin%2Fansys-twin-builder%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3EANSYS%20Twin%20Builder%3C%2FA%3E%20combines%20the%20power%20of%20physics-based%20simulations%20with%20analytics-driven%20digital%20twins.%20%3CA%20href%3D%22https%3A%2F%2Fwww.tcs.com%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3ETata%20Consultancy%20Services%3C%2FA%3E%2C%20%3CA%20href%3D%22https%3A%2F%2Fwww.ansys.com%2Fproducts%2Fdigital-twin%2Fansys-twin-builder%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3EANSYS%20Twin%20Builder%3C%2FA%3E%20and%20%3CA%20href%3D%22https%3A%2F%2Fazure.microsoft.com%2Foverview%2Fiot%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EMicrosoft%20Azure%20IoT%3C%2FA%3E%20teams%20came%20together%20to%20integrate%20physics-based%20simulations%20with%20%3CA%20href%3D%22https%3A%2F%2Fazure.microsoft.com%2Fservices%2Fdigital-twins%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EAzure%20Digital%20Twins%3C%2FA%3E%20and%20IoT%20data.%20%26nbsp%3B%3C%2FP%3E%0A%3CP%20class%3D%22lia-align-justify%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20class%3D%22lia-align-justify%22%3EThis%20article%20is%20meant%20to%20provide%20guidelines%20to%20developers%20whose%20goal%20is%20to%20implement%20physics-based%20simulations%20for%20their%20digital%20twin%20solutions%20leveraging%20the%20integration%20between%20Ansys%20Twin%20Builder%20and%20Azure%20Digital%20Twins.%3C%2FP%3E%0A%3CP%20class%3D%22lia-align-justify%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20class%3D%22lia-align-justify%22%3EHere%20is%20a%20diagram%20showing%20how%20Azure%20Digital%20Twins%20and%20Ansys%20Twin%20Builder%20Runtime%20could%20take%20part%20in%20an%20end-to-end%20IoT%20solution%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20align%3D%22center%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22blog_image1.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F325246iA46C90B70EB4A08A%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22blog_image1.png%22%20alt%3D%22Simulation%20based%20digital%20twin%20architecture%22%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3ESimulation%20based%20digital%20twin%20architecture%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIn%20this%20article%2C%20we%20will%20focus%20on%20how%20to%20implement%20the%20integration%20between%20Azure%20Digital%20Twins%20and%20the%20Ansys%20Twin%20Builder%20runtime%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20align%3D%22center%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22blog_image2.png%22%20style%3D%22width%3A%20674px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F325247iD9799CC7DC0ECD0D%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22blog_image2.png%22%20alt%3D%22blog_image2.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20class%3D%22lia-align-justify%22%3EYou%20can%20use%20Azure%20Digital%20Twins%20to%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Flearn%2Fpaths%2Fdevelop-azure-digital-twins%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Erepresent%20your%20asset%20hierarchy%3C%2FA%3E.%20It%20helps%20you%20keep%20twin%20data%20as%20well%20as%20a%20live%20execution%20environment%20where%20you%20can%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fdigital-twins%2Fhow-to-manage-routes%3Ftabs%3Dportal%252Cportal2%252Cportal3%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ecreate%20endpoints%3C%2FA%3E%20and%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fdigital-twins%2Ftutorial-end-to-end%23propagate-azure-digital-twins-events-through-the-graph%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Esubscribe%20to%20twin%20change%20events%3C%2FA%3E.%20The%20twin%20can%20be%20anything%20based%20on%20your%20functional%20requirements%20and%20conforming%20to%20the%20domain%20specific%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fdigital-twins%2Fconcepts-ontologies%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Eontology%3C%2FA%3E.%3C%2FP%3E%0A%3CP%20class%3D%22lia-align-justify%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20class%3D%22lia-align-justify%22%3EIn%20the%20above%20example%2C%20the%20updates%20in%20the%20digital%20twin%20on%20specific%20models%20trigger%20an%20event%20that%20invokes%20the%20Ansys%20Digital%20Twin%20Runtime%20and%20the%20results%20are%20saved%20back%20to%20the%20Azure%20Digital%20Twins%20instance.%3C%2FP%3E%0A%3CP%20class%3D%22lia-align-justify%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20class%3D%22lia-align-justify%22%3ETwin%20processor%20will%20be%20the%20core%20function%20or%20integrator%20between%20the%20Azure%20Digital%20Twins%20instance%20and%20the%20Ansys%20Digital%20Twin%20Runtime.%20Please%20find%20the%20process%20diagram%20below.%3C%2FP%3E%0A%3CP%20class%3D%22lia-align-justify%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20align%3D%22center%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22blog_image3.png%22%20style%3D%22width%3A%20397px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F325351i8643F924CB77158F%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22blog_image3.png%22%20alt%3D%22Simulation%20execution%20process%20flow%22%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3ESimulation%20execution%20process%20flow%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20class%3D%22lia-align-justify%22%3EAnsys%20Twin%20Builder%20and%20Ansys%20Twin%20Deployer%20will%20be%20used%20to%20generate%20the%20models%20representing%20the%20asset%20to%20monitor%20and%20export%20a%20digital%20twin%20runtime%20that%20can%20be%20made%20available%20in%20the%20environment%20to%20run%20the%20simulations.%20Ansys%20Digital%20Twin%20Runtime%20exposes%20multiple%20APIs%20%3CEM%3E(interface%20specification%20is%20attached%20to%20this%20article)%3C%2FEM%3E%2C%20all%20of%20which%20should%20be%20invoked%20in%20a%20specific%20order%20to%20get%20the%20response%20from%20Ansys%20as%20described%20in%20the%20architecture%20section.%3C%2FP%3E%0A%3CP%20class%3D%22lia-align-justify%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20class%3D%22lia-align-justify%22%3EIn%20a%20%E2%80%9Creal%E2%80%9D%20digital%20twin%20application%2C%20the%20digital%20twin%20instance%20is%20connected%20to%20IoT%20data%20streams%20to%20keep%20the%20digital%20twin%20%E2%80%9Calive%E2%80%9D%20and%20there%20would%20be%20a%20continuous%20evaluation%20of%20the%20simulation%20runtime%20based%20on%20the%20new%20data%20coming%20from%20the%20connected%20assets.%20In%20some%20cases%2C%20you%20might%20have%20a%20static%20digital%20twin%20where%20you%20might%20not%20have%20IoT%20data%20streams%20yet%20and%20the%20simulation%20models%20might%20be%20static%20and%20need%20to%20be%20evaluated%20one%20single%20time.%20Depending%20on%20your%20case%2C%20the%20sequence%20of%20core%20functions%20to%20invoke%20on%20the%20Ansys%20Digital%20Twin%20runtime%20from%20the%20Twin%20Processor%20function%20are%20listed%20below%3A%3C%2FP%3E%0A%3CP%20class%3D%22lia-align-justify%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%20class%3D%22lia-list-style-type-lower-alpha%22%3E%0A%3CLI%3E%3CSTRONG%3EInitialization%20phase%3C%2FSTRONG%3E%3COL%20class%3D%22lia-list-style-type-lower-roman%22%3E%0A%3CLI%3EReceive%20twin%20update%3C%2FLI%3E%0A%3CLI%3EPrepare%20the%20requested%20parameters%20and%20inputs%20to%20invoke%20the%20Ansys%20Digital%20Twin%20Runtime%3C%2FLI%3E%0A%3CLI%3EInvoke%20the%20Ansys%20Digital%20Twin%20Runtime%20API%3COL%3E%0A%3CLI%3EInvoke%20model%20load%20API%3C%2FLI%3E%0A%3CLI%3EInvoke%20model%20instantiate%20API%3C%2FLI%3E%0A%3CLI%3EInvoke%20set%20parameters%20API%3C%2FLI%3E%0A%3CLI%3EInvoke%20set%20inputs%20API%3C%2FLI%3E%0A%3CLI%3EInvoke%20model%20initialize%20API%3C%2FLI%3E%0A%3CLI%3EInvoke%20get%20output%20API%26nbsp%3B%20%3CEM%3E(if%20your%20digital%20twin%20is%20static%2C%20invoke%20close%20API%20and%20stop%20at%20step%20v%20and%20don%E2%80%99t%20execute%20the%20%E2%80%9Crunning%20phase%E2%80%9D)%3C%2FEM%3E%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3C%2FLI%3E%0A%3CLI%3EPrepare%20the%20simulation%20result%20object%3C%2FLI%3E%0A%3CLI%3EUpdate%20the%20digital%20twin%20with%20the%20simulation%20result%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3ERunning%20phase%3C%2FSTRONG%3E%3COL%20class%3D%22lia-list-style-type-lower-roman%22%3E%0A%3CLI%3EReceive%20Twin%20update%3C%2FLI%3E%0A%3CLI%3EPrepare%20the%20requested%20inputs%20to%20invoke%20Ansys%20Digital%20Twin%20Runtime%3C%2FLI%3E%0A%3CLI%3EInvoke%20Ansys%20Digital%20Twin%20Runtime%20API%3COL%3E%0A%3CLI%3EInvoke%20simulation%20step%20or%20simulation%20batch%20API%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3C%2FLI%3E%0A%3CLI%3EPrepare%20the%20simulation%20result%20object%3C%2FLI%3E%0A%3CLI%3EUpdate%20the%20digital%20twin%20with%20the%20simulation%20result%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3EClosing%20phase%3C%2FSTRONG%3E%3COL%20class%3D%22lia-list-style-type-lower-roman%22%3E%0A%3CLI%3EInvoke%20close%20API%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--296885010%22%20id%3D%22toc-hId--296226481%22%3ERunning%20Ansys%20Digital%20Twin%20Runtime%20Service%3C%2FH2%3E%0A%3CP%20class%3D%22lia-align-justify%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20class%3D%22lia-align-justify%22%3EAnsys%20Digital%20Twin%20Runtime%20is%20made%20available%20in%20a%20%E2%80%9Ctar.gz%E2%80%9D%20format%20of%20Docker%20image.%20We%20need%20to%20run%20the%20container%20from%20the%20GZip%20file.%20For%20that%2C%20we%20need%20to%20first%20load%20that%20Docker%20image%20into%20an%20Azure%20Container%20Registry.%20The%20instructions%20to%20create%20an%20Azure%20Container%20Registry%20can%20be%20found%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fcontainer-registry%2Fcontainer-registry-get-started-portal%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehere%3C%2FA%3E.%3C%2FP%3E%0A%3CP%20class%3D%22lia-align-justify%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20class%3D%22lia-align-justify%22%3EAs%20a%20pre-requisite%2C%20you%20will%20need%20to%20upload%20the%20tar.gz%20file%20to%20any%20repository.%20Then%2C%20you%20can%20use%20the%20below%20YAML%20code%20in%20Azure%20Devops%20to%20create%20a%20pipeline%20for%20that%20process.%20You%20need%20to%20specify%20%3CEM%3E%3CYOUR%20repo%3D%22%22%20folder%3D%22%22%20path%3D%22%22%3E%3C%2FYOUR%3E%3C%2FEM%3E%20and%20%3CEM%3E%3CYOUR%20container%3D%22%22%20registry%3D%22%22%20id%3D%22%22%3E%3C%2FYOUR%3E%3C%2FEM%3E%20in%20the%20script%20below.%20You%20can%20then%20run%20the%20pipeline%20to%20create%20a%20Docker%20container%20on%20the%20specified%20Azure%20Container%20Registry%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CDIV%3E%3CPRE%20class%3D%22lia-code-sample%20language-yaml%22%3E%3CCODE%3E%23%20Variable%20'Source_FileName'%20was%20defined%20in%20the%20Variables%20tab%0A%23%20Variable%20'Source_ImageName'%20was%20defined%20in%20the%20Variables%20tab%0A%23%20Variable%20'Source_Tag'%20was%20defined%20in%20the%20Variables%20tab%0A%23%20Variable%20'Target_ACR'%20was%20defined%20in%20the%20Variables%20tab%0A%23%20Variable%20'Target_ImageName'%20was%20defined%20in%20the%20Variables%20tab%0A%23%20Variable%20'Target_Tag'%20was%20defined%20in%20the%20Variables%20tab%0Aresources%3A%0A%20%20repositories%3A%0A%20%20-%20repository%3A%20self%0A%20%20%20%20type%3A%20git%0A%20%20%20%20ref%3A%20%3CYOUR%20repo%3D%22%22%20folder%3D%22%22%20path%3D%22%22%3E%0Ajobs%3A%0A-%20job%3A%20Job_1%0A%20%20displayName%3A%20Docker%20push%0A%20%20pool%3A%0A%20%20%20%20vmImage%3A%20ubuntu-16.04%0A%20%20steps%3A%0A%20%20-%20checkout%3A%20self%0A%20%20-%20task%3A%20CopyFiles%402%0A%20%20%20%20displayName%3A%20Copy%20Files%20From%20Repo%0A%20%20%20%20inputs%3A%0A%20%20%20%20%20%20SourceFolder%3A%20DockerImage%0A%20%20%20%20%20%20TargetFolder%3A%20%24(build.artifactstagingdirectory)%0A%20%20-%20task%3A%20Docker%402%0A%20%20%20%20displayName%3A%20login%0A%20%20%20%20inputs%3A%0A%20%20%20%20%20%20containerRegistry%3A%20%3CYOUR%20container%3D%22%22%20registry%3D%22%22%20id%3D%22%22%3E%0A%20%20%20%20%20%20command%3A%20login%0A%20%20-%20task%3A%20CmdLine%402%0A%20%20%20%20displayName%3A%20Command%20Line%20Script%0A%20%20%20%20inputs%3A%0A%20%20%20%20%20%20script%3A%20%22docker%20image%20load%20--input%20%24(build.artifactstagingdirectory)%2F%24(Source_FileName)%5Cn%5Cndocker%20image%20ls%5Cn%20%20%20%5Cndocker%20image%20tag%20%24(Source_ImageName)%3A%24(Source_Tag)%20%24(Target_ACR)%2F%24(Target_ImageName)%3A%24(Target_Tag)%5Cn%5Cndocker%20push%20%24(Target_ACR)%2F%24(Target_ImageName)%3A%24(Target_Tag)%22%0A%20%20-%20task%3A%20Docker%402%0A%20%20%20%20displayName%3A%20logout%0A%20%20%20%20inputs%3A%0A%20%20%20%20%20%20containerRegistry%3A%20%3CYOUR%20container%3D%22%22%20registry%3D%22%22%20id%3D%22%22%3E%0A%20%20%20%20%20%20command%3A%20logout%0A%3C%2FYOUR%3E%3C%2FYOUR%3E%3C%2FYOUR%3E%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FDIV%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20class%3D%22lia-align-justify%22%3EAs%20a%20second%20step%2C%20you%20will%20need%20to%20create%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Flearn%2Fmodules%2Fdeploy-run-container-app-service%2F5-exercise-deploy-web-app%3Fpivots%3Dcsharp%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ean%20App%20Service%20in%20Azure%20with%20Docker%20based%20deployment%3C%2FA%3E.%20While%20creating%20the%20App%20Service%2C%20you%20can%20select%20the%20new%20Docker%20image%20as%20the%20application%20source.%3C%2FP%3E%0A%3CP%20class%3D%22lia-align-justify%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20class%3D%22lia-align-justify%22%3ENow%20your%20Ansys%20Digital%20Twin%20Runtime%20service%20is%20ready%20to%20serve%20the%20requests.%3C%2FP%3E%0A%3CP%20class%3D%22lia-align-justify%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--2104339473%22%20id%3D%22toc-hId--2103680944%22%3ETwin%20Processor%20Azure%20Function%20Implementation%3C%2FH2%3E%0A%3CP%20class%3D%22lia-align-justify%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20class%3D%22lia-align-justify%22%3EThis%20function%20plays%20the%20role%20of%20integrator%20which%20will%20be%20invoked%20with%20Azure%20Digital%20Twin%20event%20trigger.%20You%20can%20follow%20the%20steps%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fdigital-twins%2Fhow-to-send-twin-to-twin-events%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehere%3C%2FA%3E%20to%20set%20up%20the%20endpoints%2C%20routes%20and%20create%20the%20Azure%20Function%20that%20watches%20for%20twin%20life%20cycle%20events%20that%20should%20trigger%20the%20Ansys%20Digital%20Twin%20Runtime%20and%20reflect%20the%20changes%20back%20to%20the%20Azure%20Digital%20Twins%20instance.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20class%3D%22lia-align-justify%22%3EOnce%20the%20Azure%20Function%20receives%20any%20specific%20trigger%20to%20call%20the%20Ansys%20Digital%20Twin%20Runtime%2C%20it%20needs%20to%20prepare%20the%20request%20body%20with%20specific%20parameters%20and%20invoke%20services%20in%20sequence.%20As%20an%20initial%20setup%20you%20can%20specify%20the%20URLs%20as%20follows%3A%3C%2FP%3E%0A%3CDIV%3E%3CPRE%20class%3D%22lia-code-sample%20language-csharp%22%3E%3CCODE%3E_loadUrl%20%3D%20_config%5B%22Ansys%20%20BaseUrl%22%5D%20%2B%20%22%2FrestAPI%2Fload_model%22%3B%0A_instantiateUrl%20%3D%20_config%5B%22Ansys%20%20BaseUrl%22%5D%20%2B%20%22%2FrestAPI%2Finstantiate_model%22%3B%0A_initializeUrl%20%3D%20_config%5B%22Ansys%20%20BaseUrl%22%5D%20%2B%20%22%2FrestAPI%2Finitialize_model%22%3B%0A_setParametersUrl%20%3D%20_config%5B%22Ansys%20%20BaseUrl%22%5D%20%2B%20%22%2FrestAPI%2Fset_parameters%22%3B%0A_setInputsUrl%20%3D%20_config%5B%22Ansys%20%20BaseUrl%22%5D%20%2B%20%22%2FrestAPI%2Fset_inputs%22%3B%0A_simulationStepUrl%20%3D%20_config%5B%22Ansys%20%20BaseUrl%22%5D%20%2B%20%22%2FrestAPI%2Fsimulation_step%20%22%3B%0A_simulationBatchUrl%20%3D%20_config%5B%22Ansys%20%20BaseUrl%22%5D%20%2B%20%22%2FrestAPI%2Fsimulation_batch%20%22%3B_getOutputsUrl%20%3D%20_config%5B%22Ansys%20%20BaseUrl%22%5D%20%2B%20%22%2FrestAPI%2Fget_outputs%22%3B%0A_closeUrl%20%3D%20_config%5B%22Ansys%20%20BaseUrl%22%5D%20%2B%20%22%2FrestAPI%2Fclose_model%22%3B%0A%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FDIV%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20class%3D%22lia-align-justify%22%3EThen%20you%20can%20invoke%20the%20below%20APIs.%20You%20need%20to%20call%20the%20%3CEM%3E%E2%80%9CClose%20Model%E2%80%9D%3C%2FEM%3E%20API%20in%20case%20any%20failure%20happens%20in%20the%20sequence%2C%20to%20unload%20the%20model.%20You%20can%20use%20the%20below%20code%20snippet%20for%20this%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CDIV%3E%3CPRE%20class%3D%22lia-code-sample%20language-csharp%22%3E%3CCODE%3Estatus%20%3D%20await%20Ansys%20%20LoadAsync(AnsysModelId%2C%20token)%3B%0A%20if%20(!status)%0A%7B%0Aawait%20Ansys%20%20CloseAsync(AnsysModelId%2C%20token)%3B%0Areturn%20(false%2C%20null)%3B%0A%7D%0A%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FDIV%3E%0A%3CH3%20id%3D%22toc-hId--1413777999%22%20id%3D%22toc-hId--1413119470%22%3E%26nbsp%3B%3C%2FH3%3E%0A%3CH3%20id%3D%22toc-hId-1073734834%22%20id%3D%22toc-hId-1074393363%22%3EInvoke%20-%20Load%20Model%20API%3C%2FH3%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EYou%20can%20use%20the%20code%20snippet%20provided%20below%20to%20load%20the%20Ansys%20Digital%20Twin%20Runtime%20model%3A%3C%2FP%3E%0A%3CDIV%3E%3CPRE%20class%3D%22lia-code-sample%20language-csharp%22%3E%3CCODE%3Eprivate%20async%20Task%3CBOOL%3E%20AnsysLoadAsync(string%20AnsysModelId%2C%20CancellationToken%20token)%0A%7B%0AUri%20loadUri%20%3D%20new%20Uri(_loadUrl).AddQueryParameter(%22modelname%22%2C%20AnsysModelId)%3B%0AHttpResponseMessage%20response%20%3D%20await%20_httpClinetAdapter.GetAsync(loadUri%2C%20token)%3B%0Areturn%20response.IsSuccessStatusCode%3B%0A%7D%0A%3C%2FBOOL%3E%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FDIV%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId--733719629%22%20id%3D%22toc-hId--733061100%22%3EInvoke%20-%20Model%20Instantiate%20API%3C%2FH3%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20class%3D%22lia-align-justify%22%3EYou%20can%20use%20the%20code%20snippet%20provided%20below%20to%20instantiate%20the%20Ansys%20Digital%20Twin%20Runtime%20model%3A%3C%2FP%3E%0A%3CDIV%3E%3CPRE%20class%3D%22lia-code-sample%20language-csharp%22%3E%3CCODE%3Eprivate%20async%20Task%3CBOOL%3E%20AnsysInstantiateAsync(string%20AnsysModelId%2C%20CancellationToken%20token)%0A%7B%0AUri%20loadUri%20%3D%20new%20Uri(_instantiateUrl).AddQueryParameter(%22modelname%22%2C%20AnsysModelId)%3B%0AHttpResponseMessage%20response%20%3D%20await%20_httpClinetAdapter.GetAsync(loadUri%2C%20token)%3B%0Areturn%20response.IsSuccessStatusCode%3B%0A%7D%0A%3C%2FBOOL%3E%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FDIV%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId-1753793204%22%20id%3D%22toc-hId-1754451733%22%3E%26nbsp%3BInvoke%20-%20Set%20Parameters%20API%3C%2FH3%3E%0A%3CP%20class%3D%22lia-align-justify%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20class%3D%22lia-align-justify%22%3EYou%20can%20use%20the%20code%20snippet%20provided%20below%20to%20set%20parameters%20for%20the%20%26nbsp%3BAnsys%20Digital%20Twin%20Runtime%20model%3A%3C%2FP%3E%0A%3CDIV%3E%3CPRE%20class%3D%22lia-code-sample%20language-csharp%22%3E%3CCODE%3Eprivate%20async%20Task%3CBOOL%3E%20AnsysSetParametersAsync(string%20AnsysModelId%2C%20string%20parameters%2C%20CancellationToken%20token)%0A%7B%0AUri%20loadUri%20%3D%20new%20Uri(_setParametersUrl)%3B%0ASimulationRequest%20simulationRequest%20%3D%20new%20SimulationRequest%0A%7B%0AModelName%20%3D%20AnsysModelId%2C%0AParameters%20%3D%20parameters%0A%7D%3B%0Astring%20content%20%3D%20JsonConvert.SerializeObject(simulationRequest)%3B%0Ausing%20StringContent%20stringContent%20%3D%20new%20StringContent(content%2C%20Encoding.UTF8%2C%20%22application%2Fjson%22)%3B%0AHttpResponseMessage%20response%20%3D%20await%20_httpClinetAdapter.PostAsync(loadUri%2C%20stringContent%2C%20token)%3B%0Astring%20jsonResponse%20%3D%20await%20response.Content.ReadAsStringAsync()%3B%0Areturn%20response.IsSuccessStatusCode%3B%0A%7D%0A%3C%2FBOOL%3E%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FDIV%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId--53661259%22%20id%3D%22toc-hId--53002730%22%3EInvoke%20-%20Set%20Inputs%20API%3C%2FH3%3E%0A%3CP%20class%3D%22lia-align-justify%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20class%3D%22lia-align-justify%22%3EYou%20can%20use%20the%20code%20snippet%20provided%20below%20to%20set%20inputs%20for%20the%20Ansys%20Digital%20Twin%20Runtime%20model%3A%3C%2FP%3E%0A%3CDIV%3E%3CPRE%20class%3D%22lia-code-sample%20language-csharp%22%3E%3CCODE%3Eprivate%20async%20Task%3CBOOL%3E%20AnsysSetInputsAsync(string%20AnsysModelId%2C%20string%20inputs%2C%20CancellationToken%20token)%0A%7B%0AUri%20loadUri%20%3D%20new%20Uri(_setInputsUrl)%3B%0ASimulationRequest%20simulationRequest%20%3D%20new%20SimulationRequest%0A%7B%0AModelName%20%3D%20AnsysModelId%2C%0AInputs%20%3D%20inputs%0A%7D%3B%0Astring%20content%20%3D%20JsonConvert.SerializeObject(simulationRequest)%3B%0Ausing%20StringContent%20stringContent%20%3D%20new%20StringContent(content%2C%20Encoding.UTF8%2C%20%22application%2Fjson%22)%3B%0AHttpResponseMessage%20response%20%3D%20await%20_httpClinetAdapter.PostAsync(loadUri%2C%20stringContent%2C%20token)%3B%0Astring%20jsonResponse%20%3D%20await%20response.Content.ReadAsStringAsync()%3B%0Areturn%20response.IsSuccessStatusCode%3B%0A%7D%0A%3C%2FBOOL%3E%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FDIV%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId--1861115722%22%20id%3D%22toc-hId--1860457193%22%3EInvoke%20-%20Model%20Initialize%20API%3C%2FH3%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EYou%20can%20use%20the%20code%20snippet%20provided%20below%20to%20initialize%20the%20Ansys%20Digital%20Twin%20Runtime%20model%3A%3C%2FP%3E%0A%3CDIV%3E%3CPRE%20class%3D%22lia-code-sample%20language-csharp%22%3E%3CCODE%3Eprivate%20async%20Task%3CBOOL%3E%20AnsysInitializeAsync(string%20AnsysModelId%2C%20CancellationToken%20token)%0A%7B%0AUri%20loadUri%20%3D%20new%20Uri(_initializeUrl).AddQueryParameter(%22modelname%22%2C%20AnsysModelId)%3B%0AHttpResponseMessage%20response%20%3D%20await%20_httpClinetAdapter.GetAsync(loadUri%2C%20token)%3B%0Areturn%20response.IsSuccessStatusCode%3B%0A%7D%0A%3C%2FBOOL%3E%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FDIV%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId-626397111%22%20id%3D%22toc-hId-627055640%22%3E%26nbsp%3BInvoke%20%E2%80%93%20Simulation%20Step%20API%3C%2FH3%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20class%3D%22lia-align-justify%22%3EYou%20can%20use%20the%20code%20snippet%20provided%20below%20to%20simulate%20one%20step%20with%20the%20Ansys%20Digital%20Twin%20Runtime%20model%3A%3C%2FP%3E%0A%3CDIV%3E%3CPRE%20class%3D%22lia-code-sample%20language-csharp%22%3E%3CCODE%3Eprivate%20async%20Task%3CBOOL%3E%20AnsysSimulationStepAsync(string%20AnsysModelId%2C%20string%20inputs%2C%20string%20endtime%2C%20CancellationToken%20token)%0A%7B%0AUri%20loadUri%20%3D%20new%20Uri(_simulationStep%20Url)%3B%0ASimulationRequest%20simulationRequest%20%3D%20new%20SimulationRequest%0A%7B%0AModelName%20%3D%20AnsysModelId%2C%0AInputs%20%3D%20inputs%0AEndtime%20%3D%20endtime%0A%7D%3B%0Astring%20content%20%3D%20JsonConvert.SerializeObject(simulationRequest)%3B%0Ausing%20StringContent%20stringContent%20%3D%20new%20StringContent(content%2C%20Encoding.UTF8%2C%20%22application%2Fjson%22)%3B%0AHttpResponseMessage%20response%20%3D%20await%20_httpClinetAdapter.PostAsync(loadUri%2C%20stringContent%2C%20token)%3B%0Astring%20jsonResponse%20%3D%20await%20response.Content.ReadAsStringAsync()%3B%0Areturn%20(response.IsSuccessStatusCode%2C%20jsonResponse)%3B%0A%0A%7D%0A%3C%2FBOOL%3E%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FDIV%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId--1181057352%22%20id%3D%22toc-hId--1180398823%22%3EInvoke%20%E2%80%93%20Simulation%20Batch%20API%3C%2FH3%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20class%3D%22lia-align-justify%22%3EYou%20can%20use%20the%20code%20snippet%20provided%20below%20to%20simulate%20a%20batch%20of%20data%20at%20once%20with%20the%20Ansys%20Digital%20Twin%20Runtime%20model%3A%3C%2FP%3E%0A%3CDIV%3E%3CPRE%20class%3D%22lia-code-sample%20language-csharp%22%3E%3CCODE%3Eprivate%20async%20Task%3CBOOL%3E%20AnsysSimulationBatchAsync(string%20AnsysModelId%2C%20string%20inputs%2C%20CancellationToken%20token)%0A%7B%0AUri%20loadUri%20%3D%20new%20Uri(_simulationStep%20Url)%3B%0ASimulationRequest%20simulationRequest%20%3D%20new%20SimulationRequest%0A%7B%0AModelName%20%3D%20AnsysModelId%2C%0AInputs%20%3D%20inputs%0A%7D%3B%0Astring%20content%20%3D%20JsonConvert.SerializeObject(simulationRequest)%3B%0Ausing%20StringContent%20stringContent%20%3D%20new%20StringContent(content%2C%20Encoding.UTF8%2C%20%22application%2Fjson%22)%3B%0AHttpResponseMessage%20response%20%3D%20await%20_httpClinetAdapter.PostAsync(loadUri%2C%20stringContent%2C%20token)%3B%0Astring%20jsonResponse%20%3D%20await%20response.Content.ReadAsStringAsync()%3B%0Areturn%20(response.IsSuccessStatusCode%2C%20jsonResponse)%3B%0A%7D%0A%3C%2FBOOL%3E%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FDIV%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId-611292002%22%20id%3D%22toc-hId-611950531%22%3EInvoke%20-%20Get%20Output%20API%3C%2FH3%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20class%3D%22lia-align-justify%22%3EYou%20can%20use%20the%20code%20snippet%20provided%20below%20to%20get%20output%20from%20the%20Ansys%20Digital%20Twin%20Runtime%3A%3C%2FP%3E%0A%3CDIV%3E%3CPRE%20class%3D%22lia-code-sample%20language-csharp%22%3E%3CCODE%3Eprivate%20async%20Task%26lt%3B(bool%2C%20string)%26gt%3B%20AnsysGetOutputsAsync(string%20AnsysModelId%2C%20CancellationToken%20token)%0A%7B%0AUri%20loadUri%20%3D%20new%20Uri(_getOutputsUrl).AddQueryParameter(%22modelname%22%2C%20AnsysModelId)%3B%0AHttpResponseMessage%20response%20%3D%20await%20_httpClinetAdapter.GetAsync(loadUri%2C%20token)%3B%0Astring%20jsonResponse%20%3D%20await%20response.Content.ReadAsStringAsync()%3B%0Areturn%20(response.IsSuccessStatusCode%2C%20jsonResponse)%3B%0A%7D%0A%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FDIV%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20class%3D%22lia-align-justify%22%3ENow%20you%20have%20the%20results%20from%20the%20Ansys%20Digital%20Twin%20Runtime%20API%2C%20which%20can%20be%20used%20to%20update%20the%20digital%20twin.%3C%2FP%3E%0A%3CP%20class%3D%22lia-align-justify%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId--1196162461%22%20id%3D%22toc-hId--1195503932%22%3EInvoke%20%E2%80%93%20Close%20Model%20API%3C%2FH3%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20class%3D%22lia-align-justify%22%3EYou%20can%20use%20the%20code%20snippet%20provided%20below%20to%20close%20the%20model%20in%20the%20Ansys%20Digital%20Twin%20Runtime%3A%3C%2FP%3E%0A%3CDIV%3E%3CPRE%20class%3D%22lia-code-sample%20language-csharp%22%3E%3CCODE%3Eprivate%20async%20Task%3CBOOL%3E%20AnsysCloseAsync(string%20AnsysModelId%2C%20CancellationToken%20token)%0A%7B%0AUri%20loadUri%20%3D%20new%20Uri(_closeUrl).AddQueryParameter(%22modelname%22%2C%20AnsysModelId)%3B%0AHttpResponseMessage%20response%20%3D%20await%20_httpClinetAdapter.GetAsync(loadUri%2C%20token)%3B%0Areturn%20response.IsSuccessStatusCode%3B%0A%7D%0A%3C%2FBOOL%3E%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FDIV%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20class%3D%22lia-align-justify%22%3EWe%20have%20completed%20the%20Ansys%20Digital%20Twin%20Runtime%20invocation.%20To%20ease%20and%20automate%20the%20process%2C%20you%20can%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Flearn%2Fmodules%2Fdeploy-run-container-app-service%2F%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3Edeploy%20the%20Twin%20Processor%20function%20based%20on%20a%20Docker%20image%3C%2FA%3E%20and%20create%20a%20devops%20pipeline%20for%20it.%20You%20can%20use%20below%20YAML%20to%20create%20a%20Docker%20based%20application%20for%20the%20Twin%20Processor%20function.%20You%20need%20to%20specify%26nbsp%3B%3CEM%3E%3CYOUR%20container%3D%22%22%20registry%3D%22%22%20id%3D%22%22%3E%3C%2FYOUR%3E%3C%2FEM%3E%20in%20the%20script%20below%3A%3C%2FP%3E%0A%3CDIV%3E%3CPRE%20class%3D%22lia-code-sample%20language-yaml%22%3E%3CCODE%3Ejobs%3A%0A-%20job%3A%20Twin%20Processor%20Docker%20Push%0A%20%20displayName%3A%20AgentJob1%0A%20%20pool%3A%0A%20%20%20%20vmImage%3A%20ubuntu-16.04%0A%20%20steps%3A%0A%20%20-%20checkout%3A%20self%0A%20%20-%20task%3A%20DotNetCoreCLI%402%0A%20%20%20%20displayName%3A%20dotnet%20restore%0A%20%20%20%20inputs%3A%0A%20%20%20%20%20%20command%3A%20restore%0A%20%20%20%20%20%20projects%3A%20TwinProcessor.sln%0A%20%20-%20task%3A%20DotNetCoreCLI%402%0A%20%20%20%20displayName%3A%20dotnet%20build%0A%20%20%20%20inputs%3A%0A%20%20%20%20%20%20projects%3A%20TwinProcessor.sln%0A%20%20%20%20%20%20arguments%3A%20--configuration%20Release%0A%20%20-%20task%3A%20CopyFiles%402%0A%20%20%20%20displayName%3A%20'Copy%20Files%20to%3A%20%24(Build.ArtifactStagingDirectory)'%0A%20%20%20%20inputs%3A%0A%20%20%20%20%20%20TargetFolder%3A%20%24(Build.ArtifactStagingDirectory)%0A%20%20-%20task%3A%20Docker%402%0A%20%20%20%20displayName%3A%20login%0A%20%20%20%20inputs%3A%0A%20%20%20%20%20%20containerRegistry%3A%20%3CYOUR%20container%3D%22%22%20registry%3D%22%22%20id%3D%22%22%3E%0A%20%20%20%20%20%20command%3A%20login%0A%20%20-%20task%3A%20Docker%402%0A%20%20%20%20displayName%3A%20buildAndPush%0A%20%20%20%20inputs%3A%0A%20%20%20%20%20%20containerRegistry%3A%20%3CYOUR%20container%3D%22%22%20registry%3D%22%22%20id%3D%22%22%3E%0A%20%20%20%20%20%20repository%3A%20ADTTwinProcessor%0A%20%20%20%20%20%20Dockerfile%3A%20TwinProcessDockerfile%0A%20%20-%20task%3A%20Docker%402%0A%20%20%20%20displayName%3A%20logout%0A%20%20%20%20inputs%3A%0A%20%20%20%20%20%20containerRegistry%3A%20%3CYOUR%20container%3D%22%22%20registry%3D%22%22%20id%3D%22%22%3E%0A%20%20%20%20%20%20command%3A%20logout%0A%20%20-%20task%3A%20PublishBuildArtifacts%401%0A%20%20%20%20displayName%3A%20'Publish%20Artifact%3A%20drop'%0A%20%20%20%20enabled%3A%20False%0A%3C%2FYOUR%3E%3C%2FYOUR%3E%3C%2FYOUR%3E%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FDIV%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20class%3D%22lia-align-justify%22%3EThe%20above%20pipeline%20will%20create%20a%20Docker%20container%20for%20your%20Twin%20Processor%20Azure%20Function.%3C%2FP%3E%0A%3CP%20class%3D%22lia-align-justify%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CH3%20class%3D%22lia-align-justify%22%20id%3D%22toc-hId-1291350372%22%20id%3D%22toc-hId-1292008901%22%3EBuild%20your%20own%20simulation%20based%20digital%20twins%3C%2FH3%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20class%3D%22lia-align-justify%22%20data-unlink%3D%22true%22%3E%3CA%20href%3D%22https%3A%2F%2Fchannel9.msdn.com%2FShows%2FInternet-of-Things-Show%2FAnsys-Twin-Builder-Integration-with-Azure-Digital-Twins%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3ELearn%20more%20about%20simulation%20based%20digital%20twins%3C%2FA%3E%20and%20start%20building%20your%20own%20with%20%3CA%20href%3D%22https%3A%2F%2Fazure.microsoft.com%2Fservices%2Fdigital-twins%2F%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3EAzure%20Digital%20Twins%3C%2FA%3E%20and%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fwww.ansys.com%2Fproducts%2Fdigital-twin%2Fansys-twin-builder%2Ftwin-builder-trial%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3EAnsys%20Twin%20Builder%20Free%20Trial%3C%2FA%3E.%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EPlease%20keep%20the%20discussion%20going.%20Leave%20your%20questions%20and%20comments%20below.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-2939616%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22blog_teaser.png%22%20style%3D%22width%3A%20370px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F325243i26EEA8E13335589A%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22blog_teaser.png%22%20alt%3D%22blog_teaser.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%20data-unlink%3D%22true%22%3ELearn%20how%20to%20integrate%20Azure%20Digital%20Twins%26nbsp%3Bwith%20Ansys%20Twin%20Builder%26nbsp%3Bfor%20high%20impact%20solutions.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2939616%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAzure%20Digital%20Twins%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EAzure%20IoT%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Version history
Last update:
‎Nov 08 2021 03:59 PM