Skip to content

Commit 966074d

Browse files
Update AzureAppConfigurationBuilder to use public SDK from Azure. (#85)
1 parent eb266a9 commit 966074d

13 files changed

Lines changed: 365 additions & 199 deletions

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ and currently exposes the format of the file which, as mentioned above, should b
179179
(@endpoint="https://your-appconfig-store.azconfig.io" | @connectionString="Endpoint=https://your-appconfig-store.azconfig.io;Id=XXXXXXXXXX;Secret=XXXXXXXXXX")
180180
[@keyFilter="string"]
181181
[@labelFilter="label"]
182-
[@preferredDateTime="DateTimeOffset"]
182+
[@acceptDateTime="DateTimeOffset"]
183183
type="Microsoft.Configuration.ConfigurationBuilders.AzureAppConfigurationBuilder, Microsoft.Configuration.ConfigurationBuilders.AzureAppConfig" />
184184
```
185185
[AppConfiguration](https://docs.microsoft.com/en-us/azure/azure-app-configuration/overview) is a new offering from Azure, currently in preview. If you
@@ -190,7 +190,7 @@ It is however, __strongly__ encouraged to use `endpoint` with a managed service
190190
* `connectionString` - This specifies the AppConfiguration store to connect to, along with the Id and Secret necessary to access the service.
191191
* `keyFilter` - Use this to select a set of configuration values matching a certain key pattern.
192192
* `labelFilter` - Only retrieve configuration values that match a certain label.
193-
* `preferredDateTime` - Instead of versioning ala Azure Key Vault, AppConfiguration uses timestamps. Use this attribute to go back in time
193+
* `acceptDateTime` - Instead of versioning ala Azure Key Vault, AppConfiguration uses timestamps. Use this attribute to go back in time
194194
to retrieve configuration values from a past state.
195195

196196
### AzureKeyVaultConfigBuilder

samples/SampleWebApp/SampleWebApp.csproj

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,15 @@
4444
<WarningLevel>4</WarningLevel>
4545
</PropertyGroup>
4646
<ItemGroup>
47+
<Reference Include="Azure.Core, Version=1.0.1.0, Culture=neutral, PublicKeyToken=92742159e12e44c8, processorArchitecture=MSIL">
48+
<HintPath>..\..\packages\Azure.Core.1.0.1\lib\netstandard2.0\Azure.Core.dll</HintPath>
49+
</Reference>
50+
<Reference Include="Azure.Data.AppConfiguration, Version=1.0.0.0, Culture=neutral, PublicKeyToken=92742159e12e44c8, processorArchitecture=MSIL">
51+
<HintPath>..\..\packages\Azure.Data.AppConfiguration.1.0.0-preview.6\lib\netstandard2.0\Azure.Data.AppConfiguration.dll</HintPath>
52+
</Reference>
53+
<Reference Include="Azure.Identity, Version=1.0.0.0, Culture=neutral, PublicKeyToken=92742159e12e44c8, processorArchitecture=MSIL">
54+
<HintPath>..\..\packages\Azure.Identity.1.0.0\lib\netstandard2.0\Azure.Identity.dll</HintPath>
55+
</Reference>
4756
<Reference Include="Microsoft.Azure.KeyVault, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
4857
<HintPath>..\..\packages\Microsoft.Azure.KeyVault.2.3.2\lib\net452\Microsoft.Azure.KeyVault.dll</HintPath>
4958
</Reference>
@@ -53,10 +62,16 @@
5362
<Reference Include="Microsoft.Azure.Services.AppAuthentication, Version=1.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
5463
<HintPath>..\..\packages\Microsoft.Azure.Services.AppAuthentication.1.0.1\lib\net452\Microsoft.Azure.Services.AppAuthentication.dll</HintPath>
5564
</Reference>
65+
<Reference Include="Microsoft.Bcl.AsyncInterfaces, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
66+
<HintPath>..\..\packages\Microsoft.Bcl.AsyncInterfaces.1.0.0\lib\net461\Microsoft.Bcl.AsyncInterfaces.dll</HintPath>
67+
</Reference>
5668
<Reference Include="Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
5769
<HintPath>..\..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\lib\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll</HintPath>
5870
</Reference>
5971
<Reference Include="Microsoft.CSharp" />
72+
<Reference Include="Microsoft.Identity.Client, Version=4.1.0.0, Culture=neutral, PublicKeyToken=0a613f4dd989e8ae, processorArchitecture=MSIL">
73+
<HintPath>..\..\packages\Microsoft.Identity.Client.4.1.0\lib\net45\Microsoft.Identity.Client.dll</HintPath>
74+
</Reference>
6075
<Reference Include="Microsoft.IdentityModel.Clients.ActiveDirectory, Version=3.19.2.6005, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
6176
<HintPath>..\..\packages\Microsoft.IdentityModel.Clients.ActiveDirectory.3.19.2\lib\net45\Microsoft.IdentityModel.Clients.ActiveDirectory.dll</HintPath>
6277
</Reference>
@@ -72,6 +87,40 @@
7287
<Reference Include="Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
7388
<HintPath>..\..\packages\Newtonsoft.Json.11.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
7489
</Reference>
90+
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
91+
<HintPath>..\..\packages\System.Buffers.4.5.0\lib\netstandard2.0\System.Buffers.dll</HintPath>
92+
</Reference>
93+
<Reference Include="System.Diagnostics.DiagnosticSource, Version=4.0.4.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
94+
<HintPath>..\..\packages\System.Diagnostics.DiagnosticSource.4.6.0\lib\net46\System.Diagnostics.DiagnosticSource.dll</HintPath>
95+
</Reference>
96+
<Reference Include="System.IdentityModel" />
97+
<Reference Include="System.Memory, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
98+
<HintPath>..\..\packages\System.Memory.4.5.3\lib\netstandard2.0\System.Memory.dll</HintPath>
99+
</Reference>
100+
<Reference Include="System.Net.Http, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
101+
<Reference Include="System.Numerics" />
102+
<Reference Include="System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
103+
<HintPath>..\..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll</HintPath>
104+
</Reference>
105+
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=4.0.5.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
106+
<HintPath>..\..\packages\System.Runtime.CompilerServices.Unsafe.4.6.0\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
107+
</Reference>
108+
<Reference Include="System.Security" />
109+
<Reference Include="System.Security.Cryptography.ProtectedData, Version=4.0.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
110+
<HintPath>..\..\packages\System.Security.Cryptography.ProtectedData.4.5.0\lib\net461\System.Security.Cryptography.ProtectedData.dll</HintPath>
111+
</Reference>
112+
<Reference Include="System.Text.Encodings.Web, Version=4.0.4.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
113+
<HintPath>..\..\packages\System.Text.Encodings.Web.4.6.0\lib\netstandard2.0\System.Text.Encodings.Web.dll</HintPath>
114+
</Reference>
115+
<Reference Include="System.Text.Json, Version=4.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
116+
<HintPath>..\..\packages\System.Text.Json.4.6.0\lib\net461\System.Text.Json.dll</HintPath>
117+
</Reference>
118+
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
119+
<HintPath>..\..\packages\System.Threading.Tasks.Extensions.4.5.2\lib\netstandard2.0\System.Threading.Tasks.Extensions.dll</HintPath>
120+
</Reference>
121+
<Reference Include="System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
122+
<HintPath>..\..\packages\System.ValueTuple.4.5.0\lib\net47\System.ValueTuple.dll</HintPath>
123+
</Reference>
75124
<Reference Include="System.Web.DynamicData" />
76125
<Reference Include="System.Web.Entity" />
77126
<Reference Include="System.Web.ApplicationServices" />
@@ -81,6 +130,7 @@
81130
<Reference Include="System.Core" />
82131
<Reference Include="System.Data.DataSetExtensions" />
83132
<Reference Include="System.Web.Extensions" />
133+
<Reference Include="System.Windows.Forms" />
84134
<Reference Include="System.Xml.Linq" />
85135
<Reference Include="System.Drawing" />
86136
<Reference Include="System.Web" />
@@ -111,6 +161,10 @@
111161
<Compile Include="Properties\AssemblyInfo.cs" />
112162
</ItemGroup>
113163
<ItemGroup>
164+
<ProjectReference Include="..\..\src\AzureAppConfig\AzureAppConfig.csproj">
165+
<Project>{3f1bb24a-355f-49e7-b396-6aa2eb5dda0e}</Project>
166+
<Name>AzureAppConfig</Name>
167+
</ProjectReference>
114168
<ProjectReference Include="..\..\src\Azure\Azure.csproj">
115169
<Project>{345c5437-4990-45dc-be34-6e37aa05d8d2}</Project>
116170
<Name>Azure</Name>

samples/SampleWebApp/Web.config

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
<configuration>
77
<configSections>
88
<section name="configBuilders" type="System.Configuration.ConfigurationBuildersSection, System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" restartOnExternalChanges="false" requirePermission="false" />
9+
<section name="appConfigTest" type="System.Configuration.AppSettingsSection, System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" restartOnExternalChanges="false" requirePermission="false" />
910
</configSections>
1011

1112
<!-- For the KeyVault builders, imagine this is the vault:
@@ -18,6 +19,22 @@
1819
STwo 63e11b20b386418d81618da23482534e First2
1920
ThrdScrt fca9f1b9d993414cb8bc807fb613baaf * Lastest3
2021
22+
23+
For Azure AppConfiguration, imagine this is the config store:
24+
25+
Key Label Value LastModified
26+
acTest (none) test1
27+
acTest2 (none) test2
28+
acTest2 beta test2b
29+
acTest2 beta2 test2b2
30+
acTest3 beta test3b
31+
acTest4 beta3 test4b3
32+
acLMTest (none) oldest T1 (T1,2 before 12/1/19. T3,4,5 after.)
33+
acLMTest (none) newer T3
34+
acLMTest2 ga older T2
35+
acLMTest2 ga newest T4
36+
acLMTest3 (none) toonew T5
37+
2138
-->
2239

2340
<configBuilders>
@@ -35,6 +52,10 @@
3552
<add name="AS_Sub_Test" optional="${Boolean}" type="Microsoft.Configuration.ConfigurationBuilders.EnvironmentConfigBuilder, Microsoft.Configuration.ConfigurationBuilders.Environment, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
3653
<add name="AS_Sub_Test2" optional="${app~Settings_Colon-and$friends@super+duper,awesome#cool:Test.}" type="Microsoft.Configuration.ConfigurationBuilders.EnvironmentConfigBuilder, Microsoft.Configuration.ConfigurationBuilders.Environment, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
3754
<add name="ExpTest" mode="Expand" escapeExpandedValues="true" jsonFile="~/App_Data/expandTest.json" jsonMode="Flat" type="Microsoft.Configuration.ConfigurationBuilders.SimpleJsonConfigBuilder, Microsoft.Configuration.ConfigurationBuilders.Json, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
55+
56+
<add name="appconfig1" endpoint="${AppConfigTestEndpoint}" keyFilter="acTes*" type="Microsoft.Configuration.ConfigurationBuilders.AzureAppConfigurationBuilder, Microsoft.Configuration.ConfigurationBuilders.AzureAppConfiguration, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
57+
<add name="appconfig2" endpoint="${AppConfigTestEndpoint}" mode="Greedy" labelFilter="beta" type="Microsoft.Configuration.ConfigurationBuilders.AzureAppConfigurationBuilder, Microsoft.Configuration.ConfigurationBuilders.AzureAppConfiguration, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
58+
<add name="appconfig3" endpoint="${AppConfigTestEndpoint}" mode="Greedy" keyFilter="acLM*" acceptDateTime="December 1, 2019" type="Microsoft.Configuration.ConfigurationBuilders.AzureAppConfigurationBuilder, Microsoft.Configuration.ConfigurationBuilders.AzureAppConfiguration, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
3859
</builders>
3960
</configBuilders>
4061

@@ -63,11 +84,25 @@
6384
<!-- key="Secret2" value="However, if the above does get updated to 'Secret2' with no version attached, it is then fair game for updates. KV1:Latest2,KV3:Latest2,KV4:Second2. KV2 won't update because its version doesn't exist for this secret." -->
6485
<!-- key="Secret2" value=" If the above does NOT get renamed to 'Secret2' though, then 'Secret2' will still get added IN ADDITION to the above by KV3:Latest2 or KV4:Second2." -->
6586
<!-- key="Secret3" value="Will be added by KV3:Latest3. IFF already added, will be "updated" by KV1 to Latest3. KV2 and KV4 don't have versions matching this secret." -->
87+
88+
<!-- These are needed to supply connection information for KeyVault and AppConfig, since the Environment builder is in strict mode. -->
89+
<add key="ConfigBuilderTestKeyVaultName" />
90+
<add key="AppConfigTestEndpoint" />
6691
</appSettings>
6792

93+
<appConfigTest configBuilders="appconfig1,appconfig2,appconfig3">
94+
<add key="acTest" value="Will be replaced by appconfig1. Should be 'test1'" />
95+
<add key="acTEST2" value="Should be case-insensitive replaced by appconfig1, and again by appconfig2. Should be 'test2b'" />
96+
<!-- <add key="acTest3" value="Will be added by appconfig2. Should be 'test3b'" /> -->
97+
<!-- <add key="acTest4" value="Will not exist." /> -->
98+
<add key="acLMTest" value="Will be replaced by appconfig3. Should be 'oldest'" />
99+
<!-- <add key="acLMTest2" value="Will be added by appconfig3. Should be 'older'" /> -->
100+
<add key="acLMTest3" value="Should be this. This will be left alone, as the config store entry is too new for appconfig3." />
101+
</appConfigTest>
102+
68103
<connectionStrings configBuilders="Json,ExpTest,AS_Sub_Test2">
69104
<add name="expansionTest" connectionString="${expandTestCS}" />
70-
<add name="expandTestCS" connectionString="Only replaced in Strict/Greedy modes. Not Expand."/>
105+
<add name="expandTestCS" connectionString="Only replaced in Strict/Greedy modes. Not Expand." />
71106
<add name="jsonConnectionString1" connectionString="Will be replaced by 'Json' in 'Flat' AND 'Sectional' jsonModes, but with different values." />
72107
<add name="connectionStrings:jsonConnectionString1" connectionString="Will only be replaced by 'Json' in 'Flat' jsonMode." />
73108
<add name="jsonConnectionString2" connectionString="Will only be replaced by 'Json' in 'Sectional' jsonMode." />
@@ -97,6 +132,30 @@
97132
<assemblyIdentity name="Microsoft.IdentityModel.Clients.ActiveDirectory.Platform" publicKeyToken="31bf3856ad364e35" culture="neutral" />
98133
<bindingRedirect oldVersion="0.0.0.0-3.19.2.6005" newVersion="3.19.2.6005" />
99134
</dependentAssembly>
135+
<dependentAssembly>
136+
<assemblyIdentity name="Azure.Core" publicKeyToken="92742159e12e44c8" culture="neutral" />
137+
<bindingRedirect oldVersion="0.0.0.0-1.0.1.0" newVersion="1.0.1.0" />
138+
</dependentAssembly>
139+
<dependentAssembly>
140+
<assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
141+
<bindingRedirect oldVersion="0.0.0.0-4.0.1.1" newVersion="4.0.1.1" />
142+
</dependentAssembly>
143+
<dependentAssembly>
144+
<assemblyIdentity name="System.Numerics.Vectors" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
145+
<bindingRedirect oldVersion="0.0.0.0-4.1.4.0" newVersion="4.1.4.0" />
146+
</dependentAssembly>
147+
<dependentAssembly>
148+
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
149+
<bindingRedirect oldVersion="0.0.0.0-4.0.5.0" newVersion="4.0.5.0" />
150+
</dependentAssembly>
151+
<dependentAssembly>
152+
<assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
153+
<bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
154+
</dependentAssembly>
155+
<dependentAssembly>
156+
<assemblyIdentity name="System.ValueTuple" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
157+
<bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
158+
</dependentAssembly>
100159
</assemblyBinding>
101160
</runtime>
102161
<system.codedom>

samples/SampleWebApp/default.aspx

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,35 @@
11
<% @Page Language="C#" %>
2+
<% @Import Namespace="System.Configuration" %>
23
<% @Import Namespace="System.Web.Configuration" %>
34

45
<script runat="server">
56
6-
void Page_Load() {
7-
Response.Write("<table border=1><tr><th colspan=2><h2>Application Settings</h2></th></tr>");
8-
foreach (string appsetting in WebConfigurationManager.AppSettings.Keys) {
9-
Response.Write("<tr><td>" + HttpUtility.HtmlEncode(appsetting) + "</td><td>" + HttpUtility.HtmlEncode(WebConfigurationManager.AppSettings[appsetting]) + "</td></tr>");
10-
}
11-
Response.Write("</table><br/><br/>");
7+
void Page_Load() {
8+
Response.Write("<table border=1><tr><th colspan=2><h2>Application Settings</h2></th></tr>");
9+
foreach (string appsetting in WebConfigurationManager.AppSettings.Keys) {
10+
Response.Write("<tr><td>" + HttpUtility.HtmlEncode(appsetting) + "</td><td>" + HttpUtility.HtmlEncode(WebConfigurationManager.AppSettings[appsetting]) + "</td></tr>");
11+
}
12+
Response.Write("</table><br/><br/>");
1213
13-
Response.Write("<table border=1><tr><th colspan=2><h2>Connection Strings</h2></th></tr>");
14-
foreach (ConnectionStringSettings cs in WebConfigurationManager.ConnectionStrings) {
15-
Response.Write("<tr><td>" + HttpUtility.HtmlEncode(cs.Name) + "</td><td>" + HttpUtility.HtmlEncode(cs.ConnectionString) + "</td></tr>");
16-
}
17-
Response.Write("</table><br/><br/>");
14+
Response.Write("<table border=1><tr><th colspan=2><h2>AppConfigTest</h2></th></tr>");
15+
var appConfigTestSection = WebConfigurationManager.GetSection("appConfigTest") as NameValueCollection;
16+
foreach (var configKey in appConfigTestSection.AllKeys) {
17+
Response.Write("<tr><td>" + HttpUtility.HtmlEncode(configKey) + "</td><td>" + HttpUtility.HtmlEncode(appConfigTestSection[configKey]) + "</td></tr>");
18+
}
19+
Response.Write("</table><br/><br/>");
1820
19-
Response.Write("<table border=1><tr><th colspan=2><h2>Environment Variables</h2></th></tr>");
20-
foreach (DictionaryEntry ev in System.Environment.GetEnvironmentVariables()) {
21-
Response.Write("<tr><td>" + HttpUtility.HtmlEncode(ev.Key) + "</td><td>" + HttpUtility.HtmlEncode(ev.Value) + "</td></tr>");
22-
}
23-
Response.Write("</table><br/><br/>");
24-
}
21+
Response.Write("<table border=1><tr><th colspan=2><h2>Connection Strings</h2></th></tr>");
22+
foreach (ConnectionStringSettings cs in WebConfigurationManager.ConnectionStrings) {
23+
Response.Write("<tr><td>" + HttpUtility.HtmlEncode(cs.Name) + "</td><td>" + HttpUtility.HtmlEncode(cs.ConnectionString) + "</td></tr>");
24+
}
25+
Response.Write("</table><br/><br/>");
26+
27+
Response.Write("<table border=1><tr><th colspan=2><h2>Environment Variables</h2></th></tr>");
28+
foreach (DictionaryEntry ev in System.Environment.GetEnvironmentVariables()) {
29+
Response.Write("<tr><td>" + HttpUtility.HtmlEncode(ev.Key) + "</td><td>" + HttpUtility.HtmlEncode(ev.Value) + "</td></tr>");
30+
}
31+
Response.Write("</table><br/><br/>");
32+
}
2533
2634
</script>
2735

0 commit comments

Comments
 (0)