Skip to content

[API Proposal]: YAML configuration provider #109199

Closed as not planned
Closed as not planned

Description

@stasberkov

Background and motivation

Currently, ASP.NET Core supports configuration providers for JSON, XML, and INI files. However, YAML is a popular configuration format due to its readability and support for complex data structures. Adding a YAML configuration provider would enhance the flexibility and usability of ASP.NET Core applications, especially for developers who prefer or require YAML for their configuration needs.

Benefits:

  • Increased flexibility in configuration file formats.
  • Improved readability and maintainability of configuration files for developers who prefer YAML.
  • Enhanced support for complex configuration scenarios.

YAML is widely used in various applications and tools, such as Kubernetes and Ansible, making it a valuable addition to the ASP.NET Core configuration system. By supporting YAML, ASP.NET Core can better align with the preferences and needs of a broader developer community.

API Proposal

builder.Configuration
    .AddYamlFile("appsettings.yaml", optional: false, reloadOnChange: true)
    .AddYamlFile($"appsettings.{builder.Environment.EnvironmentName}.yaml", optional: true, reloadOnChange: true);

API Usage

builder.Configuration
    .AddYamlFile("appsettings.yaml", optional: false, reloadOnChange: true)
    .AddYamlFile($"appsettings.{builder.Environment.EnvironmentName}.yaml", optional: true, reloadOnChange: true);

Alternative Designs

No response

Risks

No response

Activity

  1. added
    api-suggestion
    on Oct 24, 2024
  2. added
    untriaged
    on Oct 24, 2024
  3. dotnet-policy-service commented on Oct 24, 2024

    @dotnet-policy-service
    Contributor

    Tagging subscribers to this area: @dotnet/area-extensions-configuration
    See info in area-owners.md if you want to be subscribed.

  4. added this to the Future milestone on Oct 24, 2024
  5. removed
    untriaged
    on Oct 24, 2024
  6. am11 commented on Oct 24, 2024

    @am11
    Member

    Currently, runtime libraries do not offer built-in support for YAML serialization, which is the prerequisite of this feature request. However, there are community-driven YAML serialization packages like YamlDotNet, which serve as the foundation for various extensions, such as NetEscapades.Configuration.Yaml (https://www.nuget.org/packages/NetEscapades.Configuration.Yaml) and SharpDotYaml.Extensions.Configuration (https://www.nuget.org/packages/SharpDotYaml.Extensions.Configuration). Do these options meet the requirements of your use case?

  7. stasberkov commented on Oct 25, 2024

    @stasberkov
    Author

    Yeah, I saw these libs. I would like to minimize dependency on 3rd party libs for core functionality. I believe configuration is a part of application core.

  8. am11 commented on Oct 25, 2024

    @am11
    Member

    I would like to minimize dependency on 3rd party libs for core functionality.

    See this discussion #83313 (comment), generally third party libraries is the way to go when it comes to YAML. #83313 is the prerequisite, and other similar proposals before that (which were not accepted).

  9. StephenHodgson commented on Dec 11, 2024

    @StephenHodgson

    As much as I'd love to see a native yaml parser in .net, I think since json is a subset of yaml, probably better to just use the json format for this specific purpose.

    That being said most people prefer yaml for configuration files.

  10. rosebyte commented on Mar 6, 2026

    @rosebyte
    Member

    Triage: we see there are several 3rd party packages.

  11. StephenHodgson commented on Mar 6, 2026

    @StephenHodgson

    3rd party isn't 1st party. IMHO YAML should be since a majority of CI/CD and automation and config as code implementations are YAML.

  12. stasberkov commented on Mar 6, 2026

    @stasberkov
    Author

    Exactly! For a long time aspnet was using Newtonsoft JSON library. Then they decided to implement own JSON parser. Why not implement own YAML if it is so popular?

  13. locked and limited conversation to collaborators on Apr 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    api-suggestionarea-Extensions-Configuration

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions