Docker中的ASP.NET Core 3.0应用程序无法在容器的Azure Web应用程序中启动

时间:2019-10-02 15:25:34

标签: azure docker azure-devops azure-web-app-for-containers

我有一个针对ASP.NET Core 3.0的应用程序。

我使用Azure DevOps构建它,并从那里直接发布到用于容器的Azure Web App。 此YAML用于生成图像:

# 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)

这个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"]

该应用程序在本地可以运行,但是当我将其部署到Azure时,我在日志中发现了此错误。

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

有什么主意吗?

1 个答案:

答案 0 :(得分:0)

是的,我终于通过更改dockerfile中的原始图像解决了它

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