.netazureazure-cloud-services

Unsupported version of Azure.Core in Cloud Services Extended Support?


We have a web API that is still deployed as a cloud service (Extended Support). Everything was fine until the Azure.Core reference was updated from 1.31.0 to 1.44.1 because of new additional library dependencies. Now, the role won't start. I viewed the windows event log and was able to determine the issue. It seems that the role startup is still dependent on version 1.31.0.0. I'm not quite sure where that applies though.

Role entrypoint could not be created: System.TypeLoadException: Unable to load the role entry point due to the following exceptions: -- System.IO.FileLoadException: Could not load file or assembly 'Azure.Core, Version=1.31.0.0, Culture=neutral, PublicKeyToken=92742159e12e44c8' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) File name: 'Azure.Core, Version=1.31.0.0, Culture=neutral, PublicKeyToken=92742159e12e44c8'

Our web.config does have the appropriate binding redirect:

<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
    <dependentAssembly>
        <assemblyIdentity name="Azure.Core" publicKeyToken="92742159e12e44c8" culture="neutral"/>
            <bindingRedirect oldVersion="0.0.0.0-1.44.1.0" newVersion="1.44.1.0"/>
    </dependentAssembly>
</assemblyBinding>

After turning on some advanced logging, I was able to see where startup was retrieving its config:

LOG: DisplayName = Azure.Core, Version=1.31.0.0, Culture=neutral, PublicKeyToken=92742159e12e44c8
 (Fully-specified)
LOG: Appbase = file:///E:/approot/bin
LOG: Initial PrivatePath = E:\approot\bin
Calling assembly : Azure.Storage.Blobs, Version=12.16.0.0, Culture=neutral, PublicKeyToken=92742159e12e44c8.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: E:\base\x64\WaIISHost.exe.Config
LOG: Using host configuration file:
LOG: Using machine configuration file from D:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Post-policy reference: Azure.Core, Version=1.31.0.0, Culture=neutral, PublicKeyToken=92742159e12e44c8
LOG: Attempting download of new URL file:///E:/approot/bin/Azure.Core.DLL.
WRN: Comparing the assembly name resulted in the mismatch: Minor Version
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.

I remoted into the machine and added the binding redirect to the machine.config file and everything now works fine. However, I feel that this isn't quite the correct solution since I'm guessing this change will be lost on a re-image. Does anybody know what the correct solution would be? It looks like it can expect a host configuration file, but there is none according to the log. Where would it be looking for that, and can it be published with my project files?

I'm guessing it can be added in the csdef or cscfg config, but I'm not quite sure where it would go. Any help is appreciated.


Solution

  • I had no luck getting an answer here, but I was able to find an explanation of what is going on. web.config is used by IIS worker process, but it doesn’t affect the WaIISHost process under which the role is initializing.

    Unfortunately, the only solution is to do what I was already doing by modifying the machine.config or WaIISHost.exe.Config. Obviously, instead of doing it manually, we need to do it as a role startup task.

    https://dzimchuk.net/be-aware-of-web-role-host-process/