Azure virtual machine libraries

Overview

On-demand, scalable computing resources running Linux or Windows.

To get started with Azure Virtual Machines, see Create a Linux virtual machine with the Azure portal.

Management API

Create, configure, manage and scale Windows and Linux virtual machines in Azure from your code with the management API.

Install the library via pip.

pip install azure-mgmt-compute 

Example

Create a new Linux virtual machine in an existing Azure resource group with Managed Service Identity(MSI) authentication.

VM_PARAMETERS={
        'location': 'LOCATION',
        'os_profile': {
            'computer_name': 'VM_NAME',
            'admin_username': 'USERNAME',
            'admin_password': 'PASSWORD'
        },
        'hardware_profile': {
            'vm_size': 'Standard_DS1_v2'
        },
        'storage_profile': {
            'image_reference': {
                'publisher': 'Canonical',
                'offer': 'UbuntuServer',
                'sku': '16.04.0-LTS',
                'version': 'latest'
            },
        },
        'network_profile': {
            'network_interfaces': [{
                'id': 'NIC_ID',
            }]
        },
    }

def create_vm()
    compute_client.virtual_machines.create_or_update(
        'RESOURCE_GROUP_NAME', 'VM_NAME', VM_PARAMETERS)

Samples

View the complete list of virtual machine samples.