Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[Bb]in/
[Oo]bj/
src/**/[Bb]in/
src/**/[Oo]bj/
test/**/[Bb]in/
test/**/[Oo]bj/
.vs/
msbuild.*
/packages/
samples/SampleWebApp/bin/
samples/SampleWebApp/obj/
26 changes: 26 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# How to contribute

One of the easiest ways to contribute is to participate in discussions and discuss issues. You can also contribute by submitting pull requests with code changes.

## General feedback and discussions?
Please start a discussion on the [Home repo issue tracker](https://github.com/aspnet/MicrosoftConfigurationBuilders/issues).

## Bugs and feature requests?
For non-security related bugs please log a new issue on the [Home repo issue tracker](https://github.com/aspnet/MicrosoftConfigurationBuilders/issues).

## Reporting security issues and bugs
Security issues and bugs should be reported privately, via email, to the Microsoft Security Response Center (MSRC) secure@microsoft.com. You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Further information, including the MSRC PGP key, can be found in the [Security TechCenter](https://technet.microsoft.com/en-us/security/ff852094.aspx).

## Filing issues
When filing issues, please use our [bug filing templates](https://github.com/aspnet/MicrosoftConfigurationBuilders/wiki/Functional-bug-template).
The best way to get your bug fixed is to be as detailed as you can be about the problem.
Providing a minimal project with steps to reproduce the problem is ideal.
Here are questions you can answer before you file a bug to make sure you're not missing any important information.

1. Did you read the [documentation](https://github.com/aspnet/MicrosoftConfigurationBuilders/wiki)?
2. Did you include the snippet of broken code in the issue?
3. What are the *EXACT* steps to reproduce this problem?
4. What version Powershell are you using?
5. What version of VS (including update version) are you using?

GitHub supports [markdown](https://help.github.com/articles/github-flavored-markdown/), so when filing bugs make sure you check the formatting before clicking submit.
12 changes: 12 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
ASP.NET Configuration Builders

Copyright (c) Microsoft Corporation
All rights reserved.

MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the Software), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1 change: 1 addition & 0 deletions MicrosoftConfigurationBuilders.msbuild
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

<ItemGroup Condition="'$(BuildCoreOnly)' != 'true'">
<AssemblyProject Include="test\Microsoft.Configuration.ConfigurationBuilders.Test\Test\Test.csproj" />
<AssemblyProject Include="samples\SampleWebApp\SampleWebApp.csproj" />
</ItemGroup>

<ItemGroup>
Expand Down
41 changes: 8 additions & 33 deletions MicrosoftConfigurationBuilders.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27018.1
VisualStudioVersion = 15.0.27130.2036
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure", "src\Azure\Azure.csproj", "{345C5437-4990-45DC-BE34-6E37AA05D8D2}"
ProjectSection(ProjectDependencies) = postProject
Expand Down Expand Up @@ -38,33 +38,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Samples", "Samples", "{2F759F48-7F89-4811-8F94-380BCCC83C69}"
EndProject
Project("{E24C65DC-7377-472B-9ABA-BC803B73C61A}") = "ConfigBuildersSample", "samples\ConfigBuildersSample\ConfigBuildersSample\", "{B6D1F37C-41CD-4809-A7F0-AD10EBFDC6CE}"
ProjectSection(WebsiteProperties) = preProject
TargetFrameworkMoniker = ".NETFramework,Version%3Dv4.7.1"
ProjectReferences = "{f382fbf8-146d-4968-a199-90d37f9ef9a7}|Microsoft.Configuration.ConfigurationBuilders.Base.dll;{84e0ce5d-4af2-414f-a940-22b3f93fc727}|Microsoft.Configuration.ConfigurationBuilders.Json.dll;{c60d6cbb-d513-4692-81a6-0be5d45e4702}|Microsoft.Configuration.ConfigurationBuilders.UserSecrets.dll;{c6530e81-d8d8-47a8-912e-d2939f801835}|Microsoft.Configuration.ConfigurationBuilders.Environment.dll;"
Debug.AspNetCompiler.VirtualPath = "/localhost_57833"
Debug.AspNetCompiler.PhysicalPath = "samples\ConfigBuildersSample\ConfigBuildersSample\"
Debug.AspNetCompiler.TargetPath = "PrecompiledWeb\localhost_57833\"
Debug.AspNetCompiler.Updateable = "true"
Debug.AspNetCompiler.ForceOverwrite = "true"
Debug.AspNetCompiler.FixedNames = "false"
Debug.AspNetCompiler.Debug = "True"
Release.AspNetCompiler.VirtualPath = "/localhost_57833"
Release.AspNetCompiler.PhysicalPath = "samples\ConfigBuildersSample\ConfigBuildersSample\"
Release.AspNetCompiler.TargetPath = "PrecompiledWeb\localhost_57833\"
Release.AspNetCompiler.Updateable = "true"
Release.AspNetCompiler.ForceOverwrite = "true"
Release.AspNetCompiler.FixedNames = "false"
Release.AspNetCompiler.Debug = "False"
VWDPort = "57833"
SlnRelativePath = "samples\ConfigBuildersSample\ConfigBuildersSample\"
DefaultWebSiteLanguage = "Visual C#"
EndProjectSection
ProjectSection(ProjectDependencies) = postProject
{C6530E81-D8D8-47A8-912E-D2939F801835} = {C6530E81-D8D8-47A8-912E-D2939F801835}
{C60D6CBB-D513-4692-81A6-0BE5D45E4702} = {C60D6CBB-D513-4692-81A6-0BE5D45E4702}
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Base", "src\Base\Base.csproj", "{F382FBF8-146D-4968-A199-90D37F9EF9A7}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UserSecrets", "src\UserSecrets\UserSecrets.csproj", "{C60D6CBB-D513-4692-81A6-0BE5D45E4702}"
Expand All @@ -77,6 +50,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Environment", "src\Environm
{F382FBF8-146D-4968-A199-90D37F9EF9A7} = {F382FBF8-146D-4968-A199-90D37F9EF9A7}
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SampleWebApp", "samples\SampleWebApp\SampleWebApp.csproj", "{590892DD-F842-4E7C-9400-4C6451C16B1A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -99,10 +74,6 @@ Global
{9371A23F-BCB8-4429-8652-0A12D43F14F3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9371A23F-BCB8-4429-8652-0A12D43F14F3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9371A23F-BCB8-4429-8652-0A12D43F14F3}.Release|Any CPU.Build.0 = Release|Any CPU
{B6D1F37C-41CD-4809-A7F0-AD10EBFDC6CE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B6D1F37C-41CD-4809-A7F0-AD10EBFDC6CE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B6D1F37C-41CD-4809-A7F0-AD10EBFDC6CE}.Release|Any CPU.ActiveCfg = Debug|Any CPU
{B6D1F37C-41CD-4809-A7F0-AD10EBFDC6CE}.Release|Any CPU.Build.0 = Debug|Any CPU
{F382FBF8-146D-4968-A199-90D37F9EF9A7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F382FBF8-146D-4968-A199-90D37F9EF9A7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F382FBF8-146D-4968-A199-90D37F9EF9A7}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand All @@ -115,12 +86,16 @@ Global
{C6530E81-D8D8-47A8-912E-D2939F801835}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C6530E81-D8D8-47A8-912E-D2939F801835}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C6530E81-D8D8-47A8-912E-D2939F801835}.Release|Any CPU.Build.0 = Release|Any CPU
{590892DD-F842-4E7C-9400-4C6451C16B1A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{590892DD-F842-4E7C-9400-4C6451C16B1A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{590892DD-F842-4E7C-9400-4C6451C16B1A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{590892DD-F842-4E7C-9400-4C6451C16B1A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{B6D1F37C-41CD-4809-A7F0-AD10EBFDC6CE} = {2F759F48-7F89-4811-8F94-380BCCC83C69}
{590892DD-F842-4E7C-9400-4C6451C16B1A} = {2F759F48-7F89-4811-8F94-380BCCC83C69}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {6380A53F-A088-4D0B-B415-C8D16222F022}
Expand Down
46 changes: 24 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Configuration Builders

Configuration Builders are a new feature of the full .Net Framework, introduced in .Net 4.7.1. You can read about the concept in [this blog post](http://www.msdn.com).
Configuration Builders are a new feature of the full .Net Framework, introduced in .Net 4.7.1. You can read about the concept in [this blog post](http://jeffreyfritz.com/2017/11/modern-configuration-for-asp-net-4-7-1-with-configurationbuilders/).
With this project, Microsoft is providing a basic set of Configuration Builders that should make it easy for developers to get started with the new feature. They
are also intended to address some of the basic needs of applications as they move into a container and cloud focused environment.

Expand Down Expand Up @@ -59,48 +59,51 @@ This is the simplest of the config builders. It draws its values from Environmen
```xml
<add name="UserSecrets"
[mode|prefix|stripPrefix]
(userSecretId="12345678-90AB-CDEF-1234-567890" | userSecretFile="~\secrets.file")
[ignoreMissingFile="true"]
(userSecretsId="12345678-90AB-CDEF-1234-567890" | userSecretsFile="~\secrets.file")
[optional="true"]
type="Microsoft.Configuration.ConfigurationBuilders.UserSecretsConfigBuilder, Microsoft.Configuration.ConfigurationBuilders.UserSecrets" />
```
To enable a feature similar to .Net Core's user secrets you can use this config builder. Microsoft is considering future plans to better integrate secret management
into Visual Studio, and full-framework projects would use this config builder. In order to keep external dependencies out of the picture, the actual secret file will
be xml formatted. (If you need to share a secrets.json file with Core projects, you could consider using the `SimpleJsonConfigBuilder` below.)
To enable a feature similar to .Net Core's user secrets you can use this config builder. Microsoft is adding better secrets management in future releases
of Visual Studio, and this config builder will be a part of that plan. Web Applications are the initial target for this work in Visual Studio, but this
configuration builder can be used in any full-framework project if you specify your own secrets file. (Or define the 'UserSecretsId' property in your
project file and create the raw secrets file in the correct location for reading.) In order to keep external dependencies out of the picture, the
actual secret file will be xml formatted - though this should be considered an implementation detail, and the format should not be relied upon.
(If you need to share a secrets.json file with Core projects, you could consider using the `SimpleJsonConfigBuilder` below... but as with this
builder, the json format for Core secrets is technically an implementation detail subject to change as well.)

There are three additional configuration attributes for this config builder:
* `userSecretsId` - This is the preferred method for identifying an xml secrets file. It works similar to .Net Core, which uses a 'UserSecretsId' project
property to store this identifier. (The string does not have to be a Guid. Just unique. The VS "Manage User Secrets" experience produces a Guid.) With this
attribute, the `UserSecretsConfigBuilder` will look in a well-known local location for a secrets file belonging to this identifier. One of this attribute or
the 'userSecretsFile' attribute is required.
attribute, the `UserSecretsConfigBuilder` will look in a well-known local location for a secrets file belonging to this identifier. In MSBuild environments,
the value of this attribute will be replaced with the project property $(UserSecretsId) in the output directory iff the initial value is '${UserSecretsId}'.
One of this attribute or the 'userSecretsFile' attribute is required.
* `userSecretsFile` - An optional attribute specifying the file containing the secrets. The '~' character can be used at the start to reference the app root.
One of this attribute or the 'userSecretsId' attribute is required. If both are specified, 'userSecretsFile' takes precedence.
* `ignoreMissingFile` - A simple boolean to avoid throwing exceptions if the secrets file cannot be found. The default is `true`.
* `optional` - A simple boolean to avoid throwing exceptions if the secrets file cannot be found. The default is `true`.

### AzureKeyVaultConfigBuilder
```xml
<add name="AzureKeyVault"
[mode|prefix|stripPrefix]
(vaultName="MyVaultName" |
uri="https://MyVaultName.vault.azure.net")
[clientId="12345678-9012-3456-7890-123456789012"
clientSecret="8eNKl240FSfhgY909unhg23DKNj3b2cOO8bVvd+wdCc="]
[connectionString="connection string"]
type="Microsoft.Configuration.ConfigurationBuilders.AzureKeyVaultConfigBuilder, Microsoft.Configuration.ConfigurationBuilders.Azure" />
```
If your secrets are kept in Azure Key Vault, then this config builder is for you. There are four additional attributes for this config builder. The `vaultName` is
If your secrets are kept in Azure Key Vault, then this config builder is for you. There are three additional attributes for this config builder. The `vaultName` is
required. The other attributes allow you some manual control about which vault to connect to, but are only necessary if the application is not running in an
environment that works well with `Microsoft.Azure.Services.AppAuthentication`. Otherwise, the Azure Services Authentication library is used to automatically pick
up connection information from the execution environment.
environment that works magically with `Microsoft.Azure.Services.AppAuthentication`. The Azure Services Authentication library is used to automatically pick
up connection information from the execution environment if possible, but you can override that feature by providing a connection string instead.
* `vaultName` - This is a required attribute. It specifies the name of the vault in your Azure subscription from which to read key/value pairs.
* `clientId` - This is the Azure Active Directory App Id. A string representation of a GUID.
* `clientSecret` - This is the Azure Active Directory App Key. A string.
* `connectionString` - A connection string usable by [AzureServiceTokenProvider](https://docs.microsoft.com/en-us/azure/key-vault/service-to-service-authentication#connection-string-support)
* `uri` - Connect to other Key Vault providers with this attribute. If not specified, Azure is the assumed Vault provider. If the uri _is_specified, then `vaultName` is no longer a required parameter.

### SimpleJsonConfigBuilder
```xml
<add name="SimpleJson"
[mode|prefix|stripPrefix]
jsonFile="~\config.json"
[ignoreMissingFile="true"]
[optional="true"]
[jsonMode="(Flat|Sectional)"]
type="Microsoft.Configuration.ConfigurationBuilders.SimpleJsonConfigBuilder, Microsoft.Configuration.ConfigurationBuilders.Json" />
```
Expand All @@ -113,7 +116,7 @@ begins with 'Simple.' Think of the backing json file as a simple dictionary, rat

There are three additional attributes that can be used to configure this builder:
* `jsonFile` - A required attribute specifying the json file to draw from. The '~' character can be used at the start to reference the app root.
* `ignoreMissingFile` - A simple boolean to avoid throwing exceptions if the secrets file cannot be found. The default is `true`.
* `optional` - A simple boolean to avoid throwing exceptions if the json file cannot be found. The default is `true`.
* `jsonMode` - `[Flat|Sectional]`. 'Flat' is the default.
- This attribute requires a little more explanation. It says above to think of the json file as a single flat key/value source. This is the usual that applies to other key/value config builders like `EnvironmentConfigBuilder` and `AzureKeyVaultConfigBuilder` because those sources provide no other option. If the `SimpleJsonConfigBuilder` is configured in 'Sectional' mode, then the json file is conceptually divided just at the top level into multiple simple dictionaries. Each one of those dictionaries will only be applied to the config section that matches the top-level property name attached to them. For example:
```json
Expand Down Expand Up @@ -158,7 +161,6 @@ public class CustomConfigBuilder : KeyValueConfigBuilder
```

## Blog Posts
[Insert](sldfj)
[Blog Posts](sldkfjs)
[And References](sldkfj)
[Here](lskdjf)
[.Net Framework 4.7.1 ASP.NET and Configuration features](https://blogs.msdn.microsoft.com/dotnet/2017/09/13/net-framework-4-7-1-asp-net-and-configuration-features/)
[Modern Configuration for ASP.NET 4.7.1 with ConfigurationBuilders](http://jeffreyfritz.com/2017/11/modern-configuration-for-asp-net-4-7-1-with-configurationbuilders/)
[Service-to-service authentication to Azure Key Vault using .NET](https://docs.microsoft.com/en-us/azure/key-vault/service-to-service-authentication#connection-string-support)
5 changes: 3 additions & 2 deletions build.cmd
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
@ECHO OFF

setlocal
set EnableNuGetPackageRestore=true

REM msbuild will compile in Debug mode by default. The nuget packages project is Release by default.
REM Long story short... be explicit. Don't use defaults.
REM set cfgOption=/p:Configuration=Release
set cfgOption=/p:Configuration=Debug
set cfgOption=/p:Configuration=Release
REM set cfgOption=/p:Configuration=Debug
REM set cfgOption=/p:Configuration=Debug;Release

set logOptions=/flp:Summary;Verbosity=diag;LogFile=msbuild.log /flp1:warningsonly;logfile=msbuild.wrn /flp2:errorsonly;logfile=msbuild.err
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading