Skip to content

Davidfowl/fix emulators - #8406

Merged
Eric Erhardt (eerhardt) merged 6 commits into
mainfrom
davidfowl/fix-emulators
Apr 2, 2025
Merged

Davidfowl/fix emulators#8406
Eric Erhardt (eerhardt) merged 6 commits into
mainfrom
davidfowl/fix-emulators

Conversation

@davidfowl

@davidfowlDavid Fowler (davidfowl) commented Mar 29, 2025

Copy link
Copy Markdown
Collaborator

Description

Don't add the keyvault if the resource is a container.

Fixes#8364

- Pass the IKeyVaultSecretReference to the SecretResolver
- Don't add the default keyvault when using the emulator.
@github-actionsgithub-actionsBot added the area-app-model Issues pertaining to the APIs in Aspire.Hosting, e.g. DistributedApplication label Mar 29, 2025
@davidfowlDavid Fowler (davidfowl) added area-integrations Issues pertaining to Aspire Integrations packages azure-keyvault azure-cosmosdb Issues related to Azure CosmosDB and removed area-app-model Issues pertaining to the APIs in Aspire.Hosting, e.g. DistributedApplication labels Mar 29, 2025
@eerhardt
Eric Erhardt (eerhardt) marked this pull request as ready for review April 2, 2025 00:15
CopilotAI review requested due to automatic review settings April 2, 2025 00:15
@eerhardt

Copy link
Copy Markdown
Member

David Fowler (@davidfowl) - I think this is ready for review.

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes the issue where a KeyVault resource is added in scenarios when the resource is either running as a container (for Redis and Postgres) or as an emulator (for CosmosDB). The changes update both test coverage and resource provisioning logic to conditionally remove the KeyVault resource based on the runtime mode and authentication type.

Reviewed Changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated no comments.

Show a summary per file
FileDescription
tests/Aspire.Hosting.Azure.Tests/AzureRedisExtensionsTests.csAdded test to verify that KeyVault is not included when running Redis as a container.
tests/Aspire.Hosting.Azure.Tests/AzurePostgresExtensionsTests.csAdded test to verify that KeyVault is not included when running Postgres as a container.
tests/Aspire.Hosting.Azure.Tests/AzureCosmosDBExtensionsTests.csUpdated tests to validate KeyVault behavior for CosmosDB in both access key and emulator scenarios.
tests/Aspire.Hosting.Azure.Tests/AzureBicepResourceTests.csAdded tests and updated secret resolver usage to support the new signature.
src/Aspire.Hosting.Azure/Provisioning/Provisioners/BicepProvisioner.csModified the secret resolver lambda to use IKeyVaultSecretReference.
src/Aspire.Hosting.Azure/IKeyVaultResource.csUpdated the interface signature for SecretResolver to accept IKeyVaultSecretReference.
src/Aspire.Hosting.Azure.Redis/AzureRedisExtensions.csAdded an event subscription to remove the KeyVault when running in container mode.
src/Aspire.Hosting.Azure.PostgreSQL/AzurePostgresExtensions.csAdded an analogous event subscription for Postgres to remove the KeyVault when appropriate.
src/Aspire.Hosting.Azure.KeyVault/AzureKeyVaultSecretReference.csChanged the secret resolver invocation to pass the secret reference instead of just the secret name.
src/Aspire.Hosting.Azure.KeyVault/AzureKeyVaultResource.csUpdated the internal handling of SecretResolver to reflect the new delegate signature.
src/Aspire.Hosting.Azure.CosmosDB/AzureCosmosDBResource.csAltered the connection string generation to bypass secret references when running as an emulator.
src/Aspire.Hosting.Azure.CosmosDB/AzureCosmosDBExtensions.csUpdated event subscription to remove the KeyVault resource when the resource is in emulator mode.

Comment threadsrc/Aspire.Hosting.Azure.CosmosDB/AzureCosmosDBResource.cs
Comment threadsrc/Aspire.Hosting.Azure.CosmosDB/AzureCosmosDBExtensions.cs Outdated
@eerhardt
Eric Erhardt (eerhardt) deleted the davidfowl/fix-emulators branch April 2, 2025 15:25
@eerhardt

Copy link
Copy Markdown
Member

/backport to release/9.2

@github-actions

Copy link
Copy Markdown
Contributor

Started backporting to release/9.2: https://github.com/dotnet/aspire/actions/runs/14223464886

Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-integrationsIssues pertaining to Aspire Integrations packagesazure-cosmosdbIssues related to Azure CosmosDBazure-keyvault

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cosmos, Redis and Postgres show keyvault when using key access or passwords with emulator

5 participants

@davidfowl@eerhardt@sebastienros@captainsafia