Skip to content

Commit

Permalink
Merge pull request #493 from Azure/merge-preview-to-main
Browse files Browse the repository at this point in the history
Merge preview to main
  • Loading branch information
amerjusupovic authored Nov 17, 2023
2 parents 5fff60f + 5301c78 commit d970761
Show file tree
Hide file tree
Showing 28 changed files with 553 additions and 135 deletions.
2 changes: 1 addition & 1 deletion .pipelines/OneBranch.Official.yml
Original file line number Diff line number Diff line change
Expand Up @@ -171,5 +171,5 @@ extends:
testResultsFormat: 'vstest'
testResultsFiles: '**/*.trx'
searchFolder: ''
failTaskOnFailedTests: False
failTaskOnFailedTests: True
testRunTitle: Unit Tests
4 changes: 2 additions & 2 deletions build/install-dotnet.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@

[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12;

&([scriptblock]::Create((Invoke-WebRequest -UseBasicParsing 'https://dot.net/v1/dotnet-install.ps1'))) -Version 7.0.100
&([scriptblock]::Create((Invoke-WebRequest -UseBasicParsing 'https://dot.net/v1/dotnet-install.ps1'))) -Channel 6.0

&([scriptblock]::Create((Invoke-WebRequest -UseBasicParsing 'https://dot.net/v1/dotnet-install.ps1'))) -Version 6.0.301
&([scriptblock]::Create((Invoke-WebRequest -UseBasicParsing 'https://dot.net/v1/dotnet-install.ps1'))) -Channel 7.0
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Import Project="..\..\build\NugetProperties.props" />

<PropertyGroup>
<TargetFrameworks>netstandard2.0;netcoreapp3.1;net6.0;net7.0</TargetFrameworks>
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
<Description>Microsoft.Azure.AppConfiguration.AspNetCore allows developers to use Microsoft Azure App Configuration service as a configuration source in their applications. This package adds additional features for ASP.NET Core applications to the existing package Microsoft.Extensions.Configuration.AzureAppConfiguration.</Description>
<SignAssembly>true</SignAssembly>
<DelaySign>false</DelaySign>
Expand All @@ -15,14 +15,7 @@

<ItemGroup>
<ProjectReference Include="..\Microsoft.Extensions.Configuration.AzureAppConfiguration\Microsoft.Extensions.Configuration.AzureAppConfiguration.csproj" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.1.1" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' != 'netstandard2.0'">
<FrameworkReference Include="Microsoft.AspNetCore.App" />
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>

<!-- Nuget Package Version Settings -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
namespace Microsoft.Extensions.Configuration.AzureAppConfiguration
{
/// <summary>
/// Options used to configure the behavior of an Azure App Configuration provider.
/// Options used to configure the behavior of an Azure App Configuration provider.
/// If neither <see cref="Select"/> nor <see cref="SelectSnapshot"/> is ever called, all key-values with no label are included in the configuration provider.
/// </summary>
public class AzureAppConfigurationOptions
{
Expand All @@ -24,11 +25,7 @@ public class AzureAppConfigurationOptions

private List<KeyValueWatcher> _changeWatchers = new List<KeyValueWatcher>();
private List<KeyValueWatcher> _multiKeyWatchers = new List<KeyValueWatcher>();
private List<IKeyValueAdapter> _adapters = new List<IKeyValueAdapter>()
{
new AzureKeyVaultKeyValueAdapter(new AzureKeyVaultSecretProvider()),
new JsonKeyValueAdapter()
};
private List<IKeyValueAdapter> _adapters;
private List<Func<ConfigurationSetting, ValueTask<ConfigurationSetting>>> _mappers = new List<Func<ConfigurationSetting, ValueTask<ConfigurationSetting>>>();
private List<KeyValueSelector> _kvSelectors = new List<KeyValueSelector>();
private IConfigurationRefresher _refresher = new AzureAppConfigurationRefresher();
Expand Down Expand Up @@ -57,7 +54,7 @@ public class AzureAppConfigurationOptions
/// <summary>
/// A collection of <see cref="KeyValueSelector"/>.
/// </summary>
public IEnumerable<KeyValueSelector> KeyValueSelectors => _kvSelectors;
internal IEnumerable<KeyValueSelector> KeyValueSelectors => _kvSelectors;

/// <summary>
/// A collection of <see cref="KeyValueWatcher"/>.
Expand Down Expand Up @@ -114,6 +111,24 @@ internal IEnumerable<IKeyValueAdapter> Adapters
/// </summary>
internal FeatureFilterTracing FeatureFilterTracing { get; set; } = new FeatureFilterTracing();

/// <summary>
/// Options used to configure provider startup.
/// </summary>
internal StartupOptions Startup { get; set; } = new StartupOptions();

/// <summary>
/// Initializes a new instance of the <see cref="AzureAppConfigurationOptions"/> class.
/// </summary>
public AzureAppConfigurationOptions()
{
_adapters = new List<IKeyValueAdapter>()
{
new AzureKeyVaultKeyValueAdapter(new AzureKeyVaultSecretProvider()),
new JsonKeyValueAdapter(),
new FeatureManagementKeyValueAdapter(FeatureFilterTracing)
};
}

/// <summary>
/// Specify what key-values to include in the configuration provider.
/// <see cref="Select"/> can be called multiple times to include multiple sets of key-values.
Expand Down Expand Up @@ -151,7 +166,7 @@ public AzureAppConfigurationOptions Select(string keyFilter, string labelFilter
throw new ArgumentException("The characters '*' and ',' are not supported in label filters.", nameof(labelFilter));
}

if (!_kvSelectors.Any(s => s.KeyFilter.Equals(keyFilter) && s.LabelFilter.Equals(labelFilter)))
if (!_kvSelectors.Any(s => string.Equals(s.KeyFilter, keyFilter) && string.Equals(s.LabelFilter, labelFilter)))
{
_kvSelectors.Add(new KeyValueSelector
{
Expand All @@ -164,7 +179,32 @@ public AzureAppConfigurationOptions Select(string keyFilter, string labelFilter
}

/// <summary>
/// Enables Azure App Configuration feature flags to be parsed and transformed into feature management configuration.
/// Specify a snapshot and include its contained key-values in the configuration provider.
/// <see cref="SelectSnapshot"/> can be called multiple times to include key-values from multiple snapshots.
/// </summary>
/// <param name="name">The name of the snapshot in Azure App Configuration.</param>
public AzureAppConfigurationOptions SelectSnapshot(string name)
{
if (string.IsNullOrEmpty(name))
{
throw new ArgumentNullException(nameof(name));
}

if (!_kvSelectors.Any(s => string.Equals(s.SnapshotName, name)))
{
_kvSelectors.Add(new KeyValueSelector
{
SnapshotName = name
});
}

return this;
}

/// <summary>
/// Configures options for Azure App Configuration feature flags that will be parsed and transformed into feature management configuration.
/// If no filtering is specified via the <see cref="FeatureFlagOptions"/> then all feature flags with no label are loaded.
/// All loaded feature flags will be automatically registered for refresh on an individual flag level.
/// </summary>
/// <param name="configure">A callback used to configure feature flag options.</param>
public AzureAppConfigurationOptions UseFeatureFlags(Action<FeatureFlagOptions> configure = null)
Expand Down Expand Up @@ -221,11 +261,6 @@ public AzureAppConfigurationOptions UseFeatureFlags(Action<FeatureFlagOptions> c
}
}

if (!_adapters.Any(a => a is FeatureManagementKeyValueAdapter))
{
_adapters.Add(new FeatureManagementKeyValueAdapter(FeatureFilterTracing));
}

return this;
}

Expand Down Expand Up @@ -329,7 +364,7 @@ public AzureAppConfigurationOptions TrimKeyPrefix(string prefix)
}

/// <summary>
/// Configure the client used to communicate with Azure App Configuration.
/// Configure the client(s) used to communicate with Azure App Configuration.
/// </summary>
/// <param name="configure">A callback used to configure Azure App Configuration client options.</param>
public AzureAppConfigurationOptions ConfigureClientOptions(Action<ConfigurationClientOptions> configure)
Expand Down Expand Up @@ -407,9 +442,19 @@ public AzureAppConfigurationOptions Map(Func<ConfigurationSetting, ValueTask<Con
return this;
}

/// <summary>
/// Configure the provider behavior when loading data from Azure App Configuration on startup.
/// </summary>
/// <param name="configure">A callback used to configure Azure App Configuration startup options.</param>
public AzureAppConfigurationOptions ConfigureStartupOptions(Action<StartupOptions> configure)
{
configure?.Invoke(Startup);
return this;
}

private static ConfigurationClientOptions GetDefaultClientOptions()
{
var clientOptions = new ConfigurationClientOptions(ConfigurationClientOptions.ServiceVersion.V1_0);
var clientOptions = new ConfigurationClientOptions(ConfigurationClientOptions.ServiceVersion.V2023_10_01);
clientOptions.Retry.MaxRetries = MaxRetries;
clientOptions.Retry.MaxDelay = MaxRetryDelay;
clientOptions.Retry.Mode = RetryMode.Exponential;
Expand Down
Loading

0 comments on commit d970761

Please sign in to comment.