0

I have .net core Console Application, which prints a basic hello world message. I have published my application to azure container registry.

my Docker File:

FROM mcr.microsoft.com/dotnet/core/runtime:3.1-buster-slim AS base
WORKDIR /app

FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build
WORKDIR /src
COPY ["ConsoleApp1.csproj", ""]
RUN dotnet restore "./ConsoleApp1.csproj"
COPY . .
WORKDIR "/src/."
RUN dotnet build "ConsoleApp1.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "ConsoleApp1.csproj" -c Release -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "ConsoleApp1.dll"]

I have created a node, please go through this image for better understanding: node-configuration1 ,node-configuration,node-config,task-config

I am using a Linux container for integrating with azure batch, but whenever I run My task its saying to install

It was not possible to find any installed .NET Core SDKs
  Did you mean to run .NET Core SDK commands? Install a .NET Core SDK from:
      https://aka.ms/dotnet-download**

Task_issue

How do I install dotnet core in a linux container?

Please guide me on this, through sharing some examples.

Compo
  • 36,585
  • 5
  • 27
  • 39

2 Answers2

0

By default, the working directory for Azure Batch tasks is set to a path that is preset according to the job and task and in a well-known location on the VM. This directory can be referenced by the environment variable AZ_BATCH_TASK_WORKING_DIR.

If you want to explicitly set the working directory of the container as specified by the container image/Dockerfile upon execution of the container, then you should set the WorkingDirectory of the TaskContainerSettings object to ContainerImageDefault.

fpark
  • 2,304
  • 2
  • 14
  • 21
0

As fpark mentioned, here is the code snippet for setting the container working directory to ContainerImageDefault:

CloudTask task = new CloudTask(taskId, taskCommandLine);
Microsoft.Azure.Batch.TaskContainerSettings tcs = new Microsoft.Azure.Batch.TaskContainerSettings
                ("myhub.azurecr.io/image:tag"
                , workingDirectory: Microsoft.Azure.Batch.Common.ContainerWorkingDirectory.ContainerImageDefault
                );
 task.ContainerSettings = tcs;
 tasks.Add(task);
xyx
  • 93
  • 2
  • 9