0

I am new to Azure and Azure Python SDK and I would like to ask several questions. How to use Python SDK to:

  1. Given a VM, how do I get all the attached disks and their complete information?
  2. Then how do I get backup history of a disk? How do I know what was the latest backup job executed?

Please explain clearly with references if it is possible. Any help will be appreciated.

1 Answers1

0

The below code was suggested by @Shui shengbao here,to list the disks inside the Resource Group:

from azure.common.credentials import ServicePrincipalCredentials
from azure.mgmt.compute import ComputeManagementClient
from azure.mgmt.resource import ResourceManagementClient, SubscriptionClient

# Tenant ID for your Azure Subscription
TENANT_ID = ''

# Your Service Principal App ID
CLIENT = ''

# Your Service Principal Password
KEY = ''

credentials = ServicePrincipalCredentials(
    client_id = CLIENT,
    secret = KEY,
    tenant = TENANT_ID
)

subscription_id = ''

compute_client = ComputeManagementClient(credentials, subscription_id)

rg = 'shuilinux'

disks = compute_client.disks.list_by_resource_group(rg)
for disk in disks:
    print disk
  • And also refer this thread to fetch the backup details of Azure VM using python SDK.
RKM
  • 1,234
  • 1
  • 4
  • 9