欢迎使用 Blazor!Blazor 是一个使用 .NET 生成交互式客户端 Web UI 的框架:javascript
使用VS2019模板建立Blazor项目,添加Dockerfile打包为Linux镜像,最后发布到Azure应用服务, 并查看镜像的发布日志和启动日志。要完成此次任务,须要提早准备如下条件:html
1)安装VS2019,Docker Desktop,App Service For Container, Azure Container Registry(ACR)java
2)VS 2019 链接到中国区Azure帐号,可参考文章: 链接到微软云Azure中国区 By VS 2019, VS Code, Powershellweb
添加Dockerfile的文件内容为:docker
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging. FROM mcr.microsoft.com/dotnet/aspnet:5.0-buster-slim AS base WORKDIR /app EXPOSE 80 EXPOSE 443 FROM mcr.microsoft.com/dotnet/sdk:5.0-buster-slim AS build WORKDIR /src COPY ["MyLife.Blazor/Server/MyLife.Blazor.Server.csproj", "MyLife.Blazor/Server/"] COPY ["MyLife.Blazor/Shared/MyLife.Blazor.Shared.csproj", "MyLife.Blazor/Shared/"] COPY ["MyLife.Blazor/Client/MyLife.Blazor.Client.csproj", "MyLife.Blazor/Client/"] RUN dotnet restore "MyLife.Blazor/Server/MyLife.Blazor.Server.csproj" COPY . . WORKDIR "/src/MyLife.Blazor/Server" RUN dotnet build "MyLife.Blazor.Server.csproj" -c Release -o /app/build FROM build AS publish RUN dotnet publish "MyLife.Blazor.Server.csproj" -c Release -o /app/publish FROM base AS final WORKDIR /app COPY --from=publish /app/publish . ENTRYPOINT ["dotnet", "MyLife.Blazor.Server.dll"]
SECURITY WARNING: You are building a Docker image from Windows against a non-Windows Docker host. All files and directories added to build context will have '-rwxr-xr-x' permissions. It is recommended to double check and reset permissions for sensitive files and directories.shell
注意:若是应用修改后从新生成了Image,应用服务经过重启(restart)及能够拉取最新的镜像并部署。windows
Run a custom container in Azure: https://docs.microsoft.com/en-us/azure/app-service/quickstart-custom-container?pivots=container-windows#update-locally-and-redeploy服务器