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();
}
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.");
}
}
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);
}
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();
}
Aggregations