0

In Azure Cloud, I need to delete all the resources of the given instance using Azure-SDK for Python, I'm able to delete resources like VM, PublicIP, NIC. I also need to delete the availability set of the instance.

Bhargavi Annadevara
  • 4,923
  • 2
  • 13
  • 30

2 Answers2

0

If you want to delete Azure Availability Set, you can use the package azure.mgmt.compute. It provides method ComputeManagementClient.availability_sets.delete to implement it. For more details, please refer to here

Jim Xu
  • 21,610
  • 2
  • 19
  • 39
0

Here is the snippet to delete an Availability Set using Azure SDK for Python:

from azure.common.client_factory import get_client_from_cli_profile
from azure.mgmt.compute import ComputeManagementClient

compute_client = get_client_from_cli_profile(ComputeManagementClient)
    
def delete_vm_availability_set():
    compute_client.availability_sets.delete(<resource-group-name>, <availability-set-name>)

# Delete Availability Set
delete_vm_availability_set()

Equivalent Azure CLI command for this operation: az vm availability-set delete

az vm availability-set delete -n MyAvailabilitySet -g MyResourceGroup

Other common management tasks with Microsoft Azure Virtual Machines using the Azure SDK for Python can be found in this sample: Azure Virtual Machines Management Samples - Python

Bhargavi Annadevara
  • 4,923
  • 2
  • 13
  • 30