Creating a linux virtual machine from disk in azure using python

0 votes

I want to create a Linux virtual machine from a disk in azure using python. I found some links where it was suggested to do something with VHD, but it was not clearly explained how to do that. Can anyone explain the answer using python (not on CLI or powershell or in JSON).

I have referred this documentation :

VM_PARAMETERS = {

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

}

compute_client.virtual_machines.create_or_update(GROUP_NAME, VM_NAME, VM_PARAMETERS)

Please help me with this.

Aug 30, 2018 in AWS by bug_seeker
• 15,360 points
148 views

1 answer to this question.

0 votes

You specifically ask...

Can anyone explain the answer using python (not on CLI or powershell or in JSON).

Yet, you are asking the question in PowerShell Q&A forum.

Should you not be then asking the question on the python forums?https://stackoverflow.com/questions/tagged/python

All that being said. A VHD is a virtual hard disk. You have to have one, in place first, to attach to a VM, in order to spin up a virtual machine.
How to create an Azure VM with the azurerm Python library.
There are at least two ways to work with Azure infrastructure using Python. You can use the official Azure SDK for Python which supports all Azure functionality, or the azurerm REST wrapper library, which is unofficial and supports a subset of the Azure REST API.

https://msftstack.wordpress.com/2016/08/05/how-to-create-an-azure-vm-with-the-azurerm-python-library

answered Aug 30, 2018 by Priyaj
• 56,940 points

Related Questions In AWS

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

Pass account id of an AWS sub account using a variable as an argument in CloudWatch Alarm Actions with python (boto3)?

Python String and Integer concatenation >>> print("arn:aws:swf:us-east-2:{0}:action/actions/AWS_EC2.InstanceId.Stop/1.0".format(acccnum)) arn:aws:swf:us-east-2:12312312312312:action/actions/AWS_EC2.InstanceId.Stop/1.0 >>> print("arn:aws:swf:us-east-2:" ...READ MORE

answered Oct 5, 2018 in AWS by Priyaj
• 56,940 points
167 views