protected String initAppId(String appid, AppConfig appConfig) throws IOException {
String appId = super.initAppId(appid, appConfig);
// Overwrite appId if blue-green parameter is defined
try {
BeesClient client = getAppClient(appId);
ConfigurationParametersResponse res = client.configurationParameters(appId, "application");
if (res.getConfiguration() != null) {
ConfigParameters configParameters = ConfigParameters.parse(res.getConfiguration());
ParameterMap parameterMap = configParameters.getParameters();
String param = parameterMap.get("blue-green");
if (param != null) {
ApplicationAlias bgApp = new ApplicationAlias(getAccount(), param);
// Get the current alias if any
ApplicationInfo applicationInfo = client.applicationInfo(appId);
String aliases = applicationInfo.getSettings().get("aliases");
ApplicationAlias currentApp = new ApplicationAlias(getAccount(), appId, aliases);
// If the current app has the alias already, deploy to the other app
if (currentApp.containAliases(bgApp.getAliases())) {