Citrix Daas - Azure - VM Booting Issue (after using Azure Image Gallery)

Citrix Daas - Azure - VM Booting Issue (after using Azure Image Gallery)

book

Article ID: CTX693145

calendar_today

Updated On:

Description

Could not see VM created in the Citrix DaaS & Azure (Azure Image Gallery) as it keep going in power off state immediately when attempting to boot 
- Unable to see VM [OsDisk] in the Azure Portal  
- Only Identity Disk & NIC card is getting created in the Azure Portal

Resolution

Overview

========
Download Remote PowerShell SDK & access their Cloud Tenant 

Remove the ImageManagementPrep_DoImagePreparation = $False and any other configurations outside the default config.

Enabled the logging for the PrepVM
Unable to access PrepVM (via RDP or bastion due to Security) 
We took a snapshot of the PrepVM -> Created a Drive out of the snapshot -> Added the drive to an existing VM to review



Detailed Steps

===========
** First Download the Remote Powershell SDK: https://www.citrix.com/downloads/citrix-cloud/product-software/xenapp-and-xendesktop-service.html

** Install on a VM on the internal Network (However do not install on Cloud Connectors)

 

** Launch the PowerShell SDK in elevated mode (Run as admin)

                i.    Run the following commands

                ii.   ASNP Citrix*

                iii.  GET-XDAuthentication

 


 

** Once prompted & you successfully entered your Cloud Credentials - Proceed with the following commands:

------------------------------------------------------------------------------------------------------------------------------------------------

Posh:> Remove-ProvServiceConfigurationData -Name ImageManagementPrep_DoImagePreparation

 

 

On the Master Image VM

==================

Under HKLM\Software\Citrix\MachineIdentityServiceAgent

  • Create the DWORD [LOGGING] with value =1 
  • Reboot for it to take effect
  • Update the Azure Image Gallery version with these changes

 

 

Use the updated Azure Image Gallery version to create a new Catalog

==========================================================

 

You will see on the Azure side a VM ("Imageprep_xxxxxxx")

  • If you cannot Bastion / RDP onto that VM (to collect the Image-prep.log under C:\ProgramData\Citrix\ImagePreparation
  • You will need to take a snapshot of the PrepVM > convert the Snapshot to a Drive & attached the Drive to an existing VM (on Azure)
  • Use diskmgmt.msc, on the VM you have attached the drive to, to initialize the drive to a letter [ If for example the letter is F:\  the log is under F:\ProgramData\Citrix\ImagePreparation]

Using the ImagePrep.log
====================
Identify what is the real issue occurring during the Image preparation (in our case there was a re-arm issue with the OS & MS Office)


Options 
======
1) Mask the issue (by excluding the Rearming of the OS & Office from the image preparation process)

Using the Remote Powershell SDK:

--------------------------------------------

Posh:> Remove-ProvServiceConfigurationData -Name ImageManagementPrep_DoImagePreparation

Posh:> Set-ProvServiceConfigurationData -Name ImageManagementPrep_Excluded_Steps -Value "OsRearm,OfficeRearm"

 

** Validate the changes are set correctly by using the command [ Get-ProvServiceConfigurationData ] **
** Then remove after creating the new Catalog (as this affects globally anyone trying to create a new catalog on your Citrix Cloud tenant **

 

Using the Remote Powershell SDK:

--------------------------------------------

Posh:> Remove-ProvServiceConfigurationData -Name ImageManagementPrep_Excluded_Steps 

 

 

2) Resolve the O.S & Office related issue on your Master Image

Re-arming Issues, these Issues usually lie on the Windows Side:

===================================================

Permissions & WMI related issues

 

A) Use the WMI Classes to confirm that the software [SoftwareLicensingService] exists & retails like ClientMachineID, LicenseStatus, etc.

 

- ClientMachineID is tied to Windows activation. If the OS is not properly activated, this field may be empty.

 

 

Posh:> Get-WmiObject -Namespace "root\cimv2" -Class SoftwareLicensingService

Posh:> Get-WmiObject -Namespace "root\cimv2" -List | Where-Object { $_.Name -like "Software" }

 

 

 

B) Registry Permissions are as follows: 

 

   - HKLM\SOFTWARE\MICROSOFT\WINDOWS NT\CURRENTVERSION\SOFTWAREPROTECTIONPLATFORM

     - Security >Group or Username [SYSTEM] - has Permissions (FULL CONTROL & READ)

 

   - HKLM\SOFTWARE\MICROSOFT\WINDOWS NT\CURRENTVERSION\SOFTWAREPROTECTIONPLATFORM

     - Security > Group or Username [Administartors] - has Permissions (FULL CONTROL & READ)


C) Run this command to check activation status: 

    slmgr /dlv

 

 

Click OK and restart the Windows Management Instrumentation (WMI) service:

    net stop winmgmt

    net start winmgmt

 

 

Ensure that the WMI repo is not corrupt: 

    winmgmt /verifyrepository

     

 

Reset WMI repository: 

    winmgmt /resetrepository

     

 

Then, restart WMI:

    net stop winmgmt

    net start winmgmt

     

 

Restart the Software Protection Service:

    net stop sppsvc

    net start sppsvc

     

 

Verify rearm count:

    slmgr /dlv

     

 

If the remaining rearm count is 0, you may need to rearm manually before image preparation.

 

If rearm count is exhausted, reset it using a sysprep workaround:

    slmgr /rearm

    shutdown -s -t 0

 


Problem Cause

Upon checking the customers Cloud Tenant [ ProvServiceConfiguration ] details

  • We could see that the ImageManagementPrep_DoImagePreparation was set to $false

 

When you skip the Image preparation, it cannot find the appropriate Source ID (location of the Azure Image Gallery)

  • Error,"[AzPv_1]: Plug-in threw MachineCreationException within custom PowerOnWithBaseDiskReset operation: Citrix.MachineCreationAPI.MachineCreationException: Error starting machine. Invalid source id: azvmxxxx/WindowsServerGallery_Citrix/VDA-Definition/xxxx.

 

The VM Preparation is skipped (skipping all the checks along with it [OfficeRearm, EnableDHCP, PrepareMSMQ, OsRearm, PrepJoinDomain, RequirePvd, RequireWbc, AppScanning] )

  • So we could not identify the real cause of the issue (it kept giving us the generic "No Image results fund. There may not be a suitable VDA installed, or some other serous failure in the master Image VM. Image Preparation Failed"

 

Upon revert the ImagePreparation to default & access the PrepVM logs (we could see two issues)

1) Office is installed and rearm tool is present at 'C:\Program Files\Microsoft Office\Office16\OSPPREARM.EXE', executing

    Office rearm tool completed, exit code -2147024891

    Office Rearm process failed. Message=Office rearm failed: error code 0x80070005

 

 

2) Rearming Windows

 

   Caught exception in rearm Windows. System.UnauthorizedAccessException

      at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)

      at System.Management.ManagementObject.InvokeMethod(String methodName, ManagementBaseObject inParameters, 

 

          InvokeMethodOptions options)

             at Citrix.MachineCreation.ImagePreparation.SoftwareLicensingService.ReArmWindows()

             at Citrix.MachineCreation.ImagePreparation.ImagePreparation.RearmWindows(PreparationResults results)

Additional Information

https://www.citrix.com/blogs/2016/04/04/machine-creation-service-image-preparation-overview-and-fault-finding/

  https://support.citrix.com/article/CTX217456

  https://support.citrix.com/article/CTX140734

  https://www.citrix.com/blogs/2016/04/04/machine-creation-service-image-preparation-overview-and-fault-finding/

  https://www.vcloudinfo.com/2019/06/troubleshooting-citrix-machine-creation-services-mcs-stalling-at-50.html


https://support.microsoft.com/en-us/office/office-error-code-0x80070005-when-activating-office-7aa7600f-df57-4aef-81d2-25509c66f8655:02

https://learn.microsoft.com/en-us/troubleshoot/windows-server/licensing-and-activation/error-0x80070005-access-denied