From 90861a7e93997dff515290c64ce14b3df00f9792 Mon Sep 17 00:00:00 2001 From: Julien Dubois Date: Wed, 25 Aug 2021 21:15:22 +0200 Subject: [PATCH 1/3] Use the correct env variables to detect Azure App Service Fix #27657 --- .../org/springframework/boot/cloud/CloudPlatform.java | 10 ++++++++-- .../springframework/boot/cloud/CloudPlatformTests.java | 4 +++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/cloud/CloudPlatform.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/cloud/CloudPlatform.java index f4402190819c..2b0a600eb790 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/cloud/CloudPlatform.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/cloud/CloudPlatform.java @@ -140,12 +140,18 @@ private boolean isAutoDetected(EnumerablePropertySource environmentPropertySo private static final String WEBSITE_SITE_NAME = "WEBSITE_SITE_NAME"; - private static final String WEBSITES_ENABLE_APP_SERVICE_STORAGE = "WEBSITES_ENABLE_APP_SERVICE_STORAGE"; + private static final String WEBSITE_INSTANCE_ID = "WEBSITE_INSTANCE_ID"; + + private static final String WEBSITE_RESOURCE_GROUP = "WEBSITE_RESOURCE_GROUP"; + + private static final String WEBSITE_SKU = "WEBSITE_SKU"; @Override public boolean isDetected(Environment environment) { return environment.containsProperty(WEBSITE_SITE_NAME) - && environment.containsProperty(WEBSITES_ENABLE_APP_SERVICE_STORAGE); + && environment.containsProperty(WEBSITE_INSTANCE_ID) + && environment.containsProperty(WEBSITE_RESOURCE_GROUP) + && environment.containsProperty(WEBSITE_SKU); } }; diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/cloud/CloudPlatformTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/cloud/CloudPlatformTests.java index 8172589016db..b00ee15c5857 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/cloud/CloudPlatformTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/cloud/CloudPlatformTests.java @@ -136,7 +136,9 @@ void getActiveWhenHasServiceHostAndNoServicePortShouldNotReturnKubernetes() { void getActiveWhenHasWebsiteSiteNameAndWebsitesEnableAppServiceStorageShouldReturnAzureAppService() { Map envVars = new HashMap<>(); envVars.put("WEBSITE_SITE_NAME", "---"); - envVars.put("WEBSITES_ENABLE_APP_SERVICE_STORAGE", "false"); + envVars.put("WEBSITE_INSTANCE_ID", "1234"); + envVars.put("WEBSITE_RESOURCE_GROUP", "test"); + envVars.put("WEBSITE_SKU", "1234"); Environment environment = getEnvironmentWithEnvVariables(envVars); CloudPlatform platform = CloudPlatform.getActive(environment); assertThat(platform).isEqualTo(CloudPlatform.AZURE_APP_SERVICE); From 6c8b58bd644ef581c2ee6d2e4b1c662402b7d333 Mon Sep 17 00:00:00 2001 From: Julien Dubois Date: Thu, 26 Aug 2021 09:01:49 +0200 Subject: [PATCH 2/3] force CI build From 33f4598b2daa9bd69cc33af2f685fedd2150031d Mon Sep 17 00:00:00 2001 From: Julien Dubois Date: Thu, 26 Aug 2021 09:35:07 +0200 Subject: [PATCH 3/3] Fix formatting --- .../java/org/springframework/boot/cloud/CloudPlatform.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/cloud/CloudPlatform.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/cloud/CloudPlatform.java index 2b0a600eb790..ff7b68048781 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/cloud/CloudPlatform.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/cloud/CloudPlatform.java @@ -148,8 +148,7 @@ private boolean isAutoDetected(EnumerablePropertySource environmentPropertySo @Override public boolean isDetected(Environment environment) { - return environment.containsProperty(WEBSITE_SITE_NAME) - && environment.containsProperty(WEBSITE_INSTANCE_ID) + return environment.containsProperty(WEBSITE_SITE_NAME) && environment.containsProperty(WEBSITE_INSTANCE_ID) && environment.containsProperty(WEBSITE_RESOURCE_GROUP) && environment.containsProperty(WEBSITE_SKU); }