Simple workflow for spinning up an Azure VM from a snapshot in ARM? - powershell

I need to move from Azure Classic Portal to ARM for working with VMs by November and am trying to get a jump start on learning the new process.
Here is what I do in the Classic Portal now...
Make a Windows Server VM:
Add some software, make some changes, shut it down and click the 'Capture' button in Classic. Provide a name, and label and now have a Snapshot I can make new VM copies from. Easy!
Make a new VM from snapshot:
Click New, Virtual Machine, From Gallery, My Images, Select Image, Create. So easy!
That's it. That's all I do, and all I need to do.
I make 10-30 VMs at a time that way and it's really quick and easy.
How can I do that same workflow in ARM?
I have tried json templates, cmdlets, and the UI in ARM, and cannot for the life of me figure out how emulate the workflow/functionality in Classic in ARM.
Any suggestions?
Thanks in advance!

If I understand correctly , you want to create multiple VMs from one VM Image in ARM.
After you preparing your VM correctly, here is the workflow to Copy VMs from an exiting VM :
Go to Virtual machines >select your VM>Capture>Provide Image Name and Image label (select the box if you have Sysprep your VM)>OK
Go to Images> select the Image you created> Create VM>Provide some necessary Basic information> Provide Size Information>Settings>Summary OK(You can create a template and use it to create more VMs easily in this step)
Note : How to prepare and Capture a Windows VM to a generalized image ,refer to this official document.
But ,if you want to create multiple VMs from a Classic Image in ARM (Usually, we can only create Classic VM by a Classic Image), it may be a lot work to do:
Create a new ARM Storage Account
Copy the Specialized VHD from your Source Storage Account to the new ARM Storage Account
Create your new VM and point the Source VHD (Specialized disk) to the copied VHD
More details about how to move Classic Image to ARM and use it to create VMs you can refer to this link .

Related

How can I move an app from one space to another?

I have created a new space in the organisation and I have to move several apps from one space to the newly created one. How can I do this? (I don't want to rename the old space since only a subset of its apps need to be moved.
I'm afraid there is no such function to move apps from one space to another. There are two possibilities to achieve it, though:
Compile & Push
If you have access to the source-code of the app and use a common CI/CD setup, simply adjust your scripts, have them point to the new space and trigger a complete CI/CD cycle.
Download & Push
If you don't have access to the source-code, the binary-repository where you store your binaries or have to ensure it is 100% the same droplet in the new space, you can download that droplet from Cloud Foundry and push it to the new space:
cf app source-app --guid to get your source app guid
cf curl /v2/apps/:source-guid/droplet/download --output /tmp/droplet.tgz to download the source app's droplet to your local machine (note that if your Cloud Controller is configured to use a remote blobstore this command will return a redirect to the actual location of the droplet)
cf target -s destination-space to target the space you want to push the copied droplet to
cf push --droplet /tmp/droplet.tgz destination-app-name
Credits: Github
This will work for buildpack-based apps but not for Docker-based apps, as you can't simply download docker-binaries.
Pitfall: If you want to use the same route again, don't forget to delete (not just unbind) it from your old space.

powershell script for connecting HyperV VMM and create a VM from specific template

does anyone know is there a way we can connect HyperV-VMM and create a VM using particular template using powershell ?
Yes it is possible. The best way to get started with this is to create the template in VMM and go through the creation process for the vm. Before you finish creating it though, on the last page in the bottom corner, you will see a view script button. This actually gives you the powershell version of what is being performed from the GUI.

I used sysprep on a VM (new portal) and lost connectivity to the machine

In the new portal, there's an icon that says 'Capture'. I assume this was for capturing an image of a VM (snapshot), but it was greyed out. Doing a little reading, several posts suggested running sysprep to prepare the machine for a capture.
I ran it according to those instructions, the machine appears to reboot, but all connectivity is lost.
Anyone know what's going on or how to fix it? Also, are there any ways to capture a snapshot in the new portal or do we need to use PS scripts?
the machine appears to reboot, but all connectivity is lost.
It is by design behavior. Before capture a VM image, we should use sysprep to generalize the VM, generalizing a VM removes all your personal account information, among other things, and prepares the machine to be used as an image.
After we run sysprep, we will lost all connection. Run sysprep, we should select shutdown:
For now, we can't via Azure new portal to capture a VM image. We can use PowerShell to capture a VM image, we can refer to this link.
you could create a virtual machine from an image. I can't find the
same function in the new portal.
We can't use Azure new portal to create a VM from image, we can use PowerShell to create a VM from image, we can refer to the link.
Most important:
Before you capture a VM image, you should back up you VM's VHD first, because the process will delete the original virtual machine after it's captured.
The latest version of PowerShell is 3.6.0, you can install it from this page.

VHD (Virtual PC) - how to force a Startup regardless of changed VHD

I am using a virtual machine to automate the execution of integration tests for a server-based product.
I am using "Windows XP Mode and Virtual PC" on a developer machine.
I am doing everything using PowerShell. I wish to:
mount the VHD (diskpart)
copy the release package onto the VHD file system
dismount the VHD (diskpart, again)
Start the VM
It is all fine as long as I don't do 2. If I change the VHD file system at all then 4. fails silently.
If I then go to the Virtual Machines on the Host and start the VM up using the GUI I get a warning:
"Inconsistency in virtual hard disk time stamp detected"
"The virtual hard disk's parent appears to have been modified"
I suspect there is a security feature in here (would make sense). But in my case this feature is not desirable.
Anyone know how to disable the timestamp checking or set the timestamp after I unmount the VHD (before?) ...?
EDIT: Look at the Startup2() options ... method takes one parameter, one of which says:
vmStartupOption_FixParentTimestampMismatch = 1
... from:
Microsoft method details
As per my edit - there is a Startup2() method that takes a parameter that says to ignore the timestamp.

Expanding Virtual Disk [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
Hey everyone, I'm using Virtual PC and working with a virtual hard disk (*.vhd) that is only sized at 8.2 GB. I would like to double the size to something like 16-20GB. I see options for compacting the VHD but nothing to expand it. It's set to "dynamically expand" but I'm installing some software and it doesn't seem to resize itself to a larger space.
Thanks much.
Heres my solution, using VHDResizer and DISKPART on a Windows XP host.
Download VHDResizer from hereFollowing these instructions from "Murnic" on this thread didnt work, on entering EXTEND, not sure on the exact wording now, but it was along the lines of cant extend this volume.
The easiest way to do this (as long as you have enough hard drive space) is to extend your existing VHD using VHD Expander which gives you two VHD files. The newly extended file will take the name of your existing VHD. You might want to Defragment, Precompact, and Compact your VHD prior to extending your VHD. In Virtual PC 2007 go to Settings. Select your OLD VHD as Hard Disk 1Select your newly extended VHD as Hard Disk 2Boot your VMOpen an Command PromptRun diskpartFrom DISKPART>
- Execute LIST VOLUME
- Select your new VHD volume by executing SELECT VOLUME where is your new VHD most likely 2
- Execute EXTEND
- You should see a success message. If not you may have to recreate your extended VHD due to an error in the process.Quit Diskpart.exe by typing EXITShut Down the VMRemove both VHD files from the Hard Disks listAdd your newly extended VHD as Hard Disk 1Boot your VM.You will get a Windows Newly Added Hardware message after a short time.Reboot the VM when promptedStart using your newly extended VHD! Here is Microsoft's information on extending volumes using Diskpart.exe: http://support.microsoft.com/kb/325590
So I went back to these instructions from 'AutoSponge' at the start of the same thread,
Mount the image
C:>Program Files\Microsoft Virtual Server\Vhdmount>vhdmount /m “C:Documents and Settings\All Users\Documents\Shared Virtual Machines\.vhd”
Start diskpart and expand the partition
C:>Program Files\Microsoft Virtual Server\Vhdmount>diskpart
DISKPART>list disk
DISKPART>select disk 3 -----check the number in the list
DISKPART>list part
DISKPART>select part 1 -----check the number in the list
DISKPART>extend DISKPART>list part -----check the new size
DISKPART>exit
Dismount and save changes
C:>Program Files\Microsoft Virtual Server\Vhdmount>vhdmount /u /c “C:Documents and Settings\All Users\Documents\Shared Virtual Machines\.vhd”
You can get download Microsoft Virtual Server here.
You can do a custom install and only select VHDMount
Some more information using VHDMount
Using VHDMount with Windows XP -
It is not possible to use '/m' (Mount), you can only use '/p' (Plug in).
The reason for this is that VHDMount uses VDS (the Virtual Disk Service) to assign a disk letter to the virtual hard disk after it is mounted, but VDS is only included in Windows Server 2003 and later. This is not too big of an issue though, as unlike Windows Server 2003, Windows XP will automatically mount the virtual hard disk when it is plugged in. This means that the only functionality you lose on Windows XP is the ability to specify exactly which drive letter should be used.
VHD Resizer
Never worked with Virtual PC but from other virtualization software I know I guess that dynamically expand means that initially the .vhd file will take less space in the HD than the specified and will dynamically grow as you keep installing programs or adding files into the virtual drive UP TO the specified size.
For what you want I guess that you will have to modify the specified size in the virtual hard drive from Virtual PC's setup window.
A bit offtopic but give a go to Virtual Box: www.virtualbox.org
For vmware users, you can download a free edition of vmware converter which not only lets you resize virtual disks but also lets you convert from physical to virtual machines and vice-versa.
Here is a solution that worked for me:
Use "CopyWipe" or a similar software to make a hardcopy to a new vhd, as described here:
Eric Cosky
I found it easier, simpler and safer to just create a second VHD and install my Big Software to that HD.
First detach the VHD then run those commands to expand your disk:
diskpart
Select vdisk file="Your Path"
list vdisk
expand vdisk maximum=new size in MB
attach vdisk
list disk
online Disk
list volume
select volume #
extend
list Volume
detach vdisk
exit
And here's a brief description for what each line does:
Launch the DiskPart utity.
Select the VHD file. Notice that if the path or the file name has spaces you have to put double quotes around it.
Shows you a list of Vdisks. The * at the left shows the one that is selected.
Changes the size of the vdisk to our new size.
Once the disk is expanded you have to mount it to work on the disk.
Shows the list of disks mounted disks and vDisks including ours.
If disk is not showing online you will need to bring it online.
List volumes(partitions). The ### column is the most important since it has the number you need to use to select the volume you will work with.
Select the volume we want to work with.
Extends the currently selected volume to use all contiguous available space on the same disk.
Running again to show the new size.
Dismounts the Vdisk volume so that Hyper-V can load it.
Exit diskpart utity.
However I give no guarantee this will work for everyone so keep the original around until you complete the process, just in case.