Search in sources :

Example 6 with AppServiceConfig

use of com.microsoft.azure.toolkit.lib.appservice.config.AppServiceConfig in project azure-maven-plugins by microsoft.

the class AppServiceConfigUtils method buildDefaultWebAppConfig.

public static AppServiceConfig buildDefaultWebAppConfig(String subscriptionId, String resourceGroup, String appName, String packaging, JavaVersion javaVersion) {
    final AppServiceConfig appServiceConfig = AppServiceConfig.buildDefaultWebAppConfig(resourceGroup, appName, packaging, javaVersion);
    final List<Region> regions = Azure.az(AzureAppService.class).listSupportedRegions(subscriptionId);
    // replace with first region when the default region is not present
    appServiceConfig.region(Utils.selectFirstOptionIfCurrentInvalid("region", regions, appServiceConfig.region()));
    return appServiceConfig;
}
Also used : AppServiceConfig(com.microsoft.azure.toolkit.lib.appservice.config.AppServiceConfig) AzureAppService(com.microsoft.azure.toolkit.lib.appservice.AzureAppService) Region(com.microsoft.azure.toolkit.lib.common.model.Region)

Example 7 with AppServiceConfig

use of com.microsoft.azure.toolkit.lib.appservice.config.AppServiceConfig in project azure-maven-plugins by microsoft.

the class ConfigMojo method getConfigurationFromExisting.

private WebAppConfiguration getConfigurationFromExisting(IWebApp webapp, WebAppConfiguration.WebAppConfigurationBuilder<?, ?> builder) {
    final AppServiceConfig appServiceConfig = fromAppService(webapp, webapp.plan());
    // common configuration
    builder.appName(appServiceConfig.appName()).resourceGroup(appServiceConfig.resourceGroup()).subscriptionId(appServiceConfig.subscriptionId()).region(appServiceConfig.region());
    builder.os(appServiceConfig.runtime().os());
    if (AppServiceUtils.isDockerAppService(webapp)) {
        final Map<String, String> settings = webapp.entity().getAppSettings();
        builder.image(appServiceConfig.runtime().image());
        builder.registryUrl(appServiceConfig.runtime().registryUrl());
        final String dockerUsernameSetting = settings.get(SETTING_REGISTRY_USERNAME);
        if (StringUtils.isNotBlank(dockerUsernameSetting)) {
            builder.serverId(String.format(SERVER_ID_TEMPLATE, dockerUsernameSetting));
        }
    } else {
        builder.webContainer(Objects.toString(appServiceConfig.runtime().webContainer()));
        builder.javaVersion(Objects.toString(appServiceConfig.runtime().javaVersion()));
    }
    builder.servicePlanName(appServiceConfig.servicePlanName());
    builder.servicePlanResourceGroup(appServiceConfig.servicePlanResourceGroup());
    builder.pricingTier(Objects.toString(appServiceConfig.pricingTier()));
    return builder.build();
}
Also used : AppServiceConfig(com.microsoft.azure.toolkit.lib.appservice.config.AppServiceConfig)

Example 8 with AppServiceConfig

use of com.microsoft.azure.toolkit.lib.appservice.config.AppServiceConfig in project azure-maven-plugins by microsoft.

the class DeployMojo method createOrUpdateResource.

private IWebAppBase<?> createOrUpdateResource() throws AzureExecutionException {
    final boolean skipCreate = skipAzureResourceCreate || skipCreateAzureResource;
    if (!isDeployToDeploymentSlot()) {
        final AppServiceConfig appServiceConfig = getConfigParser().getAppServiceConfig();
        IWebApp app = Azure.az(AzureAppService.class).webapp(appServiceConfig.resourceGroup(), appServiceConfig.appName());
        final boolean newWebApp = !app.exists();
        AppServiceConfig defaultConfig = !newWebApp ? fromAppService(app, app.plan()) : buildDefaultConfig(appServiceConfig.subscriptionId(), appServiceConfig.resourceGroup(), appServiceConfig.appName());
        mergeAppServiceConfig(appServiceConfig, defaultConfig);
        if (appServiceConfig.pricingTier() == null) {
            appServiceConfig.pricingTier(appServiceConfig.runtime().webContainer() == WebContainer.JBOSS_7 ? PricingTier.PREMIUM_P1V3 : PricingTier.PREMIUM_P1V2);
        }
        final CreateOrUpdateWebAppTask task = new CreateOrUpdateWebAppTask(appServiceConfig);
        task.setSkipCreateAzureResource(skipCreate);
        return task.execute();
    } else {
        // todo: New CreateOrUpdateDeploymentSlotTask
        final DeploymentSlotConfig config = getConfigParser().getDeploymentSlotConfig();
        final IWebAppDeploymentSlot slot = getDeploymentSlot(config);
        final boolean slotExists = slot.exists();
        if (!slotExists && skipCreate) {
            throwForbidCreateResourceWarning("Deployment slot", config.getName());
        }
        return slotExists ? updateDeploymentSlot(slot, config) : createDeploymentSlot(slot, config);
    }
}
Also used : CreateOrUpdateWebAppTask(com.microsoft.azure.toolkit.lib.appservice.task.CreateOrUpdateWebAppTask) DeploymentSlotConfig(com.microsoft.azure.maven.webapp.configuration.DeploymentSlotConfig) AppServiceConfig(com.microsoft.azure.toolkit.lib.appservice.config.AppServiceConfig) AppServiceConfigUtils.mergeAppServiceConfig(com.microsoft.azure.toolkit.lib.appservice.utils.AppServiceConfigUtils.mergeAppServiceConfig) AzureAppService(com.microsoft.azure.toolkit.lib.appservice.AzureAppService) IWebAppDeploymentSlot(com.microsoft.azure.toolkit.lib.appservice.service.IWebAppDeploymentSlot) IWebApp(com.microsoft.azure.toolkit.lib.appservice.service.IWebApp)

Aggregations

AppServiceConfig (com.microsoft.azure.toolkit.lib.appservice.config.AppServiceConfig)8 AzureAppService (com.microsoft.azure.toolkit.lib.appservice.AzureAppService)4 AppServiceConfigUtils.mergeAppServiceConfig (com.microsoft.azure.toolkit.lib.appservice.utils.AppServiceConfigUtils.mergeAppServiceConfig)4 Region (com.microsoft.azure.toolkit.lib.common.model.Region)3 RuntimeConfig (com.microsoft.azure.toolkit.lib.appservice.config.RuntimeConfig)2 CreateOrUpdateFunctionAppTask (com.microsoft.azure.toolkit.lib.appservice.task.CreateOrUpdateFunctionAppTask)2 CreateOrUpdateWebAppTask (com.microsoft.azure.toolkit.lib.appservice.task.CreateOrUpdateWebAppTask)2 AzureEnvironment (com.azure.core.management.AzureEnvironment)1 Preconditions (com.google.common.base.Preconditions)1 AuthorizationLevel (com.microsoft.azure.functions.annotation.AuthorizationLevel)1 GradleRuntimeConfig (com.microsoft.azure.gradle.configuration.GradleRuntimeConfig)1 TelemetryAgent (com.microsoft.azure.gradle.temeletry.TelemetryAgent)1 DeploymentSlotConfig (com.microsoft.azure.maven.webapp.configuration.DeploymentSlotConfig)1 GradleFunctionContext (com.microsoft.azure.plugin.functions.gradle.GradleFunctionContext)1 Azure (com.microsoft.azure.toolkit.lib.Azure)1 FunctionAppConfig (com.microsoft.azure.toolkit.lib.appservice.config.FunctionAppConfig)1 FunctionEntity (com.microsoft.azure.toolkit.lib.appservice.entity.FunctionEntity)1 FunctionApp (com.microsoft.azure.toolkit.lib.appservice.function.FunctionApp)1 FunctionAppBase (com.microsoft.azure.toolkit.lib.appservice.function.FunctionAppBase)1 FunctionDeployType (com.microsoft.azure.toolkit.lib.appservice.model.FunctionDeployType)1