question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ASP.NET Core 1.1 fails to deploy to azure web app via CI web.config is not created with the correct values

See original GitHub issue

I updated my existing web app from 1.0.1 to 1.1. I have set up a continuous deliver process from the azure portal before I updated the app and all went without problems. After updating the app to 1.1 the continuous delivery still works but the app stopps with a “HTTP Error 502.5 - Process Failure”. I created a new app from scratch updated to 1.1 and tried to upload it to azure and I get the same result. I investigated the error and from what I see the problem is that the web.config file is not automatically updated. The web.config on azure looks like: <aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" forwardWindowsAuthToken="false" stdoutLogEnabled="false" /> so none of the placeholders is filled out.

The project.json looks like this

{
  "userSecretsId": "8272f1fc-3e6e-44fc-b1af-54bfabe2a6ba",

  "dependencies": {
    "AutoMapper": "5.1.1",
    "BundlerMinifier.Core": "2.2.306",
    "MailKit": "1.10.0",
    "Microsoft.ApplicationInsights.AspNetCore": "1.0.2",
    "Microsoft.AspNetCore.Authentication.Cookies": "1.1.0",
    "Microsoft.AspNetCore.Diagnostics": "1.1.0",
    "Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore": "1.1.0",
    "Microsoft.AspNetCore.Identity.EntityFrameworkCore": "1.1.0",
    "Microsoft.AspNetCore.Mvc": "1.1.0",
    "Microsoft.AspNetCore.Razor.Tools": {
      "version": "1.1.0-preview4-final",
      "type": "build"
    },
    "Microsoft.AspNetCore.Routing": "1.1.0",
    "Microsoft.AspNetCore.Server.IISIntegration": "1.1.0",
    "Microsoft.AspNetCore.AzureAppServicesIntegration": "1.0.0",
    "Microsoft.AspNetCore.Server.Kestrel": "1.1.0",
    "Microsoft.AspNetCore.StaticFiles": "1.1.0",
    "Microsoft.EntityFrameworkCore.SqlServer": "1.1.0",
    "Microsoft.EntityFrameworkCore.SqlServer.Design": "1.1.0",
    "Microsoft.EntityFrameworkCore.Tools": {
      "version": "1.1.0-preview4-final",
      "type": "build"
    },
    "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.1.0",
    "Microsoft.Extensions.Configuration.Json": "1.1.0",
    "Microsoft.Extensions.Configuration.UserSecrets": "1.1.0",
    "Microsoft.Extensions.Logging": "1.1.0",
    "Microsoft.Extensions.Logging.Console": "1.1.0",
    "Microsoft.Extensions.Logging.Debug": "1.1.0",
    "Microsoft.Extensions.Options.ConfigurationExtensions": "1.1.0",
    "Microsoft.NETCore.App": {
      "version": "1.1.0",
      "type": "platform"
    },
    "Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.1.0",
    "Microsoft.VisualStudio.Web.CodeGeneration.Tools": {
      "version": "1.1.0-preview4-final",
      "type": "build"
    },
    "Microsoft.VisualStudio.Web.CodeGenerators.Mvc": {
      "version": "1.1.0-preview4-final",
      "type": "build"
    },
    "Newtonsoft.Json": "9.0.1",
    "StructureMap.Microsoft.DependencyInjection": "1.2.0",
    "WindowsAzure.Storage": "7.2.1"
  },

  "tools": {
    "BundlerMinifier.Core": "2.2.306",
    "Microsoft.AspNetCore.Razor.Tools": "1.1.0-preview4-final",
    "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.1.0-preview4-final",
    "Microsoft.EntityFrameworkCore.Tools": "1.1.0-preview4-final",
    "Microsoft.Extensions.SecretManager.Tools": "1.1.0-preview4-final",
    "Microsoft.VisualStudio.Web.CodeGeneration.Tools": {
      "version": "1.1.0-preview4-final",
      "imports": [
        "portable-net45+win8"
      ]
    }
  },

  "frameworks": {
    "netcoreapp1.1": {
      "imports": [
        "dotnet5.6",
        "portable-net45+win8"
      ]
    }
  },


  "buildOptions": {
    "emitEntryPoint": true,
    "preserveCompilationContext": true
  },

  "runtimeOptions": {
    "configProperties": {
      "System.GC.Server": true
    }
  },

  "publishOptions": {
    "include": [
      "wwwroot",
      "**/*.cshtml",
      "appsettings.json",
      "web.config"
    ]
  },

  "scripts": {
    "prepublish": [ "bower install", "dotnet bundle" ],
    "postpublish": [
      "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%"
    ]
  }
}

The continoous delivery is set up like this: Azure portal -> App Services -> Continuous Delivery -> Choose a repo from VSTS and thats it. As said before with 1.0.1 it worked pretty good but now it stopped. If I change the web.config by hand and enter values like this

<aspNetCore processPath="dotnet"
        arguments=".\MyApp.dll"
        stdoutLogEnabled="true"
        stdoutLogFile="\\?\%home%\LogFiles\aspnetcore-stdout">
</aspNetCore>

I can make the app running.

Thanks for your help in advance!

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:15 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
guardrexcommented, Feb 21, 2017

System.BadImageFormatException

Occurs when there is a bitness mismatch: https://docs.microsoft.com/en-us/aspnet/core/publishing/iis#platform-conflicts-with-rid

One thing that can go sideways with Azure App deployments is incompatible assemblies hanging around. Some devs have had to go in and manually delete every file+folder in an Azure App deployment … then redeploy to clear a problem. You might want to try that on your 1st app service to see if you can clear it.

0reactions
sturatcliffecommented, Feb 21, 2017

@GuardRex I’ve set stdoutLogEnabled to true, and for some very strange reason my app started deploying successfully from github (we use VSTS at work, but I’ve been testing in a new azure app service pointing at github so as not to keep breaking our manual app deployments)

I then pointed the second app service at VSTS and did a git push and all was working well. Thought that somehow the problem was resolved, just by enabling the stdout log (would have been very weird!) However, when turning back on the VSTS git deployments on the original azure app service, I still receive 502’s, and can’t for the life of me work out what’s different in the setup of these app services, they look identical!

Anyway, stdout log is reporting this error shortly after failing to startup:

System.AggregateException: One or more errors occurred. —> System.BadImageFormatException: An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)

So ultimately, I now have 2 azure app services both configured to automatically deploy from the same VSTS git repo, and only one works!

Read more comments on GitHub >

github_iconTop Results From Across the Web

ASP.NET Core 1.1 runs fine locally but when publishing to ...
Just not deployed at Azure, I'm using my local machine as server and host it in IIS. An error occurred while starting the...
Read more >
Troubleshoot ASP.NET Core on Azure App Service and IIS
Learn how to diagnose problems with Azure App Service and Internet Information Services (IIS) deployments of ASP.NET Core apps.
Read more >
Common error troubleshooting for Azure App Service and ...
ASP.NET Core Module Debug Log: The log file isn't created. Troubleshooting: Check the IIS website Basic Settings and the physical app folder.
Read more >
Advanced configuration of the ASP.NET Core Module and IIS
Right -click the app and select Manage Website > Advanced Settings. The default Preload Enabled setting is False . Set Preload Enabled to...
Read more >
Deploy content using FTP/S - Azure App Service
This article shows you how to use FTP or FTPS to deploy your web app, mobile app backend, or API app to Azure...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found