add-pssnapin microsoft.windowsazure.serviceruntime fails in WorkerRole (2008 R2)

Unanswered add-pssnapin microsoft.windowsazure.serviceruntime fails in WorkerRole (2008 R2)

  • 10 august 2012 21:22
     
     

    I have a powershell script that I run as a startup task in a worker role to do some installation and configuration lifting for me.

    I use the "add-pssnapin microsoft.windowsazure.serviceruntime" in VM Role, Web Role, and Worker Roles.

    However, it ONLY fails in the Worker Role and Web Role when osFamily="2" with osVersion="*"

    I have tried the Steve Mark timing workaround and even when I RDP to the Role I get the error.  All that I can determine is that the Role images have been created poorly.

    This error has been posted elsewhere, but the workaround does not function and me scripting a repair of the Role is an unacceptable workaround.

    The error is:

    PS D:\Users\rdpusr> add-pssnapin microsoft.windowsazure.serviceruntime
    Add-PSSnapin : Cannot load Windows PowerShell snap-in microsoft.windowsazure.serviceruntime because of the following er
    ror: The Windows PowerShell snap-in module E:\plugins\RemoteAccess\Microsoft.WindowsAzure.ServiceRuntime.Commands.dll d
    oes not have required Windows PowerShell snap-in strong name Microsoft.WindowsAzure.ServiceRuntime.Commands, Version=1.
    0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35.
    At line:1 char:13
    + add-pssnapin <<<<  microsoft.windowsazure.serviceruntime
        + CategoryInfo          : InvalidArgument: (microsoft.windowsazure.serviceruntime:String) [Add-PSSnapin], PSSnapIn
       Exception
        + FullyQualifiedErrorId : AddPSSnapInRead,Microsoft.PowerShell.Commands.AddPSSnapinCommand

    I am currently going back in time through various versions of the image to see if I can get back to a time when the error does not happen.


    Brian Ehlert
    http://ITProctology.blogspot.com
    Learn. Apply. Repeat.
    Disclaimer: Attempting change is of your own free will.


Toate mesajele

  • 13 august 2012 08:54
    Moderator
     
     

    Hi,

    I am trying to involve someone familiar with this topic to further look at this issue. There might be some time delay.
     
    Appreciate your patience.


    Please mark the replies as answers if they help or unmark if not. If you have any feedback about my replies, please contact msdnmg@microsoft.com Microsoft One Code Framework

  • 14 august 2012 02:15
     
     

    Hi Brian,

    Could you please provide the repro steps and the powershell script.


    Sri Harsha

  • 14 august 2012 13:30
     
     

    In the simplest sense, deploy a Web and Worker Role with the osFamily=2 setting.

    Then RDP to both Roles, open a PowerShell prompt and execute the command: add-pssnapin microsoft.windowsazure.serviceruntime

    (My script is not necessary to test this)

    Conversely, build a VM Role and install the WA Integration Components from the latest SDK, upload the VM, Create a VM Role and execute the same command - no error.

    The strong name enforcement was enabled by a Windows OS patch at one point in time (there are many third party cmdlets that suffered at the time - a bit of searching shows that).  My experience leads me to think that the SDK included integration components were updated with a new service runtime DLL, but the Azure managed root images were not.

    Mind you, I took a multi-month break from Azure work, but I can't image that I am the only person that is using a PowerShell script to drive application installation and configuration within a Worker and / or Web Role.


    Brian Ehlert
    http://ITProctology.blogspot.com
    Learn. Apply. Repeat.
    Disclaimer: Attempting change is of your own free will.

  • 16 august 2012 17:15
     
     

    Any movement on this? 

    Or do I need to open a bug?


    Brian Ehlert
    http://ITProctology.blogspot.com
    Learn. Apply. Repeat.
    Disclaimer: Attempting change is of your own free will.

  • 17 august 2012 09:37
     
     
    We are investigating and I will update on this thread as soon as possible.

    Sri Harsha

  • 23 august 2012 05:58
     
     

    Here is the work around : Update the following registry key using a startup task.

    HKLM\Software\Microsoft\PowerShell\1\PowershellSnapIns

    Change the AssemblyName, Version properties to refer the version number of 1.7.0.0 instead of 1.0.0.0

    You can refer the sample code provided in the below link :

    http://blogs.msdn.com/b/codefx/archive/2012/04/11/sample-of-apr-11st-add-registry-entries-to-vms-running-in-windows-azure-programmatically.aspx

    Steps for work around:
    =================================================
    1. Change AssemblyName and Version Properties to refer to the version number of 1.7.0.0 instead of 1.0.0.0. 

    How to create a .reg file : Make the appropriate changes in the registry, and then export the appropriate subkey or subkeys. Exported registry subkeys are automatically saved as .reg files.

    1. Click Start, click Run, type regedit in the Open box, and then click OK.
    2. Locate and then click the subkey that holds the registry item or items that you want to change.
    3. Click File, and then click Export. This step backs up the subkey before you make any changes. You can import this file back into the registry later if your changes cause a problem.
    4. In the File name box, type a file name to use to save the .reg file with the original registry items, and then click Save.

    ChangeVersion.reg

    ==============
    Windows Registry Editor Version 5.00

    [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\PowerShellSnapIns\Microsoft.WindowsAzure.ServiceRuntime]
    "ApplicationBase"="E:\\plugins\\RemoteAccess"
    "AssemblyName"="Microsoft.WindowsAzure.ServiceRuntime.Commands, Version=1.7.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
    "Description"="Provides access to the Windows Azure runtime environment."
    "ModuleName"="E:\\plugins\\RemoteAccess\\Microsoft.WindowsAzure.ServiceRuntime.Commands.dll"
    "PowershellVersion"="1.0"
    "Vendor"="Microsoft"
    "Version"="1.7.0.0"

    2. Create a batch file : ChangeRegistrySetting.cmd

    @echo off
    regedit.exe /s ChangeVersion.reg
    exit /b 0

    3. Code change in ServiceDefinition file
        <Startup>
          <Task commandLine="ChangeRegistrySetting.cmd" executionContext="elevated" taskType="simple">
          </Task>
        </Startup>
        <Sites>


    4. Set “Copy to output Directory = Copy always” for both .cmd and .reg file

    5. Deploy the application, RDP into the VM, open powershell command prompt and execute the below command: add-pssnapin microsoft.windowsazure.serviceruntime


    Sri Harsha

  • 23 august 2012 14:54
     
     

    Thanks for the answer.

    I hope this is only a band-aid and the images will eventually be fixed.

    This indicates to me that the images have been updated by simly copying in new DLL's and not running the installer (since the VM Role does not suffer this same fate).


    Brian Ehlert
    http://ITProctology.blogspot.com
    Learn. Apply. Repeat.
    Disclaimer: Attempting change is of your own free will.

  • 29 noiembrie 2012 16:47
     
     

    I found out that, with the October 2012 SDK, I need to update the version number to 1.8.0.0

    I hope this gets fixed soon...


  • 29 noiembrie 2012 19:05
     
     

    I have not checked this in a long time.

    The base Worker Role image is still not fixed?  Gee whiz.


    Brian Ehlert
    http://ITProctology.blogspot.com
    Learn. Apply. Repeat.
    Disclaimer: Attempting change is of your own free will.