CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-azure-mgmt-compute

Microsoft Azure Compute Management Client Library for programmatic management of Azure compute resources including virtual machines, scale sets, disks, and related infrastructure.

Pending

Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

Overview
Eval results
Files

images-galleries.mddocs/

Image and Gallery Management

Management of custom VM images, shared image galleries, and image versions for standardized deployments across organizations. This includes creating custom VM images, managing shared image galleries for enterprise-wide image distribution, and version control for application and OS images.

Capabilities

Custom Image Management

Operations for managing custom VM images created from generalized VMs or disks.

class ImagesOperations:
    def begin_create_or_update(
        resource_group_name: str,
        image_name: str,
        parameters: Image
    ) -> LROPoller[Image]:
        """
        Create or update a custom VM image.
        
        Args:
            resource_group_name: Name of the resource group
            image_name: Name of the image
            parameters: Image configuration including source VM or disk
            
        Returns:
            Long-running operation poller for Image
        """

    def begin_delete(resource_group_name: str, image_name: str) -> LROPoller[None]:
        """
        Delete a custom VM image.
        
        Args:
            resource_group_name: Name of the resource group
            image_name: Name of the image
            
        Returns:
            Long-running operation poller
        """

    def get(resource_group_name: str, image_name: str) -> Image:
        """
        Get custom VM image details.
        
        Args:
            resource_group_name: Name of the resource group
            image_name: Name of the image
            
        Returns:
            Image details
        """

    def list() -> Iterable[Image]:
        """
        List all custom images in the subscription.
        
        Returns:
            Iterable of all custom images
        """

    def list_by_resource_group(resource_group_name: str) -> Iterable[Image]:
        """
        List custom images in a resource group.
        
        Args:
            resource_group_name: Name of the resource group
            
        Returns:
            Iterable of custom images in the resource group
        """

Shared Image Gallery Management

Operations for managing shared image galleries for enterprise image distribution.

class GalleriesOperations:
    def begin_create_or_update(
        resource_group_name: str,
        gallery_name: str,
        gallery: Gallery
    ) -> LROPoller[Gallery]:
        """
        Create or update a shared image gallery.
        
        Args:
            resource_group_name: Name of the resource group
            gallery_name: Name of the gallery
            gallery: Gallery configuration
            
        Returns:
            Long-running operation poller for Gallery
        """

    def begin_delete(resource_group_name: str, gallery_name: str) -> LROPoller[None]:
        """
        Delete a shared image gallery.
        
        Args:
            resource_group_name: Name of the resource group
            gallery_name: Name of the gallery
            
        Returns:
            Long-running operation poller
        """

    def get(resource_group_name: str, gallery_name: str) -> Gallery:
        """
        Get shared image gallery details.
        
        Args:
            resource_group_name: Name of the resource group
            gallery_name: Name of the gallery
            
        Returns:
            Gallery details
        """

    def list() -> Iterable[Gallery]:
        """
        List all shared image galleries in the subscription.
        
        Returns:
            Iterable of all galleries
        """

    def list_by_resource_group(resource_group_name: str) -> Iterable[Gallery]:
        """
        List shared image galleries in a resource group.
        
        Args:
            resource_group_name: Name of the resource group
            
        Returns:
            Iterable of galleries in the resource group
        """

Gallery Image Definitions

Operations for managing image definitions within galleries.

class GalleryImagesOperations:
    def begin_create_or_update(
        resource_group_name: str,
        gallery_name: str,
        gallery_image_name: str,
        gallery_image: GalleryImage
    ) -> LROPoller[GalleryImage]:
        """
        Create or update a gallery image definition.
        
        Args:
            resource_group_name: Name of the resource group
            gallery_name: Name of the gallery
            gallery_image_name: Name of the image definition
            gallery_image: Image definition configuration
            
        Returns:
            Long-running operation poller for GalleryImage
        """

    def begin_delete(
        resource_group_name: str,
        gallery_name: str,
        gallery_image_name: str
    ) -> LROPoller[None]:
        """
        Delete a gallery image definition.
        
        Args:
            resource_group_name: Name of the resource group
            gallery_name: Name of the gallery
            gallery_image_name: Name of the image definition
            
        Returns:
            Long-running operation poller
        """

    def get(
        resource_group_name: str,
        gallery_name: str,
        gallery_image_name: str
    ) -> GalleryImage:
        """
        Get gallery image definition details.
        
        Args:
            resource_group_name: Name of the resource group
            gallery_name: Name of the gallery
            gallery_image_name: Name of the image definition
            
        Returns:
            Gallery image definition details
        """

    def list_by_gallery(
        resource_group_name: str,
        gallery_name: str
    ) -> Iterable[GalleryImage]:
        """
        List image definitions in a gallery.
        
        Args:
            resource_group_name: Name of the resource group
            gallery_name: Name of the gallery
            
        Returns:
            Iterable of image definitions in the gallery
        """

Gallery Image Versions

Operations for managing versions of gallery images.

class GalleryImageVersionsOperations:
    def begin_create_or_update(
        resource_group_name: str,
        gallery_name: str,
        gallery_image_name: str,
        gallery_image_version_name: str,
        gallery_image_version: GalleryImageVersion
    ) -> LROPoller[GalleryImageVersion]:
        """
        Create or update a gallery image version.
        
        Args:
            resource_group_name: Name of the resource group
            gallery_name: Name of the gallery
            gallery_image_name: Name of the image definition
            gallery_image_version_name: Version name (e.g., '1.0.0')
            gallery_image_version: Image version configuration
            
        Returns:
            Long-running operation poller for GalleryImageVersion
        """

    def begin_delete(
        resource_group_name: str,
        gallery_name: str,
        gallery_image_name: str,
        gallery_image_version_name: str
    ) -> LROPoller[None]:
        """
        Delete a gallery image version.
        
        Args:
            resource_group_name: Name of the resource group
            gallery_name: Name of the gallery
            gallery_image_name: Name of the image definition
            gallery_image_version_name: Version name
            
        Returns:
            Long-running operation poller
        """

    def get(
        resource_group_name: str,
        gallery_name: str,
        gallery_image_name: str,
        gallery_image_version_name: str
    ) -> GalleryImageVersion:
        """
        Get gallery image version details.
        
        Args:
            resource_group_name: Name of the resource group
            gallery_name: Name of the gallery
            gallery_image_name: Name of the image definition
            gallery_image_version_name: Version name
            
        Returns:
            Gallery image version details
        """

    def list_by_gallery_image(
        resource_group_name: str,
        gallery_name: str,
        gallery_image_name: str
    ) -> Iterable[GalleryImageVersion]:
        """
        List versions of a gallery image.
        
        Args:
            resource_group_name: Name of the resource group
            gallery_name: Name of the gallery
            gallery_image_name: Name of the image definition
            
        Returns:
            Iterable of image versions
        """

Gallery Applications

Operations for managing application packages in galleries.

class GalleryApplicationsOperations:
    def begin_create_or_update(
        resource_group_name: str,
        gallery_name: str,
        gallery_application_name: str,
        gallery_application: GalleryApplication
    ) -> LROPoller[GalleryApplication]:
        """
        Create or update a gallery application.
        
        Args:
            resource_group_name: Name of the resource group
            gallery_name: Name of the gallery
            gallery_application_name: Name of the application
            gallery_application: Application configuration
            
        Returns:
            Long-running operation poller for GalleryApplication
        """

    def begin_delete(
        resource_group_name: str,
        gallery_name: str,
        gallery_application_name: str
    ) -> LROPoller[None]:
        """
        Delete a gallery application.
        
        Args:
            resource_group_name: Name of the resource group
            gallery_name: Name of the gallery
            gallery_application_name: Name of the application
            
        Returns:
            Long-running operation poller
        """

    def get(
        resource_group_name: str,
        gallery_name: str,
        gallery_application_name: str
    ) -> GalleryApplication:
        """
        Get gallery application details.
        
        Args:
            resource_group_name: Name of the resource group
            gallery_name: Name of the gallery
            gallery_application_name: Name of the application
            
        Returns:
            Gallery application details
        """

Data Types

class Image:
    """Describes an Image."""
    id: Optional[str]
    name: Optional[str]
    type: Optional[str]
    location: str
    tags: Optional[Dict[str, str]]
    extended_location: Optional[ExtendedLocation]
    source_virtual_machine: Optional[SubResource]
    storage_profile: Optional[ImageStorageProfile]
    provisioning_state: Optional[str]
    hyper_v_generation: Optional[HyperVGenerationTypes]

class Gallery:
    """Specifies information about the Shared Image Gallery."""
    id: Optional[str]
    name: Optional[str]
    type: Optional[str]
    location: str
    tags: Optional[Dict[str, str]]
    description: Optional[str]
    identifier: Optional[GalleryIdentifier]
    provisioning_state: Optional[GalleryProvisioningState]
    sharing_profile: Optional[SharingProfile]
    soft_delete_policy: Optional[SoftDeletePolicy]
    sharing_status: Optional[SharingStatus]

class GalleryImage:
    """Specifies information about the gallery image definition."""
    id: Optional[str]
    name: Optional[str]
    type: Optional[str]
    location: str
    tags: Optional[Dict[str, str]]
    description: Optional[str]
    eula: Optional[str]
    privacy_statement_uri: Optional[str]
    release_note_uri: Optional[str]
    os_type: OperatingSystemTypes
    os_state: OperatingSystemStateTypes
    hyper_v_generation: Optional[HyperVGeneration]
    end_of_life_date: Optional[datetime]
    identifier: GalleryImageIdentifier
    recommended: Optional[RecommendedMachineConfiguration]
    disallowed: Optional[Disallowed]
    purchase_plan: Optional[ImagePurchasePlan]
    provisioning_state: Optional[GalleryProvisioningState]
    features: Optional[List[GalleryImageFeature]]
    architecture: Optional[Architecture]

class GalleryImageVersion:
    """Specifies information about the gallery image version."""
    id: Optional[str]
    name: Optional[str]
    type: Optional[str]
    location: str
    tags: Optional[Dict[str, str]]
    publishing_profile: Optional[GalleryImageVersionPublishingProfile]
    provisioning_state: Optional[GalleryImageVersionPropertiesProvisioningState]
    storage_profile: GalleryImageVersionStorageProfile
    safety_profile: Optional[GalleryImageVersionSafetyProfile]
    replication_status: Optional[ReplicationStatus]
    security_profile: Optional[ImageVersionSecurityProfile]

class GalleryApplication:
    """Specifies information about the gallery Application Definition."""
    id: Optional[str]
    name: Optional[str]
    type: Optional[str]
    location: str
    tags: Optional[Dict[str, str]]
    description: Optional[str]
    eula: Optional[str]
    privacy_statement_uri: Optional[str]
    release_note_uri: Optional[str]
    end_of_life_date: Optional[datetime]
    supported_os_type: OperatingSystemTypes
    custom_actions: Optional[List[GalleryApplicationCustomAction]]
    provisioning_state: Optional[GalleryApplicationPropertiesProvisioningState]

class GalleryImageIdentifier:
    """This is the gallery image definition identifier."""
    publisher: str
    offer: str
    sku: str

class ImageStorageProfile:
    """Describes a storage profile."""
    os_disk: Optional[ImageOSDisk]
    data_disks: Optional[List[ImageDataDisk]]
    zone_resilient: Optional[bool]

Usage Examples

Create Custom Image from VM

from azure.identity import DefaultAzureCredential
from azure.mgmt.compute import ComputeManagementClient

credential = DefaultAzureCredential()
compute_client = ComputeManagementClient(credential, "subscription-id")

# Create custom image from a generalized VM
image_parameters = {
    'location': 'East US',
    'source_virtual_machine': {
        'id': '/subscriptions/.../virtualMachines/myGeneralizedVM'
    },
    'tags': {
        'created_by': 'automation',
        'base_os': 'ubuntu-20.04'
    }
}

operation = compute_client.images.begin_create_or_update(
    'myResourceGroup',
    'myCustomImage',
    image_parameters
)
custom_image = operation.result()
print(f"Custom image created: {custom_image.name}")

Setup Shared Image Gallery

# Create shared image gallery
gallery_parameters = {
    'location': 'East US',
    'description': 'Company-wide standardized VM images',
    'tags': {
        'department': 'IT',
        'purpose': 'standardization'
    }
}

operation = compute_client.galleries.begin_create_or_update(
    'myResourceGroup',
    'myCompanyGallery',
    gallery_parameters
)
gallery = operation.result()

# Create image definition in the gallery
image_definition_parameters = {
    'location': 'East US',
    'description': 'Ubuntu 20.04 with company applications',
    'os_type': 'Linux',
    'os_state': 'Generalized',
    'identifier': {
        'publisher': 'MyCompany',
        'offer': 'Ubuntu',
        'sku': '20.04-LTS-Configured'
    },
    'recommended': {
        'v_cpus': {'min': 2, 'max': 8},
        'memory': {'min': 4, 'max': 32}
    }
}

operation = compute_client.gallery_images.begin_create_or_update(
    'myResourceGroup',
    'myCompanyGallery',
    'ubuntu-configured',
    image_definition_parameters
)
image_definition = operation.result()
print(f"Image definition created: {image_definition.name}")

Create and Distribute Image Version

# Create image version from custom image
image_version_parameters = {
    'location': 'East US',
    'publishing_profile': {
        'target_regions': [
            {
                'name': 'East US',
                'replica_count': 1,
                'storage_account_type': 'Standard_LRS'
            },
            {
                'name': 'West US 2', 
                'replica_count': 2,
                'storage_account_type': 'Standard_LRS'
            }
        ],
        'replica_count': 1,
        'exclude_from_latest': False,
        'end_of_life_date': '2025-12-31T23:59:59+00:00'
    },
    'storage_profile': {
        'source': {
            'id': '/subscriptions/.../images/myCustomImage'
        }
    }
}

operation = compute_client.gallery_image_versions.begin_create_or_update(
    'myResourceGroup',
    'myCompanyGallery',
    'ubuntu-configured',
    '1.0.0',
    image_version_parameters
)
image_version = operation.result()

# Check replication status
replication_status = image_version.replication_status
print(f"Replication State: {replication_status.aggregated_state}")
for region_status in replication_status.summary:
    print(f"  {region_status.region}: {region_status.state} ({region_status.progress}%)")

Create VM from Gallery Image

# Create VM using gallery image version
vm_parameters = {
    'location': 'East US',
    'hardware_profile': {
        'vm_size': 'Standard_B2s'
    },
    'storage_profile': {
        'image_reference': {
            'id': '/subscriptions/.../galleries/myCompanyGallery/images/ubuntu-configured/versions/1.0.0'
        },
        'os_disk': {
            'create_option': 'FromImage',
            'managed_disk': {
                'storage_account_type': 'Premium_LRS'
            }
        }
    },
    'os_profile': {
        'computer_name': 'vm-from-gallery',
        'admin_username': 'azureuser',
        'disable_password_authentication': True,
        'linux_configuration': {
            'ssh': {
                'public_keys': [{
                    'path': '/home/azureuser/.ssh/authorized_keys',
                    'key_data': 'ssh-rsa AAAAB3NzaC1yc2E...'
                }]
            }
        }
    },
    'network_profile': {
        'network_interfaces': [{
            'id': '/subscriptions/.../networkInterfaces/mynic'
        }]
    }
}

operation = compute_client.virtual_machines.begin_create_or_update(
    'myResourceGroup',
    'vmFromGallery',
    vm_parameters
)
vm = operation.result()
print(f"VM created from gallery image: {vm.name}")

Manage Gallery Applications

# Create gallery application for software deployment
app_parameters = {
    'location': 'East US',
    'description': 'Company database application package',
    'supported_os_type': 'Linux',
    'end_of_life_date': '2025-12-31T23:59:59+00:00',
    'custom_actions': [
        {
            'name': 'configure',
            'script': 'configure.sh',
            'description': 'Configure application settings',
            'parameters': [
                {
                    'name': 'dbConnectionString',
                    'type': 'String',
                    'description': 'Database connection string'
                }
            ]
        }
    ]
}

operation = compute_client.gallery_applications.begin_create_or_update(
    'myResourceGroup',
    'myCompanyGallery',
    'database-app',
    app_parameters
)
gallery_app = operation.result()
print(f"Gallery application created: {gallery_app.name}")

Gallery Application Versions Management

Management of application versions within gallery applications for software deployment and version control.

class GalleryApplicationVersionsOperations:
    def list_by_gallery_application(resource_group_name: str, gallery_name: str, gallery_application_name: str) -> Iterable[GalleryApplicationVersion]: ...
    def get(resource_group_name: str, gallery_name: str, gallery_application_name: str, gallery_application_version_name: str, *, expand: Optional[ReplicationStatusTypes] = None) -> GalleryApplicationVersion: ...
    def begin_create_or_update(resource_group_name: str, gallery_name: str, gallery_application_name: str, gallery_application_version_name: str, gallery_application_version: GalleryApplicationVersion) -> LROPoller[GalleryApplicationVersion]: ...
    def begin_update(resource_group_name: str, gallery_name: str, gallery_application_name: str, gallery_application_version_name: str, gallery_application_version: GalleryApplicationVersionUpdate) -> LROPoller[GalleryApplicationVersion]: ...
    def begin_delete(resource_group_name: str, gallery_name: str, gallery_application_name: str, gallery_application_version_name: str) -> LROPoller[None]: ...

Install with Tessl CLI

npx tessl i tessl/pypi-azure-mgmt-compute

docs

cloud-services.md

disks-storage.md

images-galleries.md

index.md

infrastructure.md

scale-sets.md

virtual-machines.md

tile.json