title: How to set environment variables (ASPNETCORE_ENVIRONMENT) in AzureDevops for Dockerfile?
body: <p>I was planning to use Azure Devops to do the CI/CD for my dockerized .NET Core API.
  My API now have <code>appsettings.json</code> and <code>appsettings.Development.json</code>.</p>
  <p>Below are my Dockerfile:</p>
  <pre><code>FROM mcr.microsoft.com/dotnet/core/aspnet:3.1 AS base
  WORKDIR /app
  EXPOSE 80
  
  ENV ASPNETCORE_ENVIRONMENT Development
  
  FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build
  WORKDIR /src
  COPY [&quot;Api/Api.csproj&quot;, &quot;Api/&quot;]
  RUN dotnet restore &quot;Api/Api.csproj&quot;
  COPY . .
  WORKDIR &quot;/src/Api&quot;
  RUN dotnet build &quot;Api.csproj&quot; -c Release -o /app/build
  
  FROM build AS publish
  RUN dotnet publish &quot;Api.csproj&quot; -c Release -o /app/publish
  
  FROM base AS final
  WORKDIR /app
  COPY --from=publish /app/publish .
  ENTRYPOINT [&quot;dotnet&quot;, &quot;Api.dll&quot;, &quot;--environment=Development&quot;]
  </code></pre>
  <p>As can seen, I set the environment at <code>ASPNETCORE_ENVIRONMENT</code> and also the <code>ENTRYPOINT [&quot;dotnet&quot;, &quot;Api.dll&quot;, &quot;--environment=Development&quot;]</code>. However how can I make it flexible in Azure Devops pipeline?</p>
  <p>For example having different environments like <code>development</code> and <code>production</code>. So let say I have another <code>appsettings.Production.json</code>, the project would automatically pick up this file instead of <code>appsettings.Development.json</code> if I set the environment to <code>Production</code>.</p>
  <p>Is there anyway to do this or am I understanding this whole flow wrong?
  Thank you.</p>