Skip to content

Latest commit

 

History

History
62 lines (53 loc) · 1.61 KB

python-sdk-azure-samples-list-images.md

File metadata and controls

62 lines (53 loc) · 1.61 KB
title description author manager ms.assetid ms.devlang ms.topic ms.service ms.technology ms.date ms.author
List images
Print all of the available images to use for creating virtual machines.
lisawong19
douge
python
article
Azure
Azure
6/15/2017
liwong

List images

Use the following code to print all of the available images to use for creating virtual machines, including all skus and versions.

region = 'eastus'

result_list_pub = compute_client.virtual_machine_images.list_publishers(
    region,
)

for publisher in result_list_pub:
    result_list_offers = compute_client.virtual_machine_images.list_offers(
        region,
        publisher.name,
    )

    for offer in result_list_offers:
        result_list_skus = compute_client.virtual_machine_images.list_skus(
            region,
            publisher.name,
            offer.name,
        )

        for sku in result_list_skus:
            result_list = compute_client.virtual_machine_images.list(
                region,
                publisher.name,
                offer.name,
                sku.name,
            )

            for version in result_list:
                result_get = compute_client.virtual_machine_images.get(
                    region,
                    publisher.name,
                    offer.name,
                    sku.name,
                    version.name,
                )

                print('PUBLISHER: {0}, OFFER: {1}, SKU: {2}, VERSION: {3}'.format(
                    publisher.name,
                    offer.name,
                    sku.name,
                    version.name,
                ))