exam questions

Exam AZ-400 All Questions

View all questions & answers for the AZ-400 exam

Exam AZ-400 topic 7 question 25 discussion

Actual exam question from Microsoft's AZ-400
Question #: 25
Topic #: 7
[All AZ-400 Questions]

DRAG DROP -
You are creating a container for an ASP.NET Core app.
You need to create a Dockerfile file to build the image. The solution must ensure that the size of the image is minimized.
How should you configure the file? To answer, drag the appropriate values to the correct targets. Each value may be used once, more than once, or not at all. You may need to drag the split bar between panes or scroll to view content.
NOTE: Each correct selection is worth one point.
Select and Place:

Show Suggested Answer Hide Answer
Suggested Answer:
Box 1: mcr.microsoft.com/dotnet/sdk:5.0
The first group of lines declares from which base image we will use to build our container on top of. If the local system does not have this image already, then docker will automatically try and fetch it. The mcr.microsoft.com/dotnet/core/sdk:5.0 comes packaged with the .NET core 5.0 SDK installed, so it's up to the task of building ASP .NET core projects targeting version 5.0

Box 2: dotnet restore -
The next instruction changes the working directory in our container to be /app, so all commands following this one execute under this context.
COPY *.csproj ./

RUN dotnet restore -
Box 3: mcr.microsoft.com/dotnet/aspnet:5.0
When building container images, it's good practice to include only the production payload and its dependencies in the container image. We don't want the .NET core SDK included in our final image because we only need the .NET core runtime, so the dockerfile is written to use a temporary container that is packaged with the SDK called build-env to build the app.
Reference:
https://docs.microsoft.com/en-us/virtualization/windowscontainers/quick-start/building-sample-app

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
firewind
Highly Voted 3 years ago
Second field should be dotnet publish -c Release -o out
upvoted 43 times
Angrl
3 years ago
Agree with firewind FROM mcr.microsoft.com/dotnet/core/sdk:2.1 AS build-env WORKDIR /app COPY *.csproj ./ RUN dotnet restore COPY . ./ RUN dotnet publish -c Release -o out FROM mcr.microsoft.com/dotnet/core/aspnet:2.1 WORKDIR /app COPY --from=build-env /app/out . ENTRYPOINT ["dotnet", "asp-net-getting-started.dll"]
upvoted 4 times
kennynelcon
2 years, 10 months ago
You are right, maybe an error from Examtopics, cos link here is ok https://docs.microsoft.com/en-us/virtualization/windowscontainers/quick-start/building-sample-app
upvoted 2 times
...
...
...
tjeerd
Highly Voted 2 years, 9 months ago
On exam 20220727. Answer is: SDK dotnet publish ASPnet
upvoted 7 times
...
MrAZ105
Most Recent 6 months, 4 weeks ago
To minimize the size of the Docker image for your ASP.NET Core app, you can use a multi-stage Dockerfile. This approach ensures that you only include the necessary runtime components in the final image, excluding build dependencies and unnecessary files. Here's an example of a Dockerfile for an ASP.NET Core app that leverages multi-stage builds to reduce the final image size # Stage 1: Build the app FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build-env WORKDIR /app # Copy csproj and restore dependencies COPY *.csproj ./ RUN dotnet restore # Copy the rest of the app files and build the app COPY . ./ RUN dotnet publish -c Release -o out # Stage 2: Create the runtime image FROM mcr.microsoft.com/dotnet/aspnet:7.0-alpine WORKDIR /app COPY --from=build-env /app/out . # Expose the port the app runs on EXPOSE 80 # Run the app ENTRYPOINT ["dotnet", "YourApp.dll"]
upvoted 1 times
...
varinder82
1 year, 5 months ago
Final answer after going through all the comments 1. /sdk 2. dotnet publish -c Release -o out 3. /aspnet
upvoted 5 times
...
CirusD
1 year, 7 months ago
FROM mcr.microsoft.com/dotnet/aspnet:sdk AS build-env WORKDIR /app # Copy csproj and restore as distinct layers COPY *.csproj ./ RUN dotnet restore # Copy everything else and build COPY . ./ RUN dotnet publish -c Release -o out # Build runtime image FROM mcr.microsoft.com/dotnet/aspnet:runtime WORKDIR /app COPY --from=build-env /app/out . ENTRYPOINT ["dotnet", "YourApp.dll"]
upvoted 2 times
...
pamswam
2 years, 7 months ago
for second: dotnet publish -c Release -o out (publish do implicit restore) https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-publish#description
upvoted 4 times
...
syu31svc
2 years, 9 months ago
Run dotnet publish -c Release -o out https://docs.microsoft.com/en-us/virtualization/windowscontainers/quick-start/building-sample-app Other options are correct
upvoted 2 times
...
htahara
2 years, 10 months ago
FROM mcr.microsoft.com/dotnet/core/sdk:5.0 AS build-env RUN dotnet publish -c Release -o out FROM mcr.microsoft.com/dotnet/aspnet:5.0
upvoted 1 times
...
UnknowMan
3 years ago
Sdk to build Publish on Out folder aspnet to run
upvoted 2 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...
exam
Someone Bought Contributor Access for:
SY0-701
London, 1 minute ago