Skip to content
Closed
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,7 @@
package org.springframework.boot.cloud;

import org.springframework.boot.context.properties.bind.Binder;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.core.env.EnumerablePropertySource;
import org.springframework.core.env.Environment;
import org.springframework.core.env.PropertySource;
import org.springframework.core.env.StandardEnvironment;
import org.springframework.core.env.*;

/**
* Simple detection for well known cloud platforms. Detection can be forced using the
Expand All @@ -45,6 +41,23 @@ public boolean isDetected(Environment environment) {

},

/**
* Azure App Service platform.
*/
AZURE_APP_SERVICE {

private static final String WEBSITE_SITE_NAME = "WEBSITE_SITE_NAME";

private static final String WEBSITES_ENABLE_APP_SERVICE_STORAGE = "WEBSITES_ENABLE_APP_SERVICE_STORAGE";

@Override
public boolean isDetected(Environment environment) {
return environment.containsProperty(WEBSITE_SITE_NAME)
&& environment.containsProperty(WEBSITES_ENABLE_APP_SERVICE_STORAGE);
}

},

/**
* Cloud Foundry platform.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,17 @@ void getActiveWhenNotInCloudShouldReturnNull() {
Environment environment = new MockEnvironment();
CloudPlatform platform = CloudPlatform.getActive(environment);
assertThat(platform).isNull();
}

@Test
void getActiveWhenHasWebsiteSiteNameShouldReturnAzureAppService() {
Map<String, Object> envVars = new HashMap<>();
envVars.put("WEBSITE_SITE_NAME", "---");
envVars.put("WEBSITES_ENABLE_APP_SERVICE_STORAGE", "false");
Environment environment = getEnvironmentWithEnvVariables(envVars);
CloudPlatform platform = CloudPlatform.getActive(environment);
assertThat(platform).isEqualTo(CloudPlatform.AZURE_APP_SERVICE);
assertThat(platform.isActive(environment)).isTrue();
}

@Test
Expand Down