简体   繁体   中英

ASP.NET Core 3.0 app in Docker cannot start in Azure Web App for Container

I have an app targetting ASP.NET Core 3.0.

I have it built using Azure DevOps and also released from there directly to Azure Web App for Container. This YAML was used to generate the image:

# Docker
# Build a Docker image 
# https://docs.microsoft.com/azure/devops/pipelines/languages/docker

trigger:
- master

resources:
- repo: self

variables:
  tag: '$(Build.BuildId)'
  BuildConfiguration: Release

stages:
- stage: Build
  displayName: Build image
  jobs:  
  - job: Build
    displayName: Build
    pool:
      name: 'Azure Pool inside Network Linux'
      vmImage: 'ubuntu-latest'
    steps:
    - task: UseDotNet@2
      displayName: Install .Net Core 3.0
      inputs:
        packageType: 'sdk'
        version: '3.0.x'
        includePreviewVersions: false
    - task: DotNetCoreCLI@2
      displayName: Restore packages
      inputs:
        command: 'restore'
        projects: '**/*.csproj'
        feedsToUse: 'select'
        vstsFeed: '8187f5c9-e9c1-419f-8a5c-98285cf7633c'
    - task: DotNetCoreCLI@2
      displayName: Build
      inputs:
        command: 'build'
        arguments: '--configuration $(BuildConfiguration)'
        projects: '**/*.csproj'
    - task: DotNetCoreCLI@2
      displayName: Publish
      inputs:
        command: 'publish'
        publishWebProjects: false
        projects: '**/NetCoreBoilerplate.WebApi.csproj'
        arguments: '--configuration $(BuildConfiguration)'
        zipAfterPublish: false
        modifyOutputPath: false
    - task: Docker@2
      displayName: Build an image
      inputs:
        command: buildAndPush
        containerRegistry: 'ContainerRegistry'
        repository: 'NetBoilerPlate'
        buildContext: '$(Build.SourcesDirectory)/src/NetCoreBoilerplate.WebApi/bin/$(BuildConfiguration)/netcoreapp3.0/'
        dockerfile: '$(Build.SourcesDirectory)/tools/docker/Dockerfile'
        tags: |
          $(tag)

And this Dockerfile

FROM mcr.microsoft.com/dotnet/core/aspnet:3.0-buster-slim AS base
RUN useradd --create-home -s /bin/bash user
WORKDIR /home/user
USER user
ENV APP_HOME /home/user/app
RUN mkdir $APP_HOME
WORKDIR $APP_HOME
ENV ASPNETCORE_URLS http://+:5000
EXPOSE 5000
COPY publish .
ENTRYPOINT ["dotnet", "NetCoreBoilerplate.WebApi.dll"]

Locally the application works but when I deploy it to Azure I find this error in the logs.

2019-10-02T14:20:43.177686408Z It was not possible to find any compatible framework version
2019-10-02T14:20:43.178398914Z The specified framework 'Microsoft.AspNetCore.App', version '3.0.0' was not found.
2019-10-02T14:20:43.178667416Z   - The following frameworks were found:
2019-10-02T14:20:43.178867518Z        3.0.0-preview8.19405.7 at [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
2019-10-02T14:20:43.178936019Z
2019-10-02T14:20:43.179157321Z You can resolve the problem by installing the specified framework and/or SDK.
2019-10-02T14:20:43.179240321Z
2019-10-02T14:20:43.179425023Z The .NET Core frameworks can be found at:
2019-10-02T14:20:43.179548024Z        - https://aka.ms/dotnet-download

Any idea what could be wrong?

Yes, I've finally resolved it with changing of the origin image in dockerfile

FROM mcr.microsoft.com/dotnet/core/aspnet:3.0 AS base

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM