Skip to content

Latest commit

 

History

History
55 lines (46 loc) · 1.5 KB

azure-sdk-samples-list-images.md

File metadata and controls

55 lines (46 loc) · 1.5 KB
title description ms.topic ms.date
List images
Print all of the available images to use for creating virtual machines.
conceptual
6/15/2017

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,
                ))