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
4 changes: 3 additions & 1 deletion build/install-dotnet.ps1
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Installs .NET 6 for CI/CD environment
# Installs .NET 6 and .NET 7 for CI/CD environment
# see: https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-install-script#examples

[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'))) -Version 6.0.301
2 changes: 1 addition & 1 deletion examples/ConfigStoreDemo/ConfigStoreDemo.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<IsPackable>false</IsPackable>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.2" />
Expand Down
2 changes: 1 addition & 1 deletion examples/ConsoleApplication/ConsoleApplication.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<IsPackable>false</IsPackable>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand Down
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;net5.0;net6.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;netcoreapp3.1;net5.0;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 @@ -28,7 +28,7 @@
<!-- Nuget Package Version Settings -->

<PropertyGroup>
<OfficialVersion>5.1.0</OfficialVersion>
<OfficialVersion>5.2.0</OfficialVersion>
</PropertyGroup>

<PropertyGroup Condition="'$(CDP_PATCH_NUMBER)'!='' AND '$(CDP_BUILD_TYPE)'=='Official'">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Import Project="..\..\build\NugetProperties.props" />

<PropertyGroup>
<TargetFrameworks>net5.0;net6.0</TargetFrameworks>
<TargetFrameworks>net5.0;net6.0;net7.0</TargetFrameworks>
<Description>Microsoft.Azure.AppConfiguration.Functions.Worker allows developers to use the Microsoft Azure App Configuration service as a configuration source in their applications. This package adds additional features to the existing package Microsoft.Extensions.Configuration.AzureAppConfiguration for .NET Azure Functions running in an isolated process.</Description>
<SignAssembly>true</SignAssembly>
<DelaySign>false</DelaySign>
Expand All @@ -24,7 +24,7 @@
<!-- Nuget Package Version Settings -->

<PropertyGroup>
<OfficialVersion>5.1.0</OfficialVersion>
<OfficialVersion>5.2.0</OfficialVersion>
</PropertyGroup>

<PropertyGroup Condition="'$(CDP_PATCH_NUMBER)'!='' AND '$(CDP_BUILD_TYPE)'=='Official'">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public AzureAppConfigurationOptions Select(string keyFilter, string labelFilter
throw new ArgumentNullException(nameof(keyFilter));
}

if (labelFilter == null)
if (string.IsNullOrWhiteSpace(labelFilter))
{
labelFilter = LabelFilter.Null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -316,17 +316,6 @@ await CallWithRequestTracing(async () =>

foreach (var loadOption in _options.KeyValueSelectors)
{
if ((useDefaultQuery && LabelFilter.Null.Equals(loadOption.LabelFilter)) ||
_options.KeyValueSelectors.Any(s => s != loadOption &&
string.Equals(s.KeyFilter, KeyFilter.Any) &&
string.Equals(s.LabelFilter, loadOption.LabelFilter)))
{
// This selection was already encapsulated by a wildcard query
// Or would select kvs obtained by a different selector
// We skip it to prevent unnecessary requests
continue;
}

var selector = new SettingSelector
{
KeyFilter = loadOption.KeyFilter,
Expand Down Expand Up @@ -608,7 +597,7 @@ private async Task SetData(IDictionary<string, ConfigurationSetting> data, bool
{
keyValuePairs = await ProcessAdapters(kvp.Value, cancellationToken).ConfigureAwait(false);
}
catch (KeyVaultReferenceException)
catch (Exception e) when (e is KeyVaultReferenceException || e is FormatException)
{
if (!ignoreFailures)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
//
using Azure;
using Azure.Data.AppConfiguration;
using Azure.Security.KeyVault.Secrets;
using System;
using System.Collections.Generic;
using System.Linq;
Expand Down Expand Up @@ -41,7 +42,7 @@ public async Task<IEnumerable<KeyValuePair<string, string>>> ProcessKeyValue(Con
}

// Uri validation
if (string.IsNullOrEmpty(secretRef.Uri) || !Uri.TryCreate(secretRef.Uri, UriKind.Absolute, out Uri secretUri) || secretUri.Segments.Length < 3)
if (string.IsNullOrEmpty(secretRef.Uri) || !Uri.TryCreate(secretRef.Uri, UriKind.Absolute, out Uri secretUri) || !KeyVaultSecretIdentifier.TryCreate(secretUri, out KeyVaultSecretIdentifier secretIdentifier))
{
throw CreateKeyVaultReferenceException("Invalid Key vault secret identifier", setting, null, secretRef);
}
Expand All @@ -50,7 +51,7 @@ public async Task<IEnumerable<KeyValuePair<string, string>>> ProcessKeyValue(Con

try
{
secret = await _secretProvider.GetSecretValue(secretUri, setting.Key, cancellationToken).ConfigureAwait(false);
secret = await _secretProvider.GetSecretValue(secretIdentifier, setting.Key, cancellationToken).ConfigureAwait(false);
}
catch (Exception e) when (e is UnauthorizedAccessException || (e.Source?.Equals(AzureIdentityAssemblyName, StringComparison.OrdinalIgnoreCase) ?? false))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,8 @@ public AzureKeyVaultSecretProvider(AzureAppConfigurationKeyVaultOptions keyVault
}
}

public async Task<string> GetSecretValue(Uri secretUri, string key, CancellationToken cancellationToken)
public async Task<string> GetSecretValue(KeyVaultSecretIdentifier secretIdentifier, string key, CancellationToken cancellationToken)
{
string secretName = secretUri?.Segments?.ElementAtOrDefault(2)?.TrimEnd('/');
string secretVersion = secretUri?.Segments?.ElementAtOrDefault(3)?.TrimEnd('/');
string secretValue = null;

if (_cachedKeyVaultSecrets.TryGetValue(key, out CachedKeyVaultSecret cachedSecret) &&
Expand All @@ -47,7 +45,7 @@ public async Task<string> GetSecretValue(Uri secretUri, string key, Cancellation
return cachedSecret.SecretValue;
}

SecretClient client = GetSecretClient(secretUri);
SecretClient client = GetSecretClient(secretIdentifier.SourceId);

if (client == null && _keyVaultOptions.SecretResolver == null)
{
Expand All @@ -60,12 +58,12 @@ public async Task<string> GetSecretValue(Uri secretUri, string key, Cancellation
{
if (client != null)
{
KeyVaultSecret secret = await client.GetSecretAsync(secretName, secretVersion, cancellationToken).ConfigureAwait(false);
KeyVaultSecret secret = await client.GetSecretAsync(secretIdentifier.Name, secretIdentifier.Version, cancellationToken).ConfigureAwait(false);
secretValue = secret.Value;
}
else if (_keyVaultOptions.SecretResolver != null)
{
secretValue = await _keyVaultOptions.SecretResolver(secretUri).ConfigureAwait(false);
secretValue = await _keyVaultOptions.SecretResolver(secretIdentifier.SourceId).ConfigureAwait(false);
}

cachedSecret = new CachedKeyVaultSecret(secretValue);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public FeatureFlagOptions Select(string featureFlagFilter, string labelFilter =
throw new ArgumentException(@"Feature flag filter should not end with '\*'.", nameof(featureFlagFilter));
}

if (labelFilter == null)
if (string.IsNullOrWhiteSpace(labelFilter))
{
labelFilter = LabelFilter.Null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
<ItemGroup>
<PackageReference Include="Azure.Data.AppConfiguration" Version="1.2.0" />
<PackageReference Include="Azure.Messaging.EventGrid" Version="4.7.0" />
<PackageReference Include="Azure.Security.KeyVault.Secrets" Version="4.0.1" />
<PackageReference Include="Azure.Security.KeyVault.Secrets" Version="4.3.0" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="3.1.18" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="3.1.18" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="3.1.18" />
<PackageReference Include="System.Text.Json" Version="4.6.0" />
<PackageReference Include="System.Text.Json" Version="4.7.2" />
</ItemGroup>

<PropertyGroup>
Expand All @@ -34,7 +34,7 @@
<!-- Nuget Package Version Settings -->

<PropertyGroup>
<OfficialVersion>5.1.0</OfficialVersion>
<OfficialVersion>5.2.0</OfficialVersion>
</PropertyGroup>

<PropertyGroup Condition="'$(CDP_PATCH_NUMBER)'!='' AND '$(CDP_BUILD_TYPE)'=='Official'">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netcoreapp2.1;netcoreapp3.1;net5.0;net6.0</TargetFrameworks>
<TargetFrameworks>netcoreapp2.1;netcoreapp3.1;net5.0;net6.0;net7.0</TargetFrameworks>
<LangVersion>8.0</LangVersion>
<DelaySign>false</DelaySign>
<SignAssembly>true</SignAssembly>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net5.0;net6.0</TargetFrameworks>
<TargetFrameworks>net5.0;net6.0;net7.0</TargetFrameworks>
<LangVersion>8.0</LangVersion>
<DelaySign>false</DelaySign>
<SignAssembly>true</SignAssembly>
Expand Down
18 changes: 11 additions & 7 deletions tests/Tests.AzureAppConfiguration/FeatureManagementTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -348,10 +348,13 @@ public void SkipRefreshIfCacheNotExpired()
[Fact]
public void PreservesDefaultQuery()
{
var response = new MockResponse(200);
response.SetContent(SerializationHelpers.Serialize(new[] { _kv }, TestHelpers.SerializeBatch));
var mockTransport = new MockTransport(req =>
{
var response = new MockResponse(200);
response.SetContent(SerializationHelpers.Serialize(new[] { _kv }, TestHelpers.SerializeBatch));
return response;
});

var mockTransport = new MockTransport(response);
var clientOptions = new ConfigurationClientOptions
{
Transport = mockTransport
Expand All @@ -364,10 +367,11 @@ public void PreservesDefaultQuery()
options.UseFeatureFlags();
}).Build();

MockRequest request = mockTransport.SingleRequest;
bool performedDefaultQuery = mockTransport.Requests.Any(r => r.Uri.PathAndQuery.Contains("/kv/?key=%2A&label=%00"));
bool queriedFeatureFlags = mockTransport.Requests.Any(r => r.Uri.PathAndQuery.Contains(Uri.EscapeDataString(FeatureManagementConstants.FeatureFlagMarker)));

Assert.Contains("/kv/?key=%252A&label=%2500", Uri.EscapeUriString(request.Uri.PathAndQuery));
Assert.DoesNotContain(Uri.EscapeDataString(FeatureManagementConstants.FeatureFlagMarker), request.Uri.PathAndQuery);
Assert.True(performedDefaultQuery);
Assert.True(queriedFeatureFlags);
}

[Fact]
Expand Down Expand Up @@ -423,7 +427,7 @@ public void UsesEtagForFeatureFlagRefresh()
Thread.Sleep(cacheExpirationTimeSpan);

refresher.TryRefreshAsync().Wait();
mockClient.Verify(c => c.GetConfigurationSettingsAsync(It.IsAny<SettingSelector>(), It.IsAny<CancellationToken>()), Times.Exactly(2));
mockClient.Verify(c => c.GetConfigurationSettingsAsync(It.IsAny<SettingSelector>(), It.IsAny<CancellationToken>()), Times.Exactly(3));
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netcoreapp2.1;netcoreapp3.1;net5.0;net6.0</TargetFrameworks>
<TargetFrameworks>netcoreapp2.1;netcoreapp3.1;net5.0;net6.0;net7.0</TargetFrameworks>
<LangVersion>8.0</LangVersion>
<DelaySign>false</DelaySign>
<SignAssembly>true</SignAssembly>
Expand Down