How to delete secondary IP using Azure Cloud Shell CLI

Brett Hamill 0 Reputation points
2024-08-21T16:26:32.2366667+00:00

Cannot delete Azure VM secondary IP using Azure Cloud Shell.

When I run the command below, it just returns me to the prompt with no errors but does not delete the secondary IP from the NIC specified (the VM was stopped when I issued the command as suggested by the relevant docs)

az network nic ip-config delete --resource-group GNAC-Deb-Svr_group --name HA-Virtual-IP --nic-name gnac-policysvr-deb-sec10_z1


I have attached as a file the output I get when I run the command above with the --debug option.

When I try to run the update command instead of the delete command with the --remove option, I get the "ResourceNotFoundError". However, I have verified the resource is present using the az group list command and verified my subscription, tenant, etc is correct by using the az account show command.

 az network nic ip-config update --nic-name gnac-policysvr-deb-sec10_z1 --resource-group GNAC-Deb-Svr_group --remove secondary --name HA-
Virtual-IP
ResourceNotFoundError

Azure Virtual Network
Azure Virtual Network
An Azure networking service that is used to provision private networks and optionally to connect to on-premises datacenters.
2,425 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Sina Salam 10,416 Reputation points
    2024-08-21T21:16:08.93+00:00

    Hello Brett Hamill,

    Welcome to the Microsoft Q&A and thank you for posting your questions here.

    I understand that you are unable to delete Azure VM secondary IP using Azure Cloud Shell without any reasonable error.

    Kindly not just stop or pause the VM, shut it down.

    The run these commands:

    • Make sure the VM is shut down before you attempt this, meaning that VM is stopped and deallocated before attempting to delete the NIC configuration. az network nic ip-config delete --resource-group GNAC-Deb-Svr_group --nic-name gnac-policysvr-deb-sec10_z1 --name HA-Virtual-IP
    • If deletion fails, you can try updating the NIC to remove the IP configuration: az network nic ip-config update --resource-group GNAC-Deb-Svr_group --nic-name gnac-policysvr-deb-sec10_z1 --name HA-Virtual-IP --remove ipConfigurations
    • You need to be sure that the --remove parameter correctly matches the IP configuration name.

    NOTE:

    1. If the DELETE command does not return errors but does not delete the configuration, it might be useful to verify if the operation was successful.
    2. If the command still doesn’t work, check if there are any errors or additional details returned
    3. If CLI commands are failing, you can try using the Azure Portal

    Accept Answer

    I hope this is helpful! Do not hesitate to let me know if you have any other questions.

    ** Please don't forget to close up the thread here by upvoting and accept it as an answer if it is helpful ** so that others in the community facing similar issues can easily find the solution.

    Best Regards,

    Sina Salam

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.