Adding an already running VM in Virtual Machine Manager to a Windows Azure Pack Subscription

Adding an already running VM in Virtual Machine Manager to a Windows Azure Pack Subscription

  • Comments 16
  • Likes

Hi Again

One thing I get asked quite often; is it possible to add an already running VM to a subscription in Windows Azure Pack (WAP), so it shows up in the WAP Tenant portal?

Scenario:

The blog post will have two scenarios:

Scenario1:

"A tenant has signed up a subscription and just migrated 2 Virtual Machines from on premise to service provider environment and as a service owner we want to assign those 2 VMs under his subscription"

I have two VMs called Contoso101 and Contoso102 running in Virtual Machine Manager (VMM) which I would like to add to my new WAP subscription.

Scenario2:

After the two VMs are added to the subscription we are going to give a co-worker at the Tenant access to the two VMs in the WAP Tenant Portal.

Solution:

Windows Azure Pack & Service Provider Foundation (SPF) allows tenants to access their VMs using subscription which are registered in VMM as user role and has access to the Cloud assigned for that subscription (plan).

For a VM to show under a subscription the following needs to happen:

  • The VM must be a member of the Cloud for which the Subscription (Plan) uses in Windows Azure Pack.
  • The VM Owner and User Role must be set to the tenant in WAP and user role for that subscription in VMM.

To add an already running VM to a WAP subscription do the following:

  1. Log in into the WAP tenant portal with the credentials of a tenant administrator that has an active subscription. (e.g. admin@contoso.com)
  2. Select VM Clouds and verify that the VM(s) you want to move are not already showing and that minimum one VM is running under the subscription.

    We are using the running VM to make sure we extract the right information to move the two VMs to the subscription.

    Figure 1: VM running under Contoso subscription in the WAP Tenant Portal

  3. Close the WAP Tenant Console.
  4. Open the WAP Admin Portal and login as an administrator.
  5. Select Plans.
  6. Select the plan that the VMs should be added to. (e.g. Contoso).
  7. Select Virtual Machine Cloud.

    Note the VMM Management Server and Virtual Machine Cloud for the VM Cloud Plan as we will use this later. (e.g. vmm01.contoso.com and Contoso).

    Figure 2: VMM Server and Cloud used by a VM Cloud Plan in WAP

  8. Click the "back arrow" to get back to Plans.
  9. Select Subscriptions.
  10. Notice the user for the subscription, as we will use this later (e.g.: User: admin@contoso.com).

    Figure 3: Plan and user showing for a subscription in the WAP portal

  11. Login to the WMM Server as VMM Administrator.
  12. Start the VMM Console.
  13. Select VMs and Services.
  14. Select Clouds.
  15. Select the Cloud for which the WAP VM Cloud Plan is mapped (e.g. Contoso).
  16. Right Click on a Virtual Machine which was showing in the WAP Tenant Portal and select Properties.

  17. Select Access in the left menu
  18. Note the Self-service Owner (e.g. admin@contoso.com (admin@contoso.com_4afe55ef-c171-4b48-8a02-97aee2e7ed34))

     

  19. Click Ok to close the VM Properties.
  20. Click on All Hosts.
  21. In the search windows search for the VMs you would like to add to the WAP subscription (e.g. Contoso1).

    Note: In the list above, two VMs are showing that does not belong to a cloud. (Contoso101 and Contoso102).

     

  22. Right click on the first VM and select Properties (e.g. Contoso101).
  23. Under General select the Cloud (from the drop down) which the VM should belong to, according to the WAP Plan. (E.g. Contoso).
  24. Click OK.
  25. Do the same for the other VM (e.g. Contoso102).
  26. Click on the Cloud that the VMs were assigned to under Clouds and verify that the VMs have been added.

  27. Open a VMM PowerShell windows from the start menu.
  28. Connect to VMM Server by using the ForOnBehalfOf parameter in VMM, this will allow you to make use of tenant users in VMM and setting the owner for a VM, for a user which is not in AD.

    Run the following command:

     

    $SCVMMSERVER = Get-SCVMMServer -ComputerName vmm01.contoso.com -ForOnBehalfOf

     

    We want to take the following properties from the already running VM in the cloud and save them to the following variables:

    Owner

    User Role

     

  29. Run the following command to extract the needed information from the VM which is already running under the WAP Tenant Subscription (e.g. Contoso01):

    get-vm -name contoso01 |ft name, selfserviceuserrole, owner

     

  30. Set the variables for the VMs, where Contoso01 is the VM currently running in the WAP Tenant Portal and Contoso101 is the VM we would like to move to the WAP Subscription.

    $vmnamesource = "contoso01"

    $vmnametarget = "contoso101"

    $vminfo = Get-SCVirtualMachine -name $vmnamesource

    $vmowner = $vminfo.owner

    $vmselfserviceuserrole = $vminfo.selfserviceuserrole

     

  31. Set the Owner and the self-service user for the VM by running the following command:

    Set-SCVirtualMachine –VM $vmnametarget –UserRole $vmselfserviceuserrole –Owner $vmowner

     

     

  32. Verify the result in VMM.

     

  33. To move Contoso102 VM to the Contoso subscription just set the $vmnametarget variable to contoso102 and run the command again.

    $vmnametarget = "contoso102"

    Set-SCVirtualMachine –VM $vmnametarget –UserRole $vmselfserviceuserrole –Owner $vmowner

     

     

  34. Open the WAP Tenant Portal.
  35. Login in as the subscription admin (e.g. admin@contoso.com).
  36. Select Virtual Machines.
  37. Verify that the two new VMs shows in the list of VMs.

  38. Click Start and verify that the VM performs the action

  39. In the VMM Console verify that the two VMs are in fact running.

 

Adding a co-administrator to a subscription

The second part of the scenario is to add a co-administrator the Contoso subscription, so this user also can access the cloud resources under the Contoso subscription. To do this perform the following steps:

  1. Login to the WAP Tenant Portal as the Subscription owner of a plan.
  2. Click My Account.
  3. Click Administrators.
  4. Click Add from the bottom menu.
  5. Write the e-mail of the user you would like to be a co-administrator (e.g. john@contoso.com).
  6. Select the Subscription(s) that you would like the co-administrator to have access to.
  7. Click OK.
  8. Verify that the new user shows in the list.

  9. Sign Out from the tenant portal.

  10. Click Sign in back to Service Management Portal.
  11. Select
  12. Provide the user name created earlier (e.g. john@contoso.com).
  13. Provide a password and click sign up.
  14. Complete the Welcome Screen wizard.
  15. Click Virtual Machines.
  16. Verify that you have the same list of VMs as the subscription owner.

  17. Close the WAP Tenant portal.

 

Hope this blog post helps you with adding already running VMs in Virtual Machine Manager to a Windows Azure Pack subscription and how it's possible to also add a Co-Administrator to a subscription.

While writing this blog post I stumbled over another blog post from an MVP (Hans Vredevoort), which has a similar approach to the VM scenario which can be viewed here.

Hans Vredevoort is also one of the people behind WAP Wiki blog that brings a good overview of WAP Blog Posts that can be found on the Internet, the Wiki can be found here.

Happy moving VMs to a WAP Subscription.

Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment
  • It looks like the VMSelfServiceUserRole is a combination of owner and subscription ID, is there any way of doing this without needing to copy it from another VM?

    I tried to manually add it, but get an error stating 'cannot convert value of type "System.String" to type "Microsoft.SystemCenter.VirtualMachineManager.UserRole"...

    Help? :)

  • Hi,

    I have tried the same operation as Ryan and also get the error as mentioned by Ryan.
    Set-SCVirtualmachine -VM $VMName -UserRole $UserRole -Owner $Owner

    Ftm we don't have enabled VM creation by tenants in our Enterprise so I can't copy past from existing VM.
    Please advice how to put Owner and Role to a VM.

  • As per step 18. Note the Self-service Owner (e.g. admin@contoso.com (admin@contoso.com_4afe55ef-c171-4b48-8a02-97aee2e7ed34))

    I don't get the email address, it checks only for the domain name contoso\admin and not the email address

  • As per the instructions in point:
    18. Note the Self-service Owner (e.g. admin@contoso.com (admin@contoso.com_4afe55ef-c171-4b48-8a02-97aee2e7ed34))

    I am unable to add with the GUID but only with the domain user, the guid that I copy form the portal and try to find to add it, does not resolve

  • Hi Anders,
    Mine is having the same scenario as Joe, which we don't have an enabled VM created by tenants. I too, encountered the same error as other 'cannot convert value of type "System.String" to type "Microsoft.SystemCenter.VirtualMachineManager.UserRole"...
    I broke up the parameters and found out that only the -UserRole has an error. The -Owner works fine.