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.
Asked
Active
Viewed 187 times
2 Answers
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