Skip to content

Conversation

guardrex
Copy link
Collaborator

@guardrex guardrex commented Aug 29, 2025

Fixes #35807
Fixes #31962

  • The outline is below. I figure going with the following general order: environments (named), control code, and then setting the environment. If you want to change the order a great deal, I recommend giving me a new outline in a comment.
  • The (crummy IMO 😆) samples were placed into the samples repo on Add Environments sample apps AspNetCore.Docs.Samples#283 at https://github.com/dotnet/AspNetCore.Docs.Samples/tree/main/fundamentals/environments. I'll 🔪 💀 them here at the end because I don't want the diff overwhelmed with file changes during review.
  • This one doesn't adopt the dreaded INCLUDES files, but it did copy the entire article at .NET 6, which led (again 😩) to the poor update practice of only updating the current release content. The Azure Apps guidance wasn't updated, so looking at that with the <6.0 content and trying to use the portal would lead to an awfully 😕😖😠 dev. Besides, I'm 💀 that bit anyway in favor of a link to Azure docs to harden that section against future portal changes.
  • Per reader request, this adds Docker guidance for setting the environment.
  • WRT ✨ Startup class magic ✨ ... We'll keep it for now. It's going to go away at some point in the future.
  • The Blazor article (this link opens the 10.0 version because we have several section changes for 10.0+) is specifically focused on Blazor scenarios.

The initial outline for the article on the PR ...

  • Introductory remarks
  • Environments
  • Logging
  • Environment variables that determine the runtime environment
  • Control code execution by environment
  • Control rendered content
  • Set the environment in a command shell when the app is run (dotnet run)
  • Set the environment with the launch settings file (launchSettings.json)
  • Set the environment with an environment variable
    • Azure App Service
    • Set environment variable for a process
    • Set environment variable globally
    • Set the environment for apps deployed to IIS
    • Docker
      • Use a Dockerfile
      • Use Docker Compose
      • Use the docker run command
      • Docker environment file
  • Set the environment in the app's startup code
  • Load configuration by environment
  • Environment-specific Startup class
  • Environment-specific Startup class methods
  • Additional resources

Internal previews

📄 File 🔗 Preview link
aspnetcore/fundamentals/environments.md aspnetcore/fundamentals/environments

@guardrex guardrex self-assigned this Aug 29, 2025
@guardrex guardrex marked this pull request as draft August 29, 2025 15:45
@guardrex guardrex requested a review from Copilot September 3, 2025 15:10
@guardrex guardrex marked this pull request as ready for review September 3, 2025 15:16
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR completely overhauls the ASP.NET Core environments documentation article to improve its organization, add new content for Docker scenarios, and modernize the guidance. The update addresses two GitHub issues (#35807 and #31962) by restructuring the content with a more logical flow and adding comprehensive Docker environment configuration guidance.

Key changes include:

  • Restructured the article with a clearer outline focusing on environments, control mechanisms, and setting approaches
  • Added comprehensive Docker guidance (Dockerfile, Docker Compose, docker run, environment files)
  • Consolidated versioned content while maintaining support for Startup class patterns
  • Updated Azure App Service guidance to reference external documentation

@guardrex guardrex requested a review from danroth27 September 3, 2025 15:31
@guardrex guardrex closed this Sep 3, 2025
@guardrex guardrex reopened this Sep 3, 2025
danroth27

This comment was marked as outdated.

@guardrex

This comment was marked as outdated.

guardrex and others added 2 commits September 16, 2025 08:26
Co-authored-by: Daniel Roth <daroth@microsoft.com>
@guardrex
Copy link
Collaborator Author

guardrex commented Sep 16, 2025

@danroth27 ... Updates made. Another look before asking Javier to look?

Actually ... there's one more thing for me to do ........

The Control rendered content in Razor Pages and MVC has to be addressed. I'll work on that and ping back shortly.

UPDATE: That last commit addresses the RP/MVC piece.

@guardrex guardrex requested a review from tdykstra September 16, 2025 23:15
@guardrex
Copy link
Collaborator Author

@tdykstra ... I think we're still planning on getting a technical review from Javier, but you can review anytime.

Copy link
Member

@danroth27 danroth27 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! :shipit:

@guardrex guardrex requested a review from javiercn September 16, 2025 23:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update the sample app for "Use multiple environments in ASP.NET Core" to be based on Blazor instead of Razor Pages Add an example of Docker File
2 participants