0

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?

gilliduck
  • 2,762
  • 2
  • 16
  • 32
  • Are the deployed and local Service Fabric versions the same? Are you deploying in the same configuration? – joelforsyth Sep 14 '21 at 13:43
  • Actually no, Azure is 8.1.321.9590 and Local is 8.1.329.9590 – gilliduck Sep 14 '21 at 13:48
  • I'm not seeing how I would upgrade or downgrade either to match though. – gilliduck Sep 14 '21 at 13:50
  • That's a pretty minor version change, that shouldn't affect it but it might be worth a try to upgrade just to be sure. Depending on how the fabric is deployed you can manually upgrade or you can redeploy the ARM. – joelforsyth Sep 14 '21 at 13:50
  • In the portal, locate the cluster, left side > Fabric upgrades – joelforsyth Sep 14 '21 at 13:53
  • Are you running the service inside a container? If so, did you follow the [walkthrough](https://learn.microsoft.com/en-us/azure/service-fabric/service-fabric-services-inside-containers) to enable use of containerized services? – LoekD Sep 15 '21 at 05:24
  • Can you try using a larger VM SKU inside Azure to see if your node isn't running out of memory? – LoekD Sep 15 '21 at 05:26
  • You can check the logs using [this](https://stackoverflow.com/a/37887407/5946937) answer – LoekD Sep 15 '21 at 05:28

1 Answers1

0

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.

bonCodigo
  • 14,268
  • 1
  • 48
  • 91
stevie_c
  • 990
  • 1
  • 8
  • 15