Hello @Shankar Parab ,
although I am not familiar with the details in Python, your code seems to resemble a lot of the C# examples seen here.
There are two things I can think of right now.
First, be sure your Azure Function has rights/permissions to alter twins in Azure Digital Twins.
Also, you are using 'replace'.
I remember this works well if the twin property has a value already.
Please compare your code with these C# examples. And try out the C# examples next to your Python code.
If the response helped, do "Accept Answer". If it doesn't work, please let us know the progress. All community members with similar issues will benefit by doing so. Your contribution is highly appreciated.