Fix Azure scopes defaulting to Global when cloud-type is Azure China #47165
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When
spring.cloud.azure.profile.cloud-type=azure_chinais set globally but scopes are not explicitly configured for JDBC/Redis passwordless connections, the scopes incorrectly default to Azure Global (https://ossrdbms-aad.database.windows.net/.default) instead of Azure China (https://ossrdbms-aad.database.chinacloudapi.cn/.default).Root Cause
AzurePasswordlessPropertiesUtils.copyAzureCommonPropertiesIgnoreNull()unconditionally copies scopes by callingsource.getScopes(). For implementations likeAzureJdbcPasswordlessProperties, this returns a computed default based on cloud type. During property merging:cloud-type=AZURE_CHINA) are copied to targetcopyAzureCommonPropertiesIgnoreNull()source.getScopes()computes default using source's unset cloud type → returns Azure Global scopeChanges
Modified scope copying logic in
AzurePasswordlessPropertiesUtils:Added tests:
JdbcPropertiesBeanPostProcessorTestFixes #43195
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
login.microsoftonline.comoss.jfrog.org/usr/lib/jvm/temurin-17-jdk-amd64/bin/java --enable-native-access=ALL-UNNAMED -classpath /usr/share/apache-maven-3.9.11/boot/plexus-classworlds-2.9.0.jar -Dclassworlds.conf=/usr/share/apache-maven-3.9.11/bin/m2.conf -Dmaven.home=/usr/share/apache-maven-3.9.11 -Dlibrary.jansi.path=/usr/share/apache-maven-3.9.11/lib/jansi-native -Dmaven.multiModuleProjectDirectory=/home/REDACTED/work/azure-sdk-for-java/azure-sdk-for-java/sdk/spring/spring-cloud-azure-autoconfigure org.codehaus.plexus.classworlds.launcher.Launcher clean test -Dtest=JdbcPropertiesBeanPostProcessorTest(dns block)sample-propertysource.vault.azure.net/usr/lib/jvm/temurin-17-jdk-amd64/bin/java -javaagent:/home/REDACTED/.m2/repository/org/jacoco/org.jacoco.agent/0.8.13/org.jacoco.agent-0.8.13-runtime.jar=destfile=/home/REDACTED/work/azure-sdk-for-java/azure-sdk-for-java/sdk/spring/spring-cloud-azure-autoconfigure/target/jacoco-unit.exec,excludes=META-INF/** -Xmx4096m -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/home/REDACTED/work/azure-sdk-for-java/azure-sdk-for-java/sdk/spring/spring-cloud-azure-autoconfigure/target/spring-cloud-azure-autoconfigure-oom.hprof -XX:+CrashOnOutOfMemoryError --add-opens java.base/java.lang.invoke=com.azure.core org.apache.maven.surefire.booter.ForkedBooter /home/REDACTED/work/azure-sdk-for-java/azure-sdk-for-java/sdk/spring/spring-cloud-azure-autoconfigure/target/surefire 2025-11-05T09-17-25_166-jvmRun1 surefire-20251105091725250_1tmp surefire_0-20251105091725250_2tmp(dns block)sample.servicebus.windows.netsample.somelocation.eventgrid.azure.net/usr/lib/jvm/temurin-17-jdk-amd64/bin/java -javaagent:/home/REDACTED/.m2/repository/org/jacoco/org.jacoco.agent/0.8.13/org.jacoco.agent-0.8.13-runtime.jar=destfile=/home/REDACTED/work/azure-sdk-for-java/azure-sdk-for-java/sdk/spring/spring-cloud-azure-autoconfigure/target/jacoco-unit.exec,excludes=META-INF/** -Xmx4096m -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/home/REDACTED/work/azure-sdk-for-java/azure-sdk-for-java/sdk/spring/spring-cloud-azure-autoconfigure/target/spring-cloud-azure-autoconfigure-oom.hprof -XX:+CrashOnOutOfMemoryError --add-opens java.base/java.lang.invoke=com.azure.core org.apache.maven.surefire.booter.ForkedBooter /home/REDACTED/work/azure-sdk-for-java/azure-sdk-for-java/sdk/spring/spring-cloud-azure-autoconfigure/target/surefire 2025-11-05T09-17-25_166-jvmRun1 surefire-20251105091725250_1tmp surefire_0-20251105091725250_2tmp(dns block)sample.vault.azure.net/usr/lib/jvm/temurin-17-jdk-amd64/bin/java -javaagent:/home/REDACTED/.m2/repository/org/jacoco/org.jacoco.agent/0.8.13/org.jacoco.agent-0.8.13-runtime.jar=destfile=/home/REDACTED/work/azure-sdk-for-java/azure-sdk-for-java/sdk/spring/spring-cloud-azure-autoconfigure/target/jacoco-unit.exec,excludes=META-INF/** -Xmx4096m -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/home/REDACTED/work/azure-sdk-for-java/azure-sdk-for-java/sdk/spring/spring-cloud-azure-autoconfigure/target/spring-cloud-azure-autoconfigure-oom.hprof -XX:+CrashOnOutOfMemoryError --add-opens java.base/java.lang.invoke=com.azure.core org.apache.maven.surefire.booter.ForkedBooter /home/REDACTED/work/azure-sdk-for-java/azure-sdk-for-java/sdk/spring/spring-cloud-azure-autoconfigure/target/surefire 2025-11-05T09-17-25_166-jvmRun1 surefire-20251105091725250_1tmp surefire_0-20251105091725250_2tmp(dns block)test-namespace.servicebus.windows.netIf you need me to access, download, or install something from one of these locations, you can either:
Original prompt
This section details on the original issue you should resolve
<issue_title>[BUG]
azure.scopesis wrong when setspring.cloud.azure.profile.cloud-type=azure_china</issue_title><issue_description>Describe the bug
When use the passwordless feature of PostgreSQL, the
azure.scopesishttps://ossrdbms-aad.database.windows.net/.defaultwhen setspring.cloud.azure.profile.cloud-type=azure_china. Thehttps://ossrdbms-aad.database.windows.net/.defaultis for Azure Global, not for Azure ChinaException or Stack Trace