Search in sources :

Example 1 with IWebAppDeploymentSlot

use of com.microsoft.azure.toolkit.lib.appservice.service.IWebAppDeploymentSlot in project azure-tools-for-java by Microsoft.

the class AzureWebAppMvpModel method deployArtifactsToWebApp.

@AzureOperation(name = "webapp|artifact.upload", params = { "file.getName()", "deployTarget.name()" }, type = AzureOperation.Type.SERVICE)
public void deployArtifactsToWebApp(@NotNull final IWebAppBase deployTarget, @NotNull final File file, boolean isDeployToRoot, @NotNull final IProgressIndicator progressIndicator) {
    if (!(deployTarget instanceof IWebApp || deployTarget instanceof IWebAppDeploymentSlot)) {
        final String error = "the deployment target is not a valid (deployment slot of) Web App";
        final String action = "select a valid Web App or deployment slot to deploy the artifact";
        throw new AzureToolkitRuntimeException(error, action);
    }
    // stop target app service
    String stopMessage = deployTarget instanceof IWebApp ? STOP_WEB_APP : STOP_DEPLOYMENT_SLOT;
    progressIndicator.setText(stopMessage);
    deployTarget.stop();
    final DeployType deployType = getDeployTypeByWebContainer(deployTarget.getRuntime().getWebContainer());
    // java se runtime will always deploy to root
    if (isDeployToRoot || Objects.equals(deployTarget.getRuntime().getWebContainer(), com.microsoft.azure.toolkit.lib.appservice.model.WebContainer.JAVA_SE)) {
        deployTarget.deploy(deployType, file);
    } else {
        final String webappPath = String.format("webapps/%s", FilenameUtils.getBaseName(file.getName()).replaceAll("#", StringUtils.EMPTY));
        deployTarget.deploy(deployType, file, webappPath);
    }
    String successMessage = deployTarget instanceof IWebApp ? DEPLOY_SUCCESS_WEB_APP : DEPLOY_SUCCESS_DEPLOYMENT_SLOT;
    progressIndicator.setText(successMessage);
    deployTarget.start();
}
Also used : DeployType(com.microsoft.azure.toolkit.lib.appservice.model.DeployType) IWebAppDeploymentSlot(com.microsoft.azure.toolkit.lib.appservice.service.IWebAppDeploymentSlot) AzureToolkitRuntimeException(com.microsoft.azure.toolkit.lib.common.exception.AzureToolkitRuntimeException) IWebApp(com.microsoft.azure.toolkit.lib.appservice.service.IWebApp) AzureOperation(com.microsoft.azure.toolkit.lib.common.operation.AzureOperation)

Example 2 with IWebAppDeploymentSlot

use of com.microsoft.azure.toolkit.lib.appservice.service.IWebAppDeploymentSlot in project azure-tools-for-java by Microsoft.

the class WebAppRunState method updateApplicationSettings.

private void updateApplicationSettings(IAppService deployTarget, RunProcessHandler processHandler) {
    final Map<String, String> applicationSettings = webAppConfiguration.getApplicationSettings();
    if (MapUtils.isEmpty(applicationSettings)) {
        return;
    }
    if (deployTarget instanceof IWebApp) {
        processHandler.setText("Updating application settings...");
        IWebApp webApp = (IWebApp) deployTarget;
        webApp.update().withAppSettings(applicationSettings).commit();
        processHandler.setText("Update application settings successfully.");
    } else if (deployTarget instanceof IWebAppDeploymentSlot) {
        processHandler.setText("Updating deployment slot application settings...");
        AzureWebAppMvpModel.getInstance().updateDeploymentSlotAppSettings((IWebAppDeploymentSlot) deployTarget, applicationSettings);
        processHandler.setText("Update deployment slot application settings successfully.");
    }
}
Also used : IWebAppDeploymentSlot(com.microsoft.azure.toolkit.lib.appservice.service.IWebAppDeploymentSlot) IWebApp(com.microsoft.azure.toolkit.lib.appservice.service.IWebApp)

Example 3 with IWebAppDeploymentSlot

use of com.microsoft.azure.toolkit.lib.appservice.service.IWebAppDeploymentSlot in project azure-tools-for-java by Microsoft.

the class WebAppDeployDialog method fillSlot.

private void fillSlot() {
    if (!isDeployToSlot) {
        return;
    }
    int selectedRow = table.getSelectionIndex();
    comboSlot.removeAll();
    comboSlotConf.removeAll();
    if (selectedRow < 0) {
        return;
    }
    String appServiceName = table.getItems()[selectedRow].getText(0);
    IWebApp webApp = webAppDetailsMap.get(appServiceName);
    if (webApp == null) {
        return;
    }
    List<IWebAppDeploymentSlot> deploymentSlots = webApp.deploymentSlots(false);
    for (IWebAppDeploymentSlot deploymentSlot : deploymentSlots) {
        comboSlot.add(deploymentSlot.name());
        comboSlotConf.add(deploymentSlot.name());
    }
    if (comboSlot.getItemCount() > 0) {
        comboSlot.select(0);
    }
    comboSlotConf.add(webApp.name());
    comboSlotConf.add(DONOT_CLONE_SLOT_CONF);
    comboSlotConf.select(0);
}
Also used : IWebAppDeploymentSlot(com.microsoft.azure.toolkit.lib.appservice.service.IWebAppDeploymentSlot) Point(org.eclipse.swt.graphics.Point) IWebApp(com.microsoft.azure.toolkit.lib.appservice.service.IWebApp)

Example 4 with IWebAppDeploymentSlot

use of com.microsoft.azure.toolkit.lib.appservice.service.IWebAppDeploymentSlot in project azure-tools-for-java by Microsoft.

the class DeploymentSlotPropertyViewPresenter method updateAppSettings.

@Override
protected void updateAppSettings(@NotNull final String sid, @NotNull final String webAppId, @Nullable final String name, final Map toUpdate, final Set toRemove) {
    final IWebAppDeploymentSlot slot = getWebAppBase(sid, webAppId, name);
    final IWebAppDeploymentSlot.Updater updater = slot.update();
    updater.withAppSettings(toUpdate);
    toRemove.forEach(key -> updater.withoutAppSettings((String) key));
    updater.commit();
}
Also used : IWebAppDeploymentSlot(com.microsoft.azure.toolkit.lib.appservice.service.IWebAppDeploymentSlot)

Aggregations

IWebAppDeploymentSlot (com.microsoft.azure.toolkit.lib.appservice.service.IWebAppDeploymentSlot)4 IWebApp (com.microsoft.azure.toolkit.lib.appservice.service.IWebApp)3 DeployType (com.microsoft.azure.toolkit.lib.appservice.model.DeployType)1 AzureToolkitRuntimeException (com.microsoft.azure.toolkit.lib.common.exception.AzureToolkitRuntimeException)1 AzureOperation (com.microsoft.azure.toolkit.lib.common.operation.AzureOperation)1 Point (org.eclipse.swt.graphics.Point)1