Home » System Center Virtual Machine Manager
Category Archives: System Center Virtual Machine Manager
Setting up VM Roles in WAP
I have been preparing our TechEd session last weeks. During this I have solved a number of challenges in Windows Azure Pack. In this post I will share challenges and solutions.
Challenge 01 – Unexpected error
This occurred when a tenant tries to deploy an instance of a VM role from the tenant portal. I started to verify the following settings on both the template VHDX file and the gallery item
- Operating System, for example Windows Server 2012 R2 Standard
- Family name, for example Windows Server 2012 R2 Standard
- Tags, for example Windows
- Version. Remember that version must be in format X.X.X.X for example 1.0.0.0
The solution was that the Library share where the VHDX file was stored was not set as a Read-Only share for the cloud. Once added the Library share to the cloud as Read-Only library share it worked to deploy VM Role instances.
Challenge 02 – …not allowed by any capability profile supported by the cloud
The cloud, Contoso Cloud for developers, had Hyper-V as capacity profile selected. But for VM Roles you cannot use a capability profile, because the VM Role model does not have a property in which to express a capability profile (because it is designed to be consistent with Azure and Azure has no notion of capability profiles). The solution was to uncheck Hyper-V Capacity on my target cloud. Update KB 2936967 removes the requirement for Hyper-V Capability Profile on the VMM Cloud. With this update it is a bit easier to handle clouds used for both VM templates and VM roles.
Challenge 03 – Product key in a VM Role resource definition
There is no option to set Windows product key when configure a resource definition. An easy way to solve it is to use the set-scvirtualharddisk cmdlet to set the product key on the virtual hard disk in VMM.
Challenge 04 – Windows Could not apply unattend settings during pass [specialize]
I connected to the Hyper-V host, opened Hyper-V managed and looked at the floppy disk that was connected to the VM. I open the floppy disk file and read the XML. There was a part about joining the domain. As DHCP configure wrong DNS that was the problem, the VM could not join the domain and hang during installation. I re-configured in VM Role Authoring Tool, imported the new gallery item, marked it as public, added it to the plan, re-login the tenant and re-deployed. Then it worked.
Challenge 05 – Error 31356
Error (31356)
Unable to find the referenced Resource Extension, containing Name=Contoso_FileSrv_ResourceExtension Publisher=Contoso and Version=4.0.0.0.
Recommended Action: Try the operation again after fixing the Resource Definition or importing the Resource Extension.
Solution was to remove the item from the plan and save the plan. I waited until the plan was synchronized again and then re-added the item to the plan again. The root cause was that I re-import the resource extension to VMM after importing the resource definition to Windows Azure Pack portal and adding it to a plan.
Challenge 06 – Plan syncing hang
Plan remain in syncing state till all subscriptions belong to plan get synced. You can see this update happening in admin portal by going to subscriptions tab inside that plan. You will see some subscriptions which are already synced (i.e. in active Or Out-Of-Sync state) and some currently syncing (i.e. in Syncing…. State). Once all subscriptions belong to plan get synced then plan will stop syncing. In my case the solution was to apply VMM update 1, including the scripts. I read some threads about people who had seen this issue when they had forget about the scripts in update 1.
Challenge 07 – Error (22663)
The BITS client job failed to succeed for C:\ProgramData\VirtualMachineManagerData\TempResources\3e23bd43fad847e995279686e8547841\ConfigurationFile.ini resource with the following error: The server name or address could not be resolved
Error context: The error occurred while the remote file was being processed.
Error code: -2147012889
This I solved by unchecking the VM network from the Library. If you uncheck the network, VMM will try to transfer file with ISO instead of BITS/network. Else it will try to use BITS/network for some basic configuration file. In my sandbox new VMs don’t have working IP settings, therefor any kind of network communication fails. With this setting it works anyway, as VMM will use an ISO instead.
Challenge 08 – Error (22743)
The host agent on the host hyper119.contoso.local for virtual machine MyMachine001 is not up to date and cannot provision the physical resources required for the servicing operation.
Recommended Action
Ensure the virtual machine has network connectivity to the library servers, or that the host agent is up to date, and then retry the operation.
This I solved by update to 2012 R2 Update 1 on VMM server, ran Update 1 SQL script and updated all Hyper-V host agent to Update 1.
Deploy a new service instance with Powershell in VMM 2012
I read on Technet that Microsoft recommend to use service templates in VMM 2012 even for a single server. Instead of using a VM template we should use a service template to deploy a new virtual machine. In Orchestrator there is an activity in the Virtual Machine Manager (VMM) integration pack that can create a new virtual machine from a template. But there is no activity to create a new instance from a service template. So I copy/paste “wrote” a script that deploys a new instance of a service, based on a service template. This is a very basic and simple example script that you can use as a foundation. The script will ask for five input parameters
- CloudName = Target cloud in VMM for the new service
- SvcName = Name of the new service. As I only deploy a single server I use the computer name as service name too
- ComputerANDvmName = The name that will be used both for the virtual machine and the computer name
- SvcTemplateName = The service template to use
- Description = A description that will be added to the new service instance
Param(
[parameter(Mandatory=$true)]
$CloudName,
[parameter(Mandatory=$true)]
$SvcName,
[parameter(Mandatory=$true)]
$ComputerANDvmName,
[parameter(Mandatory=$true)]
$SvcTemplateName,
[parameter(Mandatory=$true)]
$Description)
Import-Module ‘C:\Program Files\Microsoft System Center 2012\Virtual Machine Manager\bin\psModules\virtualmachinemanager\virtualmachinemanager.psd1’$cloud = Get-SCCloud -Name $CloudName
$SvcTemplate = get-scServicetemplate -Name $SvcTemplateName
$SvcConfig = New-SCServiceConfiguration -ServiceTemplate $SvcTemplate -Name $SvcName -Cloud $cloud -Description $Description
$WinSrvtierConfig = Get-SCComputerTierConfiguration -ServiceConfiguration $SvcConfig | where { $_.name -like “Windows*” }
$vmConfig = Get-SCVMConfiguration -ComputerTierConfiguration $WinSrvtierConfig
Set-SCVMConfiguration -VMConfiguration $VMConfig -name $ComputerANDvmName -computername $ComputerANDvmName
Update-SCserviceConfiguration -ServiceConfiguration $Svcconfig
$newSvcInstance = New-SCService -ServiceConfiguration $Svcconfig
The script first create and configure a service deployment configuration. The service deployment configuration is an object that is stored in the VMM Library that describes the new service instance, but it is not running. The last two lines in the script will pick up that service deployment configuration and deploy it to. All settings of the new service instance is stored in the service deployment configuration. In my service template, named “Contoso Small”, I have a tier named “Windows Server 2008R2 Enterprise – Machine Tier 1” that is why the script search for a tier with a name like “Windows*”.
When we have a PowerShell script we can easy use it from a runbook in Orchestrator to deploy new instances of services.
Note that the script is provided “AS-IS†with no warranties.
Handle disk IOPS when deploying/deleting or update a virtual machine
A couple of weeks ago I needed to build a solution where disk IOPS are allocated when a new virtual machine is deployed. The scenario was that virtualization administrators wanted to make sure no disks was over allocated looking at disk performance. When Virtual Machine Manager deploy a new virtual machine it doesn’t look at what kind of virtual machines that are already deployed at the disk, only at the current disk load. In worst case this could result in very poor disk performance if all virtual machines start working heavily with the disk at the same time. In the virtual environment we had three virtual machine templates, small, medium and large. There was a estimate of disk IOPS required by each template. Virtualization administrators needed to make sure that not more than one virtual machine based on the large template was deployed to a disk and that new virtual machines was deployed to the disk with most free IOPS. Also make sure that no disk was over allocated when looking at disk IOPS.
In Service Manager disks will show up as CI if you have a connect to Operations Manager. But default properties of the disk class was not enough, we needed to store information about disk IOPS and didn’t want to affect anything else, so we created a new configure item class, that would only be used for this purpose. The new class was created with Service Manager authoring tool, example here.
We could now create CI objects for each disk that the virtual environment was using. Disk CI include max, allocated and free IOPS. We then published an offering in the Service Manager self-service to request new virtual machines. We used a runbook to deploy the new virtual machine. As you can see in the runbook below we have a main runbook building the virtual machines, then we invoke another runbook to figure out which disk to use. The runbook also write a register value to the new machine with information of the template used. Operations Manager will later discover this information and start monitor the new virtual machine based on the virtual machine template. Virtual machines are monitored with different thresholds and in different ways based on which template that was used during deployment.
The “Get disk” figure out which disk to use. It use a temp database to store disk information in, so the first step in the runbook is to clean this database to make sure it runs with fresh data. It then adds data to the temp database about each virtual machine template, and query Service Manager to find all disks that have enough free IOPS based on the virtual machine template. After the junction activity the runbook runs a SQL query to find out which disk to use, if we are about to deploy a new virtual machine based on the large template we also check if there is a free disk with enough IOPS that don’t already host a large virtual machine.   In the end the runbook updates the disk CI in Service Manager, allocate the disk IOPS,then returns which disk to use to the “main” runbook that will continue to build the virtual machine.
We also created a runbook to handle deletion of a virtual machine, including giving back allocated disk IOPS to the correct disk CI. We created one portal offering also around update a virtual machine, for example if a machine is running based on the medium template but need more RAM we can update it to a large template. Portal offerings for deletes and updates virtual machines use a query result to show only virtual machines there the portal user are owner, to make sure no one deletes or updates the wrong virtual machine.
example of the runbook that update of virtual machines
example of the runbook that delete virtual machines
Dynamic web farm with Opalis, VMM, OPSMGR and SCSM
I have built a scenario where I use Opalis, Virtual Machine Manager, Operations Manager and Service Manager to control number of web servers in a web farm. The web farm is behind a NLB cluster. The scenario was to only have enough with IIS running, no extra IIS machines that is not doing anything. If one IIS can handle the current load, there should only be one IIS online.
We use Service Manager to track what is happening. Opalis executes and Service Manager remembers. As soons as Opalis is done, it will drop everything, it only keeps it in memory during execution (and maybe some logs). Working with Service Manager will give us a great way to track everything.
Operations Manager are monitoring my IIS machines, if IIS01 is running low on resources an alert will be raised. If any other IIS in the web farm is idle another alert will be raised. When an alert about high load on IIS01 is raised the first Opalis policy starts. When an alert about a idle IIS is raised the “shut down” policy will start.
The purpose of this policy is to start a extra IIS, that is already in the web farm. The IIS will then relieve pressure from IIS01 that is running low on resources.
- The first activity monitor Operations Manager for new alerts about IIS01 running low on resources
- Set resolution state of the alert in Operations Manager to a Opalis resolution state. This makes sure no one else picks it up, instead you can see that Opalis is working on it in the Operations Manager console
- We use a counter to decide which IIS to start, this activity reset the counter to 0
- This activity gets all running machines from Virtual Machine Manager that is named something with IIS0. I have three IIS, named IIS01, IIS02 and IIS03.
- For each running IIS machine, add one to the counter (+1)
- The merge step is used to merge multiple treads, we don’t want to run the rest of the policy more the once. If step 4 returns multiple IISs a Junction activity is a good way to terminate parallel treads. One thing to remember here is that the merge step don’t publish any data from activities before it, so that is why we need to read the counter again.
- Reads counter value
- Add one (+1) to the counter. Each running VM added one to the counter and we want to start the next free IIS. If there is only one IIS running the value will be “1” then we add “1” and gets “2”. In step 9 we use that “2” to start IIS02
- Gets VM with name IIS0<Output from 8>, for example IIS02
- Create a change request in Service Manager saying the web farm is running low on resources and we need to add a extra IIS. We also include that we need to start the machine that we picked up in step 9
- Start the virtual machine. If it fails we will update set the change request to failure and add information around it, also generate an alert in Operations Manager
- Wait four minutes to make sure the virtual machine is up and running
- Trigger a policy to remove maintenance mode from Operations Manager
- Wait three minutes to make sure the maintenance mode is stopped
- Check if the web page is working on the IIS machine. If it fails we will set the change request to failure and add information around it, also generate an alert in Operations Manager
- Update the change request with result and change it to completed
The Stop Maintenance Mode policy is used to stop maintenance mode for machines that was shut down by Opalis earlier. This policy check if the affected machine is in maintenance mode, by checking Windows Computer (1), Health Service (2) and Health Service Watcher (4). We use a SQL query to get the agent watcher ID (3). These are the three objects that Opalis puts into maintenance mode when it shuts down a IIS in this example. Another example of Opalis and maintenance mode here.
The stop IIS policy will look for an alert in Operations Manager saying a IIS is idle, it will then shut down the IIS. In one version of this policy I added a run command activity that drain the IIS first from active sessions before shutdown.
- Monitor for an alert saying that a IIS is idle
- Set resolution state of the alert in Operations Manager to a Opalis resolution state. This makes sure no one else picks it up, instead you can see that Opalis is working on it
- Create a change request in Service Manager saying we will shut down a IIS, including name and reason
- Get VM to shutdown
- Put the Windows Computer into maintenance mode
- Put the Health Service into maintenance mode
- Query the OperationsManager database for the agent ID
- Put the agent watcher into maintenance mode
- Wait three minutes to make sure the maintenance mode is active
- Shutdown the machine (VM)
- Wait four minutes to make sure the machine is down
- Verify that the machine is down, else update the change request with a status equals failure and generate an alert in Operations Manager
- Update the change request with success and set status to completed
- Close the alert in Operations Manager
A couple of pictures of change requests in Service Manager
In this scenario and example I used two unit monitors in Operations Manager to trigger on a performance counter, to decide if IIS01 was running low on resource or if another IIS was idle. As the NLB will decide the load equal between my IIS machines I only measure load on IIS01, if I had two IIS online and IIS01 was low on resources IIS02 was that too.
In the first policy there should be a thread checking if already all IIS is running, then create a change request saying we need more IIS machines in the web farm. Or trigger another policy to create a new VM, configure it and include it in the web farm.
This export file have meet “mr Wolf†so it should not contain any unnecessary settings or objects.
You can download my policies here, ZIP file, please note that this is provided “as is†with no warranties at all. Also please read this blog post about export and import of policies.
Deploying servers and software with Opalis, Service Manager and Virtual Machine Manager
In my sandbox I often need to install a new server or a new server application for example SQL, IIS or Operations Manager. Unfortunaly I have never really learned how to use Configuration Manager to do that, deploy software and operating system. But lucky for me I have learned a bit about Virtual Machine Manager (VMM), Service Manager (SCSM) and Opalis. In this post I will describe for you how I deploy servers and apps in my sandbox.
The picture below show the policy I have for deploying new virtual servers. It includes a number of objects that first decide which VM host to use and then deploys the server. It all starts with a change request in Service manager. I will try to explain each step in the policy.
- The first object is from the Service Manager IP. I have built my own activity class in Service Manager, a deploy server activity. The new activity management pack includes a form where I can input VM Name, description and server type. Server type is a way to set which hardware to use, for example my DC machines will only get 1GB RAM. When a instance of this class gets in status “IN PROGRESS” Opalis will pick it up and start the policy. I have a blogpost here about writting a new custom activity class and integrate with Opalis, it also includes step how to use the new activity in a change request template.
- The following three objects is QMI Query objects. They query each of my Hyper-V Hosts for free memory. I want to deploy the new server to the host with most free RAM. Each of the WMI Query objects have a link to a Operations Manager object that will generate an alert if the policy cant query a machine for free RAM.
- Next item is a RUN .NET Script object. It runs a Powershell script. This script compare each of the hosts and returns the host with most free RAM. I guess I could solve it with a number of compare value objects, but it is easier with a script and it is only one object in the policy. As you can see in the beginning of the script I use DIV to get the free memory value in GB format.
- The “Map Published Data” object, Map Disk, is used to map which disk to use and which template to use. Depending on which Hyper-V server that has most free RAM, I want to use different logical disks. This object also map the server type fromthe Service Manager change request to a template in Virtual Machine Manager. The template controls what kind of hardware the virtual machine will get. For example if the server type is DC it will use a template with only 1 GB RAM.
- The “Create VM From Template” object connects to Virtual Machine Manager and creates the new virtual machine. I notice that when you work with this object, and want to test the connection to VMM, it does that from the machine where you run the console, not from the action server where you will run the policy. In my case my workstation did not have WS management installed, so the connection test failed. Instead I did that part from the Opalis server.
- The two “Update Activity” objects updates the change request in Service Manager. One if the machine cant be created and one if it worked out fine. As you can see in the picture I have updated the status of the change request and also added some info about where the virtual machine was created and which template that was used. All steps to update a change from Opalis is in this post.
Now when you have a easy way to create a new virtual machine the next step would be to install something on it, for example SQL server. This can also be done with Opalis 🙂 I have built a library of policies that each install small parts of a complete server. For example I have a policy to add the .NET Framework feature on a server.
I have another policy to unattend install SQL server. This policy first creates C:\temp, if the folder don’t exists. It then copy a INI file from a network file share. The INI file is the “answering” file for the SQL installation. It contains all the settings that you normally input manually during SQL installation. The policy then run the SQL setup, “D:\setup /ConfigurationFile=C:\temp\SQL2008R2_OPSMGR.ini /QUIET”. It is pretty easy to get the SQL unattend file, when you run the SQL setup wizard, on the last page you will see a path to a configuration file. You can copy that file direct from the path. The only thing I added to the INI file was “IAcceptSQLServerLicenseTerms=”TRUE””
When you have created your own library of policies that install and prepare machines you can create different “master workflows” that will create a new machine, install the application and configure the server for you. For example a “master policy” from installing a new Operations Manager server. This policy will then trigger the other policies. I use it almost every day in the sandbox and it saves me a lot of time. The policy below is a “master policy” for a new SQL server. It starts with a change request in Service Manager, it creates a new machine, run server setup to add for example .NET Framework and then it install SQL server. It finish by updating the change request. I have a notification in Service Manager that will notify me by e-mail when then machine is ready. If you want to take a look at the policy for the new machine, you can download it here 6.1 New Virtual MachineÂ
Please note that this is provided “as is†with no warranties at all. Update: There is a extension to the VMM IP that you can download here
Windows Server 2008 templates
This is a short step by step guide how to create a windows server 2008 template in SCVMM 2008.
- In the Virtual Machine workspace, create a new Windows Server 2008 virtual machine. Install Windows and configure as you like, for example run Windows Update. The templating process expects either a blank password or injects one, therfore you will need to edit your local security policy to allow “non complex passwords” (start Local Security Policy, Account Policies, Password must meet complexity requirements = FALSE). Make sure the machine is stopped.
- In the Library workspace, create a new software profile including for example product key, time zone, local administration password
- In the Library workspace, create a new hardware profile including suitable hardware. Read all about Windows Server 2008 systemrequirements here at Comparitech.
- In the Library workspace, navigate to templates, click New Template. Follow the wizard and select you new Windows Server 2008 machine as source. Select the hardware and software profiles that you created. The wizard will sysprep you machine and prepare it to be a template, it will also store the template in the library.
If you now want to use the new template, you go to the virtual machines workspace. Click “New Virtual Machine”, use a template, select your new Windows Server 2008 template, input a name, select your software and hardware profiles. Dont forgett to input a hostname under “Guest Operating System” (Input server name). After that, you have a new Windows Server 2008 machine built on your template machine, with your hardware profile and software profile applied.
Vmware > SCVMM
This weekend I have been playing in the sandpit with Hyper-V (build 6.0.6001.18016), System Center Virtual Machine Manager 2008 (beta), Vmware and Windows Server 2008. I had a lot of issues first (for example I often lost the connection to the server from the console) but after I applied SCVMM2008_Beta_ServerUpdate.msp the console started to work much better.
After moved one of my Vmware machines into the SCVMM library I started to converted it. The virtual-to-virtual conversion wizard was successfully but there was a couple of warnings saying that “Boot or system volume on the virtual machine is not found”. The virtual machine started but did not find a harddisk to boot from.
I think the problem was the Vmware virtual machine disc configuration. After I changed it and re-imported the machine in SCVMM library the virtual-to-virtual conversion was successfully without any warnings. I recommend you to uninstall Vmware tools before you convert the machine as you cant uninstall it without the “vmware tools.msi” file, that is easy accessible on your Vmware host, it works much better uninstalling it on the Vmware host in general.
In my sandpit a virtual-to-virtual conversion for a 19GB large machine took 11 minutes. next step will be to get everything monitored by Operations Manager 2007.
Recent Comments