将 net 8 docker 映像部署到 azure web app(Linux) 容器后遇到问题

问题描述 投票:0回答:1

我使用 .Net 8 构建了一个 API,并使用下面的 Dockerfile 创建了容器映像

#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging.

FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
USER app
WORKDIR /app
EXPOSE 8080

FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["Presentation/POMaster.API/POMaster.API.csproj", "Presentation/POMaster.API/"]
COPY ["Libraries/POMaster.Framework/POMaster.Framework.csproj", "Libraries/POMaster.Framework/"]
COPY ["Libraries/POMaster.Services/POMaster.Services.csproj", "Libraries/POMaster.Services/"]
COPY ["Libraries/POMaster.Data/POMaster.Data.csproj", "Libraries/POMaster.Data/"]
COPY ["Libraries/POMaster.Domain/POMaster.Domain.csproj", "Libraries/POMaster.Domain/"]
COPY ["Libraries/POMaster.Utils/POMaster.Utils.csproj", "Libraries/POMaster.Utils/"]
RUN dotnet restore "./Presentation/POMaster.API/POMaster.API.csproj"
COPY . .
WORKDIR "/src/Presentation/POMaster.API"
RUN dotnet build "./POMaster.API.csproj" -c $BUILD_CONFIGURATION -o /app/build

FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "./POMaster.API.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "POMaster.API.dll"]

我已将此图像推送到 ACR 上。我正在使用 Azure Web 应用程序(Linux)容器从图像中运行容器。一切正常(即基于日志),但我无法通过公共 URL 访问网站,它显示 404

以下是来自日志流的日志

我在这里错过了什么或做错了什么?有人可以帮忙解决吗?我们将非常感谢您的帮助。

我还在azure web app应用程序设置下添加了值为8080的WEBSITES_PORT设置,但没有工作。

azure docker dockerfile azure-web-app-service containers
1个回答
0
投票

发布我的评论作为答案,以造福社区。

我创建了一个简单的 ASP。 NET Core 8 Web APP,使用 Docker 将其容器化,将其推送到 Azure 容器注册表,并将其部署到 Azure Web App (Linux)。成功了。

我也遇到同样的问题,所以我放了这个

dotnet <YourLocalWebAppName>.dll

Azure App Service 中的启动命令,如下所示。

enter image description here

Linux 的启动命令是必需的,它告诉平台如何启动应用程序。

Azure 应用服务输出

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.