Skip to content

Fix passwordless JDBC and Redis azure.scopes defaulting to Azure Global when cloud-type=azure_china/azure_us_government#48683

Merged
rujche merged 10 commits intomainfrom
copilot/fix-azure-scopes-for-china-again
Apr 28, 2026
Merged

Fix passwordless JDBC and Redis azure.scopes defaulting to Azure Global when cloud-type=azure_china/azure_us_government#48683
rujche merged 10 commits intomainfrom
copilot/fix-azure-scopes-for-china-again

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 3, 2026

This pull request fixes the defaulting logic for passwordless connection scopes in Azure JDBC and Redis for Spring Cloud Azure, ensuring the correct cloud-specific scopes are used when the cloud type is set to Azure China or Azure US Government. It introduces new methods for determining effective scopes, updates property conversion logic, and adds comprehensive tests to verify correct behavior. The changes also improve the merging of global and resource-specific properties to avoid overwriting explicit user configuration.

Bug Fixes and Scope Resolution Improvements

  • Fixed the logic for defaulting JDBC/Azure Database and Redis passwordless connection scopes so that the correct azure.scopes value is used for Azure China and Azure US Government clouds, based on the merged cloud type. Previously, the wrong scope could be used if the cloud type was set via spring.cloud.azure.profile.cloud-type.
  • Added getEffectiveScopes() methods to both AzureJdbcPasswordlessProperties and AzureRedisPasswordlessProperties, which return the appropriate default scope for the merged cloud type when scopes are not explicitly set. [1] [2]

Property Conversion and Merging

  • Updated the toPasswordlessProperties() method in both JDBC and Redis passwordless properties classes to use the effective, cloud-type-aware scopes instead of the raw value, ensuring correct values are propagated to downstream consumers. [1] [2]
  • Modified the property merging utility to only copy the scopes field if it is explicitly set, preventing accidental overwriting of user-provided values during the merge process.

Testing Enhancements

  • Added and updated unit tests to verify that the correct default scopes are used for Azure China and Azure US Government clouds, that explicit scopes override defaults, and that property merging behaves as expected for both JDBC and Redis passwordless properties. [1] [2]

These changes ensure passwordless authentication works reliably across different Azure environments and that user intent is preserved in configuration.

Copilot AI changed the title [WIP] Fix azure.scopes configuration for Azure China profile Fix azure.scopes defaulting to Azure Global when cloud-type=azure_china/azure_us_government Apr 3, 2026
Copilot AI requested a review from rujche April 3, 2026 07:41
Comment thread sdk/spring/spring-cloud-azure-autoconfigure/CHANGELOG.md Outdated
Copilot AI requested a review from rujche April 3, 2026 08:04
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

Fixes passwordless JDBC azure.scopes resolution so that when spring.cloud.azure.profile.cloud-type is set (e.g., azure_china / azure_us_government) and JDBC-specific scopes aren’t explicitly configured, the effective default scope is derived from the merged cloud type (instead of incorrectly defaulting to Azure Global).

Changes:

  • Update JDBC passwordless properties so getScopes() returns the raw (possibly null) configured value, and add getEffectiveScopes() for cloud-aware defaults; ensure JDBC URL generation uses the effective scopes.
  • Adjust copyAzureCommonPropertiesIgnoreNull to avoid overwriting target scopes when the source scopes are null.
  • Update/add tests for China/US Gov scope behavior and update changelogs.

Reviewed changes

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

Show a summary per file
File Description
sdk/spring/spring-cloud-azure-core/src/main/java/com/azure/spring/cloud/core/implementation/util/AzurePasswordlessPropertiesUtils.java Adds null-guard around copying scopes during passwordless property merge.
sdk/spring/spring-cloud-azure-core/CHANGELOG.md Notes the change in scopes merge behavior.
sdk/spring/spring-cloud-azure-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/implementation/passwordless/properties/AzureJdbcPasswordlessProperties.java Separates raw vs effective scopes and ensures toPasswordlessProperties() uses cloud-aware default scopes.
sdk/spring/spring-cloud-azure-autoconfigure/src/test/java/com/azure/spring/cloud/autoconfigure/implementation/passwordless/MergeAzureCommonPropertiesTest.java Adds merge tests validating JDBC effective scopes behavior.
sdk/spring/spring-cloud-azure-autoconfigure/src/test/java/com/azure/spring/cloud/autoconfigure/implementation/jdbc/JdbcPropertiesBeanPostProcessorTest.java Fixes US Gov expected scope and adds Azure China scenario coverage.
sdk/spring/spring-cloud-azure-autoconfigure/CHANGELOG.md Adds a bug-fix entry for the cloud-type-specific default scopes behavior.

Comment thread sdk/spring/spring-cloud-azure-autoconfigure/CHANGELOG.md Outdated
Comment thread sdk/spring/spring-cloud-azure-core/CHANGELOG.md Outdated
@rujche
Copy link
Copy Markdown
Member

rujche commented Apr 22, 2026

@copilot apply changes based on the comments in this thread

…tant, rename test method

Agent-Logs-Url: https://github.com/Azure/azure-sdk-for-java/sessions/e12bfcb2-e753-484c-9f60-d4bd0aabc999

Co-authored-by: rujche <171773178+rujche@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 22, 2026

@copilot apply changes based on the comments in this thread

Applied all changes from the review thread in cc3ef95:

  • Cached source.getScopes() in a local variable in copyAzureCommonPropertiesIgnoreNull to avoid double-call
  • Renamed testJdbcPropertiesGetCorrectScopeFromGlobalCloudTypetestJdbcPropertiesGetCorrectScopeFromChinaCloudTypeInGlobalProperties
  • Replaced hard-coded "azure.scopes" string with AuthProperty.SCOPES.getPropertyKey() in both test methods

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

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

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

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

Comment thread sdk/spring/CHANGELOG.md Outdated
@rujche
Copy link
Copy Markdown
Member

rujche commented Apr 23, 2026

@copilot apply changes based on the comments in this thread

… pattern; clarify CHANGELOG entry

Agent-Logs-Url: https://github.com/Azure/azure-sdk-for-java/sessions/bdd4ce6e-14e3-4a50-92e0-608069e8c44c

Co-authored-by: rujche <171773178+rujche@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 23, 2026

@copilot apply changes based on the comments in this thread

Applied both changes in 2919235:

  • Updated AzureRedisPasswordlessProperties to align with the JDBC raw/effective scopes pattern: getScopes() now returns the raw field (null when not explicitly set), added getEffectiveScopes() for cloud-type-aware defaults, and overrode toPasswordlessProperties() to use getEffectiveScopes(). This ensures copyAzureCommonPropertiesIgnoreNull won't propagate a computed default scope from the unmerged Redis profile.
  • Updated the CHANGELOG entry to specifically mention JDBC/Azure Database passwordless scope defaulting.

Copilot AI changed the title Fix azure.scopes defaulting to Azure Global when cloud-type=azure_china/azure_us_government Fix passwordless JDBC and Redis azure.scopes defaulting to Azure Global when cloud-type=azure_china/azure_us_government Apr 23, 2026
@rujche rujche requested a review from Copilot April 23, 2026 23:51
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

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

Comment thread sdk/spring/CHANGELOG.md Outdated
@rujche
Copy link
Copy Markdown
Member

rujche commented Apr 24, 2026

@copilot apply changes based on the comments in this thread

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 24, 2026

@copilot apply changes based on the comments in this thread

Applied in 35a158a:

  • Updated the CHANGELOG entry to mention both JDBC/Azure Database and Redis passwordless scope defaulting fix.
  • Added three new Redis tests to MergeAzureCommonPropertiesTest: testRedisPropertiesGetCorrectScopeFromChinaCloudTypeInGlobalProperties, testRedisPropertiesGetCorrectScopeFromUsGovCloudTypeInGlobalProperties, and testRedisPropertiesExplicitScopesOverridesDefault.

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

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

@rujche rujche marked this pull request as ready for review April 24, 2026 01:47
@rujche rujche requested review from a team, Netyyyy, moarychan and saragluna as code owners April 24, 2026 01:47
Copy link
Copy Markdown
Member

@Netyyyy Netyyyy left a comment

Choose a reason for hiding this comment

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

LGTM.

@rujche rujche merged commit ab2626d into main Apr 28, 2026
38 checks passed
@rujche rujche deleted the copilot/fix-azure-scopes-for-china-again branch April 28, 2026 01:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

azure-spring All azure-spring related issues bug This issue requires a change to an existing behavior in the product in order to be resolved.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[BUG] azure.scopes is wrong when set spring.cloud.azure.profile.cloud-type=azure_china

4 participants