https://pulumi.com logo
#general
Title
# general
m

melodic-doctor-70522

09/14/2023, 12:58 AM
Hello guys, I made a code to create a VM in Azure with the following order First I create the rule to connect to the RDP or SSH Then I create the public IP that will be associated with the VM's NIC Then I create that NIC and associate that IP Finally I create the VM with the components, it is created, there is no error in the creation, but when I want to execute the pulumi destroy command, this error appears can help me with this?
Copy code
azure-native:network:NetworkInterface (NIC-VMWindows1-063-100-160):
     error: Code="NicInUse" Message="Network Interface /subscriptions/8e23e0ca-e424-495e-b142-813621dbb51f/resourceGroups/rg-archie-nonprod-eaus2/providers/Microsoft.Network/networkInterfaces/NIC-VMWindows1-063-100 -160 is used by existing resource /subscriptions/8e23e0ca-e424-495e-b142-813621dbb51f/resourceGroups/rg-archie-nonprod-eaus2/providers/Microsoft.Compute/virtualMachines/VMWindows1-063-archie-nonprod-eaus2-160- 4. In order to delete the network interface, it must be dissociated from the resource. To learn more, see <http://aka.ms/deletenic|aka.ms/deletenic>." Details=[]
d

dazzling-ice-76553

09/14/2023, 1:38 PM
Not sure if this is the cause or not, but you may need to add a
depends on
to your VM referencing the NIC, or mark the NIC to be destroyed with the VM as Azure gets finicky with order of operations when it comes to destroying resources. Also, it could be that without the dependency link, Pulumi is doing something similar to Terraform in that it is not following the order the resources are listed when doing the creation, and since the NIC is not actually required to create the VM, it may be that the VM is created then the NIC attached once it is created,
m

melodic-doctor-70522

09/15/2023, 4:27 PM
How mark the NIC destroys with the VM?