Skip to content

Let parent config AKV settings propagate to child configs#3323

Open
aaronburtle wants to merge 3 commits intomainfrom
dev/aaronburtle/fix-child-config-akv-options-3271
Open

Let parent config AKV settings propagate to child configs#3323
aaronburtle wants to merge 3 commits intomainfrom
dev/aaronburtle/fix-child-config-akv-options-3271

Conversation

@aaronburtle
Copy link
Copy Markdown
Contributor

@aaronburtle aaronburtle commented Mar 26, 2026

Why make this change?

When a parent config has azure-key-vault configured, child configs referenced via data-source-files were unable to resolve @akv('...') references because the parent's AKV options were not passed during child config deserialization.

What is this change?

  • Pass the parent config's AzureKeyVault options into DeserializationVariableReplacementSettings when loading each child config, enabling @akv('...') references in child configs to be resolved using the parent's Key Vault configuration.
  • The DeserializationVariableReplacementSettings object is created once before the child config foreach loop and reused for all child configs, avoiding redundant Key Vault client initialization or secrets file reads per iteration.

How was this tested?

  • Integration Tests
  • Unit Tests

Regression test added (ChildConfigResolvesAkvReferencesFromParentAkvOptions) that loads a parent config referencing a local .akv secrets file and a child config with an @akv() connection string, validating the connection string is correctly resolved without requiring a real Azure Key Vault.

When loading child data-source-files, the parent's AzureKeyVault options
were not passed to the DeserializationVariableReplacementSettings, causing
@akv() references in child configs to go unresolved.

Fix: pass this.AzureKeyVault instead of null so child configs inherit the
parent's Key Vault configuration for secret resolution.

Regression test uses a local .akv file to verify end-to-end resolution.

Fixes part of #3271
Copilot AI review requested due to automatic review settings March 26, 2026 09:16
@aaronburtle aaronburtle self-assigned this Mar 26, 2026
@aaronburtle aaronburtle added 2.1 bug Something isn't working labels Mar 26, 2026
@aaronburtle aaronburtle moved this from Todo to Review In Progress in Data API builder Mar 26, 2026
@aaronburtle aaronburtle added this to the April 2026 milestone Mar 26, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Propagates the parent runtime config’s Azure Key Vault (AKV) options when deserializing child configs in multi–data source scenarios, so @akv('...') replacements in child files can succeed (fix for issue #3322).

Changes:

  • Pass parent AzureKeyVault options into DeserializationVariableReplacementSettings when loading each child config.
  • Add a regression test that loads a parent config referencing a local .akv secrets file and a child config with an @akv() connection string.

Reviewed changes

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

File Description
src/Config/ObjectModel/RuntimeConfig.cs Use parent AKV options when creating replacement settings for child config loading.
src/Service.Tests/Configuration/RuntimeConfigLoaderTests.cs Add regression test validating child @akv() resolution via parent AKV options using a local .akv file.

@aaronburtle
Copy link
Copy Markdown
Contributor Author

@copilot can you review this again please

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 26, 2026

@copilot can you review this again please

Both issues from the prior review were already addressed in commit 28f3245:

  1. The test's issue link now correctly references [Bug]: Parent config AKV settings do not propagate to child configs #3322 (not [Bug]: missing OTEL environment variables in multi-config fails. #3271).
  2. DeserializationVariableReplacementSettings is created once before the foreach loop, so the AKV client/secrets file is only initialized once regardless of how many child configs are loaded.

The changes look good to me.


// Pass the parent's AKV options so @akv() references in child configs can
// be resolved using the parent's Key Vault configuration.
DeserializationVariableReplacementSettings replacementSettings = new(azureKeyVaultOptions: this.AzureKeyVault, doReplaceEnvVar: true, doReplaceAkvVar: true);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Are we sure if the child config has its own AKV options, those will override the ones passed onto by the parent?

// Verify the child's connection string was resolved from the .akv file.
string childDataSourceName = runtimeConfig.GetDataSourceNameFromEntityName("AkvChildEntity");
DataSource childDataSource = runtimeConfig.GetDataSourceFromDataSourceName(childDataSourceName);
Assert.IsTrue(
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Can we also verify in a different case that the child AKV settings override the ones passed onto by the parent?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2.1 bug Something isn't working

Projects

Status: Review In Progress

Development

Successfully merging this pull request may close these issues.

4 participants