Open mafernando opened 9 years ago
References:
Useful Snippets:
# List virtual machine images provisionable from subscribtion
foo = Azure::VirtualMachineImageManagement::VirtualMachineDiskManagementService.new
foo.list_virtual_machine_disks
# List virtual machines that are currently provisioned
foo = Azure::VirtualMachineManagementService.new
foo.list_virtual_machines
Azure To Do:
The virtual machine image source is not valid.
Notes:
Choose selection from Azure Image Gallery: http://azure.microsoft.com/en-us/documentation/articles/virtual-machines-create-custom/
Login to the VM to prep it for cloning: http://azure.microsoft.com/en-us/documentation/articles/virtual-machines-linux-how-to-log-on/
Template the VM to use as a base for clones: http://blogs.technet.com/b/keithmayer/archive/2013/01/17/step-by-step-templating-vms-in-the-cloud-with-windows-azure-and-powershell-31-days-of-servers-in-the-cloud-part-17-of-31.aspx
In Azure, first create a new Windows Server 2012 Datacenter base VM from Gallery.
Then connect to the VM and run the System Preparation Tool which will shutdown the VM. When the VM is shutdown, select the VM in the management portal and capture an image from it. When capturing a VM to an image, the original VM that is captured will be deleted from your Windows Azure subscription account. The original VM is replaced by the newly captured image
# Use this command to list provisionable VM images
foo = Azure::VirtualMachineImageManagement::VirtualMachineDiskManagementService.new
foo.list_virtual_machine_disks
# Sample Response - specify @image as :image attribute for provisioning
#<Azure::VirtualMachineImageManagement::VirtualMachineDisk:0x007fb3dde310a0
# @attached=false,
# @image="custom_vm_image.vhd",
# @name="vmname",
# @os_type="Windows",
# @size="128">
# Create a new Fog Azure Connection
azure = Fog::Compute.new(
:provider => 'Azure',
:azure_sub_id => 'subscription_id',
:azure_pem => 'azure.pem',
:azure_api_url => 'https://management.core.windows.net'
)
# Provision the Server
# This does not enable Remote Desktop
server = azure.servers.create(
:image => 'custom_vm_image.vhd',
:location => 'West US',
:vm_name => 'fogtest',
:vm_user => "user",
:password => "ComplexPassword!123",
:storage_account_name => 'fogteststorage'
)
# Delete a virtual machine service object
virtual_machine_service = Azure::VirtualMachineManagementService.new
virtual_machine_service.delete_virtual_machine('fogtest', 'fogteststorage')
To Do: