Existing machine (vhd) as an image for creating multiple VM instances - azure

I have an existing VM with a configured Sharepoint environment. I would like to use this machine as a base for creating multiple azure VM instances for several developers to work on. Is such scenario possible? Is running 'sysprep' (will ruin my sharepoint) unevitable?
I would also be able to upgrade the 'image' (e.g. install windows updates) and create VM's from it afterwards.
How can I achieve this? I know cloudshare offers similar solution, so I suppose it also can be done in azure.

You certainly can make an image from a Virtual Machine. The entire process is described here. Also look at my other SO answer about a caveat when running sysprep (regarding not letting the VM image shut down after sysprep runs).
Once you have your image, it will be available in your Virtual Machine gallery, where you can choose it as your baseline for new VMs (either via portal or PowerShell / CLI).
If, in the future, you do updates on your master image, you'd need to re-create an image for future deployments. Or... you'd need to install the updates on each deployed VM instance.
Note: With web/worker role instances (which doesn't help for SharePoint but could help with other workloads you have), the Windows Server OS image is maintained by Microsoft. Should there be an OS update, these are taken care of for you.

Related

How do I deploy an application in Azure Scale Set VMs?

I have created a Azure Scale Set upto 3 Linux VMs using the Azure Portal. I have successfully installed java, maven and git on the first VM. I was able to run my App on the first VM.
I have a fan out trigger at 60% and fan in at 25%. Whenever my processing exceeds 60% a new VM is started.
But how do I deploy my app on the second VM? I have gone through this and found the second option custom VM image suitable for my purpose. But I fail to understand how it is achieved.
Is there a easier way or do I have to manually install everything that I did on my first VM?
You have several options available to do this, detailed here
From a single image that you keep refreshing each time you update the app or the os
using a VM Extension - refresh the extension url each time you want to update the vms, and then issue a ps or rest command to roll out the updates
use something like puppet/chef/dsc to pull updates from somewhere and install them - you could use msdeploy for example
use msdeploy from a script that iterates your vms and remote deploys.
I'm sure there are other ways too...
To do this, you will need to create a generalized VM image, put it into a storage account, then create a scale set based on that image.
Here are instructions for creating a generalized Windows VM image, see here: https://azure.microsoft.com/en-us/documentation/articles/virtual-machines-windows-classic-createportal/
For Linux, see here: https://azure.microsoft.com/en-us/documentation/articles/virtual-machines-linux-upload-vhd/
Once the image is in a storage account, you can use this example template to deploy it in a scale set (assumes Windows image): https://github.com/Azure/azure-quickstart-templates/tree/master/201-vmss-windows-customimage
Hope this helps! :)

I am a bit confused about deployment of cloud services, and particular whether just code can be replaced

Just getting used to VS2012 publishing of Cloud Services. At present I have a one instance webrole which contains a MVC3 application. I can publish it to Azure without issue, and it creates the Cloud Service>Web Role>VMs. Fine. Takes a little while.
However when I do a little code change how can I migrate just this code change without replacing all the VMs that implement the WebRole etc.
It seems that Code and infrastructure are inseparable, or have I misunderstood. Is there a way to just update the code bit?
Thanks.
When you roll out an update, you upload an entire package containing not only your code files, but also the configuration for the VM, such as # of instances, ports to open on the firewall, local resources to allocate, etc. These configuration settings are part of the code package - so there is more going on than just updating code files.
However, there are a couple of methods you can use to have more granular control over updates.
Use Web Deploy. One thing to keep in mind, is that any automatic service updates will restore your website to the last fully-deployed package, which may not be as up-to-date. You would only want to use this in staging, then do a full package update for production rollout.
Use an Azure Web Site instead, which allows continuous integration with your source control provider, and direct updates to the code.
Use an Iaas VM instead. These are basically the same as running your own custom server in the Azure cloud, and you have full control over the OS. However, you also have full responsibility for keeping the OS updated and secure.
You can also enable RDP to your Azure Web Role VM's. You will find all your code files there and IIS, but I wouldn't recommend updating your code this way for the same reasons listed in #1.
The code and infrastructure, in a cloud service, are actually separate. All you upload is a deployment package containing just your code and supporting libraries / files. You don't upload a vhd. Azure provides that for you, spinning up a vhd, and then accessing your code on a file folder on that vhd. Same process happens each time you scale out to more instances.
when you make a code change, you build a new deployment package and deploy that. If you do it as an in-place update (vs delete+redeploy), each role is updated on each instance (when you have multiple instances of a role, they're not all updated at the same time). You can even specify that you only want a single role within the deployment to be updated (helpful if, say, you have a worker role in addition to your web role, and want to leave all the worker role instances running).
when the code update happens, the VMs aren't replaced, but they are recycled, and when they start back up, they are running the updated code.
You can use WebDeploy with Cloud Services in production across multiple servers using the AzureWebFarm project (disclaimer: I maintain it).
Alternatively, you can also use the excellent Octopus Deploy deployment technology in conjunction with the AzureWebFarm.OctopusDeploy project (disclaimer: I maintain this one too).
To be honest though, if you just have a simple web app then I wouldn't both with cloud services - I'd just use Web Sites. Feel free to check out my blog post to see the situations which might force you to use cloud services though.
If you enable WebDeploy on the cloud service, you can use web deploy to publish the MVC application.
See http://msdn.microsoft.com/en-us/library/windowsazure/ff683672.aspx for details.
All of the above answers are correct and if you are trying to change your code for a production service you definitely want to do an in place upgrade as described. However, frequently during the dev/test phase or troubleshooting I want to make one small change and test it out quickly. To do this check out http://blogs.msdn.com/b/kwill/archive/2013/09/05/how-to-modify-a-running-azure-service.aspx which describes how to modify the code via RDP to the Azure VM.

Can I use a windows image as a guest OS for Azure WebRole?

I have this situation where I need to install and configure various things in the OS. I know that I can use VMs for this, but I need the code deployment functionality and wonder if there is a way to have a custom OS image and also be able to do code deployments using visual studio publish.
Custom OS images is not option for Web/Worker roles (i.e. True PaaS Cloud Services). However you add OS customizations via a Startup Task. I can hardly think of anything that is not possible via a startup task.

Is it possible to start a VM inside a WorkerRole?

I have a little OS that I'd like to start and use in Azure and thought about running a VM inside a WorkerRole. I know it is possible to use Azure VM roles for that but my exercise is to run it from inside a Worker/WebRole. Is that possible?
I tried installing VirtualBox and running that in a WorkerRole but when running the OS my WorkerRole just reboots.
Any help appreciated.
You cannot run a VM inside a VM in Azure. A Worker Role (or instances of a Worker Role) are already Windows Server 2008 / 2012 VMs. As #Robert pointed out, Azure has support for Virtual Machines, whether Linux or Windows, where you have complete control of its contents.
Regarding I have a little OS that I'd like to start: You can only run supported OS's that are listed in the Virtual Machine gallery: Ubuntu, CentOS, Windows Server, SUSE currently. More info on Linux VMs here, Windows Server here.
What you are trying to do is not technically supported by Microsoft and is not recommended (even if you could easily) since Azure is constantly taking down and bringing back up your Web/Worker role instances in a deployment.
This means that any manual changes made to your WorkerRole will be undone any time Azure bounces your deployment (i.e. data center issues, migrations, etc.) This happens much more often than you'd think.
You should check out Azure's VM support which may have what you need.

Confused about Azure VM Creation

So I am a little bit confused about the Azure feature to create virtual machines(i.e VMRoles).
When I do a quick create via the managment portal, I am not asked to specify nor a hosted service nor a storage account. After I click 'create' I see that a storage account is generated for me automatically with some unique name, but I don't see the same for a hosted service. Is a hosted service not needed to create a VM?
The thing that is confusing is that it seems like every other method for creating a VM does require me to specify a hosted service (Azure PowerShell, REST API). And indeed after I create the VM using one of these methods I see my VM inside the hosted service...
Anyone can explain this?
Thanks in advance
Please do not confuse Windows Azure Virtual Machines (IaaS, stateful) with Windows Azure VMRole (PaaS, stateless).
As for creation - the process behind the portal is automated. For me, I have a separate Cloud Service for each Virtual Machine I've created (along with the auto generated storage account). However as all operations are asyc, and I also guess the Microsoft teams are using some kind of CQRS pattern behind the portal, it might take some time for all the components behind a Virtual Machine to appear. While the API strictly requires everything to be ready set, before you actually create the Virtual Machine. My guess is that soon you will also see a cloud service created for your VM (it usually is with the name of the Virtual Machine you created). Also, if you have noticed, the public URI for accessing your Virtual Machine (be it RDP or SSH) has the format of [your_vm_name].cloudapp.net - so this is a Cloud Service (formerly known as Hosted Service).
First of all Windows Azure Virtual Machines and VM Role are two separate things. Based on what you have explained it seems you are trying to create a Windows Azure Virtual Machine so I will explain you in short how it works:
Very first: In order to create a Windows Azure Virtual Machine you need a VHD which has OS Image. You can use one from Gallery or you can upload one by yourself to your specific Blob Azure Storage.
When you use Quick create or create the process is exactly same in the background however during quick create lots of settings is already predefined as will quick create you will only get Windows OS VHD to choose. In both cases a storage account is used to copy the OS VHD (if it is not part of your OS image collection). In most of the cases a previously created storage account is used, so you may think in was not created but in fact the storage account was used to copy the VHD from repo. This may not be the case if you create a VM from an image which is already in your OS VHD collection.
With quick create the DNS name you set is become the VM name but with create you have option to create a different DNS name for your application but they needed in both cases. In any case the DNS name will bind to your VM, the same DNS name will distinguish your VM from others and a must to configure for any VM.
I believe that the cloud service is not surfaced for a single quick-create Virtual Machine. This is to make Virtual Machines as easy to use as possible. The cloud service would be created and be displayed on the portal were a second virtual machine to be added to the cloud service.

Resources