Skip to content

Instantly share code, notes, and snippets.

@codingoutloud
Created March 3, 2017 20:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codingoutloud/55377c19c9acd85378c0db9f9f64f66d to your computer and use it in GitHub Desktop.
Save codingoutloud/55377c19c9acd85378c0db9f9f64f66d to your computer and use it in GitHub Desktop.
from azure import *
from azure.servicemanagement import *
subscription_id = '<your_subscription_id>'
certificate_path = '<path_to_.pem_certificate>'
sms = ServiceManagementService(subscription_id, certificate_path)
name = 'myvm'
location = 'West US'
# You can either set the location or an affinity_group
sms.create_hosted_service(service_name=name,
label=name,
location=location)
# Name of an os image as returned by list_os_images
image_name = 'OpenLogic__OpenLogic-CentOS-62-20120531-en-us-30GB.vhd'
# Destination storage account container/blob where the VM disk
# will be created
media_link = 'url_to_target_storage_blob_for_vm_hd'
# Linux VM configuration
linux_config = ('myhostname', 'myuser', 'mypassword', True)
os_hd = OSVirtualHardDisk(image_name, media_link)
sms.create_virtual_machine_deployment(service_name=name,
deployment_name=name,
deployment_slot='production',
label=name,
role_name=name,
system_config=linux_config,
os_virtual_hard_disk=os_hd,
role_size='Small')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment