歡迎使用 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服務器