Search in sources :

Example 1 with GradleWebAppConfig

use of com.microsoft.azure.gradle.configuration.GradleWebAppConfig in project azure-gradle-plugins by microsoft.

the class DeployTask method parseConfiguration.

private GradleWebAppConfig parseConfiguration() {
    final AzureWebappPluginExtension ctx = this.azureWebappExtension;
    GradleWebAppConfig config = new GradleWebAppConfig();
    config.subscriptionId(ctx.getSubscription());
    config.resourceGroup(ctx.getResourceGroup());
    config.appName(ctx.getAppName());
    config.pricingTier(ctx.getPricingTier());
    config.region(ctx.getRegion());
    config.runtime(ctx.getRuntime());
    config.appSettings(ctx.getAppSettings());
    config.servicePlanName(ctx.getAppServicePlanName());
    config.servicePlanResourceGroup(ctx.getAppServicePlanResourceGroup());
    config.deploymentSlotName(Optional.ofNullable(ctx.getDeploymentSlot()).map(GradleDeploymentSlotConfig::name).orElse(null));
    config.deploymentSlotConfigurationSource(Optional.ofNullable(ctx.getDeploymentSlot()).map(GradleDeploymentSlotConfig::configurationSource).orElse(null));
    if (StringUtils.isNotBlank(this.artifactFile)) {
        File file = new File(this.artifactFile);
        if (!file.exists()) {
            throw new AzureToolkitRuntimeException(String.format("artifact file(%s) cannot be found.", file.getAbsolutePath()));
        }
        final WebAppArtifact webAppArtifact = WebAppArtifact.builder().deployType(Utils.getDeployTypeByFileExtension(file)).file(file).build();
        config.webAppArtifacts(Collections.singletonList(webAppArtifact));
    }
    return config;
}
Also used : GradleDeploymentSlotConfig(com.microsoft.azure.gradle.configuration.GradleDeploymentSlotConfig) GradleWebAppConfig(com.microsoft.azure.gradle.configuration.GradleWebAppConfig) AzureToolkitRuntimeException(com.microsoft.azure.toolkit.lib.common.exception.AzureToolkitRuntimeException) File(java.io.File) WebAppArtifact(com.microsoft.azure.toolkit.lib.appservice.model.WebAppArtifact)

Example 2 with GradleWebAppConfig

use of com.microsoft.azure.gradle.configuration.GradleWebAppConfig in project azure-gradle-plugins by microsoft.

the class DeployTask method deploy.

@TaskAction
@AzureOperation(name = "webapp.deploy_app", type = AzureOperation.Type.ACTION)
public void deploy() throws GradleException {
    try {
        ProxyManager.getInstance().applyProxy();
        TelemetryAgent.getInstance().addDefaultProperty(PROXY, String.valueOf(ProxyManager.getInstance().isProxyEnabled()));
        TelemetryAgent.getInstance().addDefaultProperties(azureWebappExtension.getTelemetryProperties());
        initTask();
        TelemetryAgent.getInstance().trackTaskStart(this.getClass());
        final GradleWebAppConfig config = parseConfiguration();
        normalizeConfigValue(config);
        validate(config);
        config.subscriptionId(GradleAuthHelper.login(azureWebappExtension.getAuth(), config.subscriptionId()));
        validateOnline(config);
        final WebAppBase<?, ?, ?> target = createOrUpdateWebapp(config);
        deployArtifact(target, config);
        TelemetryAgent.getInstance().trackTaskSuccess(this.getClass());
    } catch (Exception e) {
        AzureMessager.getMessager().error(e);
        TelemetryAgent.getInstance().traceException(this.getClass(), e);
        throw new GradleException("Cannot deploy web app due to error: " + e.getMessage(), e);
    }
}
Also used : GradleWebAppConfig(com.microsoft.azure.gradle.configuration.GradleWebAppConfig) GradleException(org.gradle.api.GradleException) AzureToolkitRuntimeException(com.microsoft.azure.toolkit.lib.common.exception.AzureToolkitRuntimeException) GradleException(org.gradle.api.GradleException) TaskAction(org.gradle.api.tasks.TaskAction) AzureOperation(com.microsoft.azure.toolkit.lib.common.operation.AzureOperation)

Aggregations

GradleWebAppConfig (com.microsoft.azure.gradle.configuration.GradleWebAppConfig)2 AzureToolkitRuntimeException (com.microsoft.azure.toolkit.lib.common.exception.AzureToolkitRuntimeException)2 GradleDeploymentSlotConfig (com.microsoft.azure.gradle.configuration.GradleDeploymentSlotConfig)1 WebAppArtifact (com.microsoft.azure.toolkit.lib.appservice.model.WebAppArtifact)1 AzureOperation (com.microsoft.azure.toolkit.lib.common.operation.AzureOperation)1 File (java.io.File)1 GradleException (org.gradle.api.GradleException)1 TaskAction (org.gradle.api.tasks.TaskAction)1