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
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,7 @@ BicepValue<string> GetHostValue(string? prefix = null, string? suffix = null)
return (AllocateParameter(secretOutputReference, secretType: SecretType.KeyVault), SecretType.KeyVault);
}

if (value is IKeyVaultSecretReference vaultSecretReference)
if (value is IAzureKeyVaultSecretReference vaultSecretReference)
{
if (parent is null)
{
Expand Down Expand Up @@ -797,7 +797,7 @@ private BicepValue<string> AllocateKeyVaultSecretUriReference(BicepSecretOutputR
return secret.Properties.SecretUri;
}

private BicepValue<string> AllocateKeyVaultSecretUriReference(IKeyVaultSecretReference secretOutputReference)
private BicepValue<string> AllocateKeyVaultSecretUriReference(IAzureKeyVaultSecretReference secretOutputReference)
{
if (!KeyVaultRefs.TryGetValue(secretOutputReference.Resource.Name, out var kv))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ public static IResourceBuilder<AzureCosmosDBResource> WithAccessKeyAuthenticatio
/// <param name="builder">The Azure Cosmos DB resource builder.</param>
/// <param name="keyVaultBuilder">The Azure Key Vault resource builder where the connection string used to connect to this AzureCosmosDBResource will be stored.</param>
/// <returns>A reference to the <see cref="IResourceBuilder{T}"/> builder.</returns>
public static IResourceBuilder<AzureCosmosDBResource> WithAccessKeyAuthentication(this IResourceBuilder<AzureCosmosDBResource> builder, IResourceBuilder<IKeyVaultResource> keyVaultBuilder)
public static IResourceBuilder<AzureCosmosDBResource> WithAccessKeyAuthentication(this IResourceBuilder<AzureCosmosDBResource> builder, IResourceBuilder<IAzureKeyVaultResource> keyVaultBuilder)
{
ArgumentNullException.ThrowIfNull(builder);

Expand Down
2 changes: 1 addition & 1 deletion src/Aspire.Hosting.Azure.CosmosDB/AzureCosmosDBResource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class AzureCosmosDBResource(string name, Action<AzureResourceInfrastructu
///
/// This is set when access key authentication is used. The connection string is stored in a secret in the Azure Key Vault.
/// </summary>
internal IKeyVaultSecretReference? ConnectionStringSecretOutput { get; set; }
internal IAzureKeyVaultSecretReference? ConnectionStringSecretOutput { get; set; }

private BicepOutputReference NameOutputReference => new("name", this);

Expand Down
10 changes: 5 additions & 5 deletions src/Aspire.Hosting.Azure.KeyVault/AzureKeyVaultResource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace Aspire.Hosting.Azure;
/// <param name="name">The name of the resource.</param>
/// <param name="configureInfrastructure">Callback to configure the Azure resources.</param>
public class AzureKeyVaultResource(string name, Action<AzureResourceInfrastructure> configureInfrastructure)
: AzureProvisioningResource(name, configureInfrastructure), IResourceWithConnectionString, IKeyVaultResource
: AzureProvisioningResource(name, configureInfrastructure), IResourceWithConnectionString, IAzureKeyVaultResource
{
/// <summary>
/// Gets the "vaultUri" output reference for the Azure Key Vault resource.
Expand All @@ -31,12 +31,12 @@ public class AzureKeyVaultResource(string name, Action<AzureResourceInfrastructu
public ReferenceExpression ConnectionStringExpression =>
ReferenceExpression.Create($"{VaultUri}");

BicepOutputReference IKeyVaultResource.VaultUriOutputReference => VaultUri;
BicepOutputReference IAzureKeyVaultResource.VaultUriOutputReference => VaultUri;

// In run mode, this is set to the secret client used to access the Azure Key Vault.
internal Func<IKeyVaultSecretReference, CancellationToken, Task<string?>>? SecretResolver { get; set; }
internal Func<IAzureKeyVaultSecretReference, CancellationToken, Task<string?>>? SecretResolver { get; set; }

Func<IKeyVaultSecretReference, CancellationToken, Task<string?>>? IKeyVaultResource.SecretResolver
Func<IAzureKeyVaultSecretReference, CancellationToken, Task<string?>>? IAzureKeyVaultResource.SecretResolver
{
get => SecretResolver;
set => SecretResolver = value;
Expand All @@ -48,7 +48,7 @@ public class AzureKeyVaultResource(string name, Action<AzureResourceInfrastructu
/// <param name="secretName"></param>
/// <returns></returns>
/// <exception cref="ArgumentException"></exception>
public IKeyVaultSecretReference GetSecretReference(string secretName)
public IAzureKeyVaultSecretReference GetSecretReference(string secretName)
{
ArgumentException.ThrowIfNullOrEmpty(secretName, nameof(secretName));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace Aspire.Hosting.Azure;
/// </summary>
/// <param name="secretName">The name of the secret.</param>
/// <param name="azureKeyVaultResource">The Azure Key Vault resource.</param>
internal sealed class AzureKeyVaultSecretReference(string secretName, AzureKeyVaultResource azureKeyVaultResource) : IKeyVaultSecretReference, IValueProvider, IManifestExpressionProvider
internal sealed class AzureKeyVaultSecretReference(string secretName, AzureKeyVaultResource azureKeyVaultResource) : IAzureKeyVaultSecretReference, IValueProvider, IManifestExpressionProvider
{
/// <summary>
/// Gets the name of the secret.
Expand All @@ -20,7 +20,7 @@ internal sealed class AzureKeyVaultSecretReference(string secretName, AzureKeyVa
/// <summary>
/// Gets the Azure Key Vault resource.
/// </summary>
public IKeyVaultResource Resource => azureKeyVaultResource;
public IAzureKeyVaultResource Resource => azureKeyVaultResource;

string IManifestExpressionProvider.ValueExpression => $"{{{azureKeyVaultResource.Name}.secrets.{SecretName}}}";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public static IResourceBuilder<PostgresServerResource> AsAzurePostgresFlexibleSe
/// This requires changes to the application code to use an azure credential to authenticate with the resource. See
/// https://learn.microsoft.com/azure/postgresql/flexible-server/how-to-connect-with-managed-identity#connect-using-managed-identity-in-c for more information.
///
/// You can use the <see cref="WithPasswordAuthentication(IResourceBuilder{AzurePostgresFlexibleServerResource}, IResourceBuilder{IKeyVaultResource}, IResourceBuilder{ParameterResource}?, IResourceBuilder{ParameterResource}?)"/> method to configure the resource to use password authentication.
/// You can use the <see cref="WithPasswordAuthentication(IResourceBuilder{AzurePostgresFlexibleServerResource}, IResourceBuilder{IAzureKeyVaultResource}, IResourceBuilder{ParameterResource}?, IResourceBuilder{ParameterResource}?)"/> method to configure the resource to use password authentication.
/// </remarks>
/// <example>
/// The following example creates an Azure PostgreSQL Flexible Server resource and referencing that resource in a .NET project.
Expand Down Expand Up @@ -317,7 +317,7 @@ public static IResourceBuilder<AzurePostgresFlexibleServerResource> WithPassword
/// <returns>A reference to the <see cref="IResourceBuilder{T}"/> builder.</returns>
public static IResourceBuilder<AzurePostgresFlexibleServerResource> WithPasswordAuthentication(
this IResourceBuilder<AzurePostgresFlexibleServerResource> builder,
IResourceBuilder<IKeyVaultResource> keyVaultBuilder,
IResourceBuilder<IAzureKeyVaultResource> keyVaultBuilder,
IResourceBuilder<ParameterResource>? userName = null,
IResourceBuilder<ParameterResource>? password = null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class AzurePostgresFlexibleServerResource(string name, Action<AzureResour
///
/// This is set when password authentication is used. The connection string is stored in a secret in the Azure Key Vault.
/// </summary>
internal IKeyVaultSecretReference? ConnectionStringSecretOutput { get; set; }
internal IAzureKeyVaultSecretReference? ConnectionStringSecretOutput { get; set; }

private BicepOutputReference NameOutputReference => new("name", this);

Expand Down
2 changes: 1 addition & 1 deletion src/Aspire.Hosting.Azure.Redis/AzureRedisCacheResource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class AzureRedisCacheResource(string name, Action<AzureResourceInfrastruc
///
/// This is set when access key authentication is used. The connection string is stored in a secret in the Azure Key Vault.
/// </summary>
internal IKeyVaultSecretReference? ConnectionStringSecretOutput { get; set; }
internal IAzureKeyVaultSecretReference? ConnectionStringSecretOutput { get; set; }

private BicepOutputReference NameOutputReference => new("name", this);

Expand Down
4 changes: 2 additions & 2 deletions src/Aspire.Hosting.Azure.Redis/AzureRedisExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public static IResourceBuilder<RedisResource> AsAzureRedis(this IResourceBuilder
/// This requires changes to the application code to use an azure credential to authenticate with the resource. See
/// https://github.com/Azure/Microsoft.Azure.StackExchangeRedis for more information.
///
/// You can use the <see cref="WithAccessKeyAuthentication(IResourceBuilder{AzureRedisCacheResource}, IResourceBuilder{IKeyVaultResource})"/> method to configure the resource to use access key authentication.
/// You can use the <see cref="WithAccessKeyAuthentication(IResourceBuilder{AzureRedisCacheResource}, IResourceBuilder{IAzureKeyVaultResource})"/> method to configure the resource to use access key authentication.
/// </remarks>
/// <example>
/// The following example creates an Azure Cache for Redis resource and referencing that resource in a .NET project.
Expand Down Expand Up @@ -218,7 +218,7 @@ public static IResourceBuilder<AzureRedisCacheResource> WithAccessKeyAuthenticat
/// <param name="builder">The Azure Cache for Redis resource builder.</param>
/// <param name="keyVaultBuilder">The Azure Key Vault resource builder where the connection string used to connect to this AzureRedisCacheResource will be stored.</param>
/// <returns>A reference to the <see cref="IResourceBuilder{T}"/> builder.</returns>
public static IResourceBuilder<AzureRedisCacheResource> WithAccessKeyAuthentication(this IResourceBuilder<AzureRedisCacheResource> builder, IResourceBuilder<IKeyVaultResource> keyVaultBuilder)
public static IResourceBuilder<AzureRedisCacheResource> WithAccessKeyAuthentication(this IResourceBuilder<AzureRedisCacheResource> builder, IResourceBuilder<IAzureKeyVaultResource> keyVaultBuilder)
{
ArgumentNullException.ThrowIfNull(builder);
ArgumentNullException.ThrowIfNull(keyVaultBuilder);
Expand Down
2 changes: 1 addition & 1 deletion src/Aspire.Hosting.Azure/AzureResourcePreparer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ private static void ProcessAzureReferences(HashSet<IAzureResource> azureReferenc
return;
}

if (value is IKeyVaultSecretReference keyVaultSecretReference)
if (value is IAzureKeyVaultSecretReference keyVaultSecretReference)
{
azureReferences.Add(keyVaultSecretReference.Resource);
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Aspire.Hosting.Azure;
/// <summary>
/// Represents a resource that represents an Azure Key Vault.
/// </summary>
public interface IKeyVaultResource : IResource, IAzureResource
public interface IAzureKeyVaultResource : IResource, IAzureResource
{
/// <summary>
/// Gets the output reference that represents the vault uri for the Azure Key Vault resource.
Expand All @@ -23,12 +23,12 @@ public interface IKeyVaultResource : IResource, IAzureResource
/// <summary>
/// Gets or sets the secret resolver function used to resolve secrets at runtime.
/// </summary>
Func<IKeyVaultSecretReference, CancellationToken, Task<string?>>? SecretResolver { get; set; }
Func<IAzureKeyVaultSecretReference, CancellationToken, Task<string?>>? SecretResolver { get; set; }

/// <summary>
/// Gets a secret reference for the specified secret name.
/// </summary>
/// <param name="secretName">The name of the secret.</param>
/// <returns>A reference to the secret.</returns>
IKeyVaultSecretReference GetSecretReference(string secretName);
IAzureKeyVaultSecretReference GetSecretReference(string secretName);
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Aspire.Hosting.Azure;
/// <summary>
/// Represents a reference to a secret in an Azure Key Vault resource.
/// </summary>
public interface IKeyVaultSecretReference : IValueProvider, IManifestExpressionProvider
public interface IAzureKeyVaultSecretReference : IValueProvider, IManifestExpressionProvider
{
/// <summary>
/// Gets the name of the secret.
Expand All @@ -18,5 +18,5 @@ public interface IKeyVaultSecretReference : IValueProvider, IManifestExpressionP
/// <summary>
/// Gets the Azure Key Vault resource.
/// </summary>
IKeyVaultResource Resource { get; }
}
IAzureKeyVaultResource Resource { get; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ await notificationService.PublishUpdateAsync(resource, state =>
}

// Populate secret outputs from key vault (if any)
if (resource is IKeyVaultResource kvr)
if (resource is IAzureKeyVaultResource kvr)
{
var vaultUri = resource.Outputs[kvr.VaultUriOutputReference.Name] as string ?? throw new InvalidOperationException($"{kvr.VaultUriOutputReference.Name} not found in outputs.");

Expand Down
Loading