@Vishwajit Vipat Dalve Greetings!
Did you get a chance to see Sander's suggestions? In addition to it, please see below information and let us know if that helps.
I am able to update all the components of the digital twin but these updates are not fast it gives me a latency of 18-25 seconds. I am using the update_component() function to update one component at a time
I understand that you would like to update multiple digital twin components. After creating or updating a twin, there may be a latency of up to 10 seconds before the changes will be reflected in queries.
Did you try updating multiple components of a digital twin by making multiple calls to the update_component()
function? If not, Please try with the suggestion and see if that helps.
from azure.digitaltwins.core import DigitalTwinsClient
from azure.identity import DefaultAzureCredential
# Create a DigitalTwinsClient instance
credential = DefaultAzureCredential()
client = DigitalTwinsClient("<your-digital-twins-url>", credential)
# Define the digital twin ID and components to update
digital_twin_id = "<your-digital-twin-id>"
components = {
"Component1": {
"Property1": "Value1",
"Property2": "Value2"
},
"Component2": {
"Property3": "Value3",
"Property4": "Value4"
}
}
# Update the digital twin components
for component_id, component in components.items():
client.update_component(digital_twin_id, component_id, component)
Reference: Update digital twin components
By using a loop to make multiple calls to the update_component()
function, you can update multiple components of a digital twin with the Azure Digital Twins Python SDK.
If you are ok to use API, please check update a component in a digital twin (multiple updates)
Sample request:
PATCH https://digitaltwins-hostname/digitaltwins/myTwinId/components/myComponent?api-version=2023-02-27-preview
[
{
"op": "add",
"path": "/property1",
"value": 1
},
{
"op": "replace",
"path": "/$metadata/property1/sourceTime",
"value": "2022-05-31T12:00:01.000125009Z"
},
{
"op": "remove",
"path": "/property2"
},
{
"op": "replace",
"path": "/property3/subProperty1",
"value": "new value"
}
]
I hope this helps! Let us know if you have any further questions.
If this answers your query, do click Accept Answer
and Yes
for was this answer helpful. And, if you have any further query do let us know.