private WebAppConfiguration chooseExistingWebappForConfiguration()

in azure-webapp-maven-plugin/src/main/java/com/microsoft/azure/maven/webapp/ConfigMojo.java [468:510]


    private WebAppConfiguration chooseExistingWebappForConfiguration()
            throws AzureAuthFailureException {
        try {
            final AzureAppService az = getOrCreateAzureAppServiceClient();
            if (Objects.isNull(az)) {
                return null;
            }
            // get user selected sub id to persistent it in pom.xml
            this.subscriptionId = az.getDefaultSubscription().getId();
            // load configuration to detecting java or docker
            Log.info(LONG_LOADING_HINT);
            final List<WebAppOption> webAppOptionList = az.webapps().stream()
                    .map(WebAppOption::new).sorted().collect(Collectors.toList());

            // check empty: first time
            if (webAppOptionList.isEmpty()) {
                Log.warn(NO_JAVA_WEB_APPS);
                return null;
            }
            final boolean isContainer = !Utils.isJarPackagingProject(this.project.getPackaging());
            final boolean isDockerOnly = Utils.isPomPackagingProject(this.project.getPackaging());
            final List<WebAppOption> javaOrDockerWebapps = webAppOptionList.stream().filter(app -> app.isJavaWebApp() || app.isDockerWebapp())
                    .filter(app -> checkWebAppVisible(isContainer, isDockerOnly, app.isJavaSE(), app.isDockerWebapp())).sorted()
                    .collect(Collectors.toList());
            final WebAppOption selectedApp = selectAzureWebApp(javaOrDockerWebapps,
                    getWebAppTypeByPackaging(this.project.getPackaging()), az.getDefaultSubscription());
            if (selectedApp == null || selectedApp.isCreateNew()) {
                return null;
            }

            final WebApp webapp = az.webapp(selectedApp.getId());

            final WebAppConfiguration.WebAppConfigurationBuilder<?, ?> builder = WebAppConfiguration.builder();
            if (!AppServiceUtils.isDockerAppService(webapp)) {
                builder.resources(Deployment.getDefaultDeploymentConfiguration(getProject().getPackaging()).getResources());
            }
            return getConfigurationFromExisting(webapp, builder);
        } catch (AzureToolkitAuthenticationException ex) {
            // if is valid for config goal to have error in authentication
            getLog().warn(String.format("Cannot authenticate due to error: %s, select existing webapp is skipped.", ex.getMessage()));
            return null;
        }
    }