Create Azure resource using a Terraform code without destroying the existing Resouce

I have written a Terrafrom code to create Azure Resource and It woked as expected. But when I try to create other resource using same code it is deleting the existing resouce as the state file ID is same. I tried to change the ID even though it is not working.

Kindly suggest me how to modify the script

You might want to restructure the code as a module and call it to create resources.

The typical way to add a new resource without affecting any existing ones is to add a new resource block with a different type/name and leave the one you already created present in the configuration.

If you remove a resource block from the configuration after creating it then Terraform understands that as you intending to destroy the corresponding object.

Terraform is a “desired state” system, so your configuration should represent the entire set of infrastructure you want this particular configuration to manage, and you should remove blocks from it only when you are ready to destroy the corresponding objects.