0
votes

I'm publishing a .net core 3.1 app that is saved in an Azure DevOps repo, built in a build pipeline and published to an Azure Linux Web App Service container. The whole process seems to go well and the according to the deployment blade in the App Service the deployment was successful.

Expected Result

I expect to see my deployed website when I go to the public URL.

Actual Result

Instead I see the new host page that says "Hey, .NET Core developers! Your app service is up and running. Time to take the next step and deploy your code".

Additional Info

It appears that the app service is launching the default app because it's having a problem starting my published app.

The startup command I've specified in the app service general configuration is:

dotnet "SmartSAR.dll"

Log for App Service startup

2020-04-18 07:39:27.802 INFO  - Container smartsar_0_36ea601f for site smartsar initialized successfully and is ready to serve requests.
2020-04-18T07:39:25.664749049Z   _____
2020-04-18T07:39:25.664775249Z   /  _  \ __________ _________   ____
2020-04-18T07:39:25.664780549Z  /  /_\  \___   /  |  \_  __ \_/ __ \
2020-04-18T07:39:25.664799849Z /    |    \/    /|  |  /|  | \/\  ___/
2020-04-18T07:39:25.664803949Z \____|__  /_____ \____/ |__|    \___  >
2020-04-18T07:39:25.664808049Z         \/      \/                  \/
2020-04-18T07:39:25.664811949Z A P P   S E R V I C E   O N   L I N U X
2020-04-18T07:39:25.664815749Z
2020-04-18T07:39:25.664819349Z Documentation: http://aka.ms/webapp-linux
2020-04-18T07:39:25.664823149Z Dotnet quickstart: https://aka.ms/dotnet-qs
2020-04-18T07:39:25.664826849Z ASP .NETCore Version: 3.1.0
2020-04-18T07:39:25.664830549Z Note: Any data outside '/home' is not persisted
2020-04-18T07:39:25.727133075Z Running oryx -appPath /home/site/wwwroot -output /opt/startup/startup.sh -defaultAppFilePath /defaulthome/hostingstart/hostingstart.dll     -bindPort 8080 -userStartupCommand 'dotnet "SmartSAR.dll"'
2020-04-18T07:39:25.730817476Z Oryx Version: 0.2.20200114.13, Commit: 204922f30f8e8d41f5241b8c218425ef89106d1d, ReleaseTagName: 20200114.13
2020-04-18T07:39:25.737275979Z Cound not find build manifest file at '/home/site/wwwroot/oryx-manifest.toml'
2020-04-18T07:39:25.737697979Z Could not find operation ID in manifest. Generating an operation id...
2020-04-18T07:39:25.738149780Z Build Operation ID: 6b038e35-4bdc-4c95-ba56-af4ed38e0ce0
2020-04-18T07:39:26.610476848Z Writing output script to '/opt/startup/startup.sh'
2020-04-18T07:39:27.105207557Z Running user provided startup command...
2020-04-18T07:39:27.112012760Z   It was not possible to find any installed .NET Core SDKs
2020-04-18T07:39:27.112467060Z   Did you mean to run .NET Core SDK commands? Install a .NET Core SDK from:
2020-04-18T07:39:27.112892061Z       https://aka.ms/dotnet-download
2020-04-18T07:39:27.113473661Z WARNING: Startup command execution failed with exit code 145
2020-04-18T07:39:27.113786261Z Running the default application instead...
2020-04-18T07:39:27.447628502Z Hosting environment: Production
2020-04-18T07:39:27.448410002Z Content root path: /defaulthome/hostingstart/
2020-04-18T07:39:27.449102503Z Now listening on: http://[::]:8080

Build Pipeline YAML

# ASP.NET Core (.NET Framework)
# Build and test ASP.NET Core projects targeting the full .NET Framework.
# Add steps that publish symbols, save build artifacts, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/dotnet-core

trigger:
- master

pool:
  vmImage: 'windows-latest'

variables:
  solution: '**/*.sln'
  buildPlatform: 'Any CPU'
  buildConfiguration: 'Release'

steps:
- task: NuGetToolInstaller@1

- task: UseDotNet@2 
  displayName: ".NET Core 3.1.x"
  inputs:
    version: '3.1.x'
    packageType: sdk
- script: dotnet build --configuration $(buildConfiguration)
  displayName: 'dotnet build $(buildConfiguration)'

- task: NuGetCommand@2
  inputs:
    restoreSolution: '$(solution)'

- task: VSBuild@1
  inputs:
    solution: '$(solution)'
    msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:DesktopBuildPackageLocation="$(build.artifactStagingDirectory)\WebApp.zip" /p:DeployIisAppPath="Default Web Site"'
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'

- task: VSTest@2
  inputs:
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'

- task: PublishBuildArtifacts@1

The artifact generated is a drop containing a WebApp.zip deployment file (plus associated files).

From what I can tell, the dll being generated that I need to start is SmartSAR.dll. From the build log:

Building target "_CopyOutOfDateSourceItemsToOutputDirectory" partially, because some output files are out of date with respect to their input files.
  Copying file from "d:\a\1\s\SmartSAR\obj\Release\netcoreapp3.1\SmartSAR.exe" to "d:\a\1\s\SmartSAR\bin\Release\netcoreapp3.1\SmartSAR.exe".
CopyFilesToOutputDirectory:
  Copying file from "d:\a\1\s\SmartSAR\obj\Release\netcoreapp3.1\SmartSAR.dll" to "d:\a\1\s\SmartSAR\bin\Release\netcoreapp3.1\SmartSAR.dll".
  SmartSAR -> d:\a\1\s\SmartSAR\bin\Release\netcoreapp3.1\SmartSAR.dll
  Copying file from "d:\a\1\s\SmartSAR\obj\Release\netcoreapp3.1\SmartSAR.pdb" to "d:\a\1\s\SmartSAR\bin\Release\netcoreapp3.1\SmartSAR.pdb".
2
I just notice that the auto-generated yaml is for a Windows app image. Oops. Working on switching the build pipeline to target ubuntu-latest instead.platypusjh

2 Answers

0
votes

Did you set the Azure web app's general settings stack property to .NET Core?

enter image description here

0
votes

The issue was I used the default YAML generated for the build pipeline and I didn't notice it was targeting a Windows build image! (I blame lack of sleep.)

Here's the YAML I used for the final working pipeline:

trigger:
- main

pool:
  vmImage: 'ubuntu-latest'

variables:
  buildConfiguration: 'Release'

steps:

    - task: UseDotNet@2 
      displayName: ".NET Core 3.1.x"
      inputs:
        version: '3.1.x'
        packageType: sdk
    - script: dotnet build --configuration $(buildConfiguration)
      displayName: 'dotnet build $(buildConfiguration)'

    - task: DotNetCoreCLI@2
      displayName: "Test"
      inputs:
        command: test
        projects: '**/*tests/*.csproj'
        arguments: '--configuration $(buildConfiguration)'

    - task: DotNetCoreCLI@2
      displayName: "Publish"
      inputs:
        command: 'publish'
        publishWebProjects: true
        arguments: '-r linux-x64 --configuration $(BuildConfiguration) --output $(Build.ArtifactStagingDirectory)'
        zipAfterPublish: true

    - task: PublishBuildArtifacts@1
      displayName: "Upload Artifacts"
      inputs:
        pathtoPublish: '$(Build.ArtifactStagingDirectory)' 
        artifactName: 'WebApp'