Reputation: 699
I'm trying to publish a small .NET Core 3.1 Web App on Azure App Service (Linux), and the app won't start.
No matter if I'm publishing using Visual Studio, or Azure DevOps, i'm getting the following error on my Linux Azure App Service (which, by the way, already contains two other apps):
2021-06-23T22:19:47.102376527Z _____
2021-06-23T22:19:47.102415627Z / _ \ __________ _________ ____
2021-06-23T22:19:47.102422327Z / /_\ \___ / | \_ __ \_/ __ \
2021-06-23T22:19:47.102426627Z / | \/ /| | /| | \/\ ___/
2021-06-23T22:19:47.102430627Z \____|__ /_____ \____/ |__| \___ >
2021-06-23T22:19:47.102434927Z \/ \/ \/
2021-06-23T22:19:47.102438927Z A P P S E R V I C E O N L I N U X
2021-06-23T22:19:47.102442827Z
2021-06-23T22:19:47.102446327Z Documentation: http://aka.ms/webapp-linux
2021-06-23T22:19:47.102449927Z Dotnet quickstart: https://aka.ms/dotnet-qs
2021-06-23T22:19:47.102453427Z ASP .NETCore Version: 3.1.13
2021-06-23T22:19:47.102457227Z Note: Any data outside '/home' is not persisted
2021-06-23T22:19:47.307988432Z Running oryx create-script -appPath /home/site/wwwroot -output /opt/startup/startup.sh -defaultAppFilePath /defaulthome/hostingstart/hostingstart.dll -bindPort 8080 -userStartupCommand 'dotnet WebApplication1.dll'
2021-06-23T22:19:47.378242802Z Cound not find build manifest file at '/home/site/wwwroot/oryx-manifest.toml'
2021-06-23T22:19:47.382799606Z Could not find operation ID in manifest. Generating an operation id...
2021-06-23T22:19:47.382816206Z Build Operation ID: 7f48597c-0791-46e5-bffd-b0007d8b27b7
2021-06-23T22:19:49.335414280Z Writing output script to '/opt/startup/startup.sh'
2021-06-23T22:19:49.567879341Z Running user provided startup command...
2021-06-23T22:19:49.610748271Z A compatible installed .NET Core SDK for global.json version [3.1.409] from [/home/site/wwwroot/global.json] was not found
2021-06-23T22:19:49.610783071Z Install the [3.1.409] .NET Core SDK or update [/home/site/wwwroot/global.json] with an installed .NET Core SDK:
2021-06-23T22:19:49.610825071Z It was not possible to find any installed .NET Core SDKs
2021-06-23T22:19:49.610829471Z Did you mean to run .NET Core SDK commands? Install a .NET Core SDK from:
2021-06-23T22:19:49.610835971Z https://aka.ms/dotnet-download
2021-06-23T22:19:50.944Z ERROR - Container procoding-me_0_8935305e for site procoding-me has exited, failing site start
2021-06-23T22:19:50.961Z ERROR - Container procoding-me_0_8935305e didn't respond to HTTP pings on port: 8080, failing site start. See container logs for debugging.
2021-06-23T22:19:50.978Z INFO - Stopping site procoding-me because it failed during startup.```
I've tried to create the web app on azure again, and even tried to publish the same code of the other apps, and the same problem occurs.
Anybody has a hint of the cause of this problem?
Upvotes: 2
Views: 4514
Reputation: 820
So, after a long day of trying to figure this thing out I managed to publish and app to an app service running linux. I'm using an App Service Plan (Linux, B1) that lives in a "shared" resource group since I want to run multiple apps on it. I'm also deploying the infrastructure using Bicep and the pipeline is yaml.
The issue was, as it seems, that when I was deploying the app through Azure DevOps, it was nesting the app archive in another zip-file. The app zip-file needs to be the root-folder in the app, not obvious unless you download the files that are being executed in the app service itself.
Yeah, also I'm using the self-contained version of deployment here. You can read more about it here. I had no success doing it with the framework-dependent way unless I published the app from Visual Studio 2022.
So, in the end, here are the snippets that made the thing work for me:
azure-pipelines.yaml - Build stage
- task: DotNetCoreCLI@2
inputs:
command: 'publish'
projects: '**/*Api.csproj'
arguments: '--configuration $(buildConfiguration) -r linux-x64 --self-contained true --output $(Build.ArtifactStagingDirectory)'
modifyOutputPath: false
publishWebProjects: false
zipAfterPublish: true
displayName: 'Dotnet Publish'
- task: PublishBuildArtifacts@1
inputs:
targetPath: '$(Build.ArtifactStagingDirectory)'
ArtifactName: drop
azure-pipelines.yaml - Deploy stage
- task: AzureRmWebAppDeployment@4
inputs:
azureSubscription: '$(azureSubscription)'
appType: webAppLinux
WebAppName: '$(output_appServiceName)'
packageForLinux: '$(Pipeline.Workspace)/**/a.zip' #Since we are not specifying the folder name in the steps prior, the folder will be called just a.zip, this is fine since the deployment is going to rename it any way in the app service file system anyway(in Kudu)
The app service resource in Bicep
resource appService 'Microsoft.Web/sites@2021-01-01' = {
name: '${serviceName}-${environment}-app'
location: resourceGroup().location
kind: 'app'
properties: {
serverFarmId: planId
siteConfig: {
alwaysOn: true
http20Enabled: true
linuxFxVersion: 'DOTNETCORE|5.0'
appSettings: [
{
name: 'WEBSITE_RUN_FROM_PACKAGE'
value: '1'
}
]
}
}
}
Hope this helps.
P.S. Having "corrupted" zip-files in the app service (Kudu) can cause the app to fail. I suggest anyone having this issue to either delete all files from wwwroot or simply delete the app service resource and deploy it from scratch to make sure it can start properly.
Upvotes: 4