Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

libsodium-64.dll not found in production Azure Service Fabric cluster

Using libsodium-net for all of its security goodness in an Azure Service Fabric Reliable Service, on my local dev cluster everything is working fine (although I did have to set the libsodium-64.dll to copy to the output directory).

Unfortunately, when deployed to a real cluster in Azure it throws the following error:

Unable to load DLL 'libsodium-64.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)

I've checked by Remote Desktop-ing into one of the nodes and the DLL is copied across into the same directory as the service, exactly as it is in my dev cluster. Can't work out why it can't be found in production.

I've tried setting the PATH environment variable as suggested in this answer, and verified that it does actually get set - unfortunately that doesn't help.

Is there anything special I need to do to get ASF to pick up the DLL?

Edit: also tried adding the DLL to System32 on all the nodes, didn't solve it either.

like image 991
Tom Davies Avatar asked Feb 07 '23 13:02

Tom Davies


1 Answers

Turns out libsodium-64.dll depends on the Visual C++ Runtime, which didn't seem to be present on the Azure VMs. Ran Process Monitor as mentioned here and saw it was picking up "libsodium-64.dll" but failing on "vcruntime140.dll" - the exception message alone makes this pretty much impossible to work out.

Installed the Visual C++ Redistributable on the VMs and everything seems to be working fine now.

If anyone happens to run into the same problem, you can solve it by adding the following extension to the VM profile of the scale set in your ARM deployment template (VMSS -> properties -> virtualMachineProfile -> extensionProfile -> extensions):

{
    "name": "InstallVCRuntime",
    "properties": {
        "publisher": "Microsoft.Compute",
        "type": "CustomScriptExtension",
        "typeHandlerVersion": "1.7",
        "autoUpgradeMinorVersion": true,
        "settings": {
            "fileUris": [
                "https://some.blob.storage.url/vc_redist.x64.exe"
            ],
            "commandToExecute": "vc_redist.x64.exe /q /norestart"
        }
    }
}

All it does is grab the installer, and run it silently. There didn't seem to be a public link to the redistributable, so I just downloaded it and put it into blob storage.

like image 96
Tom Davies Avatar answered Feb 12 '23 10:02

Tom Davies