Service fabric failure when deployed to Azure, but working locally

445 Views Asked by At

A stateless service made in Core 3.1 requires a Nuget package that is being problematic. If my csproj looks like the default of:

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp3.1</TargetFramework>
    <IsServiceFabricServiceProject>True</IsServiceFabricServiceProject>
    <ServerGarbageCollection>True</ServerGarbageCollection>
    <RuntimeIdentifier>win7-x64</RuntimeIdentifier>
    <TargetLatestRuntimePatch>False</TargetLatestRuntimePatch>
    <Configurations>Debug;Release;Staging</Configurations>
  </PropertyGroup>

The application fails to run locally due to a System.BadImageFormatException: 'An attempt was made to load a program with an incorrect format. (0x8007000B)

Modifying the csproj to look like:

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp3.1</TargetFramework>
    <IsServiceFabricServiceProject>True</IsServiceFabricServiceProject>
    <ServerGarbageCollection>True</ServerGarbageCollection>
    <TargetLatestRuntimePatch>False</TargetLatestRuntimePatch>
    <Configurations>Debug;Release;Staging</Configurations>
    <Platforms>x64</Platforms>
  </PropertyGroup>

Allows it to work correctly when deployed to my local cluster on my machine for testing.

Once deployed to Azure however, it's failing. I can't determine the source or error message. None of my logging is being invoked, so I assume it's failing at a very early point. Service Fabric Explorer is giving a very unhelpful, generic error message of There was an error during CodePackage activation.Container failed to start for image, exit code: 2147516547.

Why is local vs Azure behaving differently and is it possible to make some change to get Azure to work like the local cluster so that this runs?

1

There are 1 best solutions below

0
stevie_c On

I had the same problem. When the Azure DevOps pipeline deployed to ServiceFabric in Azure I had the error "There was an error during CodePackage activation.The process/container terminated with exit code:2147516547". According to this page"

The exit code in this health message is the only clue that the process or container provides about why it terminated.

But it would work locally on my ServiceFabric cluster. The exit code led me to this StackOverflow page at which point I noticed that the "Platforms" node in my CSPROJ file was missing.