public DeploymentSlot getDeploymentSlot(final WebApp app, final String slotName) { DeploymentSlot slot = null; if (StringUtils.isNotEmpty(slotName)) { try { slot = app.deploymentSlots().getByName(slotName); } catch (NoSuchElementException deploymentSlotNotExistException) { } } return slot; }
/** * Get all the deployment slots of a web app by the subscription id and web app id. */ public List<DeploymentSlot> getDeploymentSlots(final String subscriptionId, final String appId) throws IOException { final List<DeploymentSlot> deploymentSlots = new ArrayList<>(); final WebApp webApp = AuthMethodManager.getInstance().getAzureClient(subscriptionId).webApps().getById(appId); deploymentSlots.addAll(webApp.deploymentSlots().list()); return deploymentSlots; }
/** * API to create a new Deployment Slot by setting model. */ public DeploymentSlot createDeploymentSlot(@NotNull WebAppSettingModel model) throws Exception { final WebApp app = getWebAppById(model.getSubscriptionId(), model.getWebAppId()); final String name = model.getNewSlotName(); final String configurationSource = model.getNewSlotConfigurationSource(); final DeploymentSlot.DefinitionStages.Blank definedSlot = app.deploymentSlots().define(name); if (configurationSource.equals(app.name())) { return definedSlot.withConfigurationFromParent().create(); } final DeploymentSlot configurationSourceSlot = app.deploymentSlots() .list() .stream() .filter(s -> configurationSource.equals(s.name())) .findAny() .orElse(null); if (configurationSourceSlot != null) { return definedSlot.withConfigurationFromDeploymentSlot(configurationSourceSlot).create(); } else { return definedSlot.withBrandNewConfiguration().create(); } }
protected void createDeploymentSlot(final WebApp app, final String slotName, final String configurationSource) throws MojoExecutionException { assureValidSlotName(slotName); final DeploymentSlot.DefinitionStages.Blank definedSlot = app.deploymentSlots().define(slotName); final ConfigurationSourceType type = ConfigurationSourceType.fromString(configurationSource); switch (type) { case NEW: this.mojo.getLog().info(EMPTY_CONFIGURATION_SOURCE); definedSlot.withBrandNewConfiguration().create(); break; case PARENT: this.mojo.getLog().info(DEFAULT_CONFIGURATION_SOURCE); definedSlot.withConfigurationFromParent().create(); break; case OTHERS: final DeploymentSlot configurationSourceSlot = this.mojo.getDeploymentSlot(app, configurationSource); if (configurationSourceSlot == null) { throw new MojoExecutionException(TARGET_CONFIGURATION_SOURCE_SLOT_NOT_EXIST); } this.mojo.getLog().info(String.format(COPY_CONFIGURATION_FROM_SLOT, configurationSource)); definedSlot.withConfigurationFromDeploymentSlot(configurationSourceSlot).create(); break; default: throw new MojoExecutionException(UNKNOWN_CONFIGURATION_SOURCE); } this.mojo.getLog().info(CREATE_DEPLOYMENT_SLOT_DONE); }
public void deleteDeploymentSlotNode(final String subscriptionId, final String appId, final String slotName) throws IOException { final WebApp app = AuthMethodManager.getInstance().getAzureClient(subscriptionId).webApps().getById(appId); app.deploymentSlots().deleteByName(slotName); }
/** * Download publish profile of deployment slot. */ public boolean getSlotPublishingProfileXmlWithSecrets(final String sid, final String webAppId, final String slotName, final String filePath) throws Exception { final WebApp app = getWebAppById(sid, webAppId); final DeploymentSlot slot = app.deploymentSlots().getByName(slotName); final File file = new File(Paths.get(filePath, slotName + "_" + System.currentTimeMillis() + ".PublishSettings") .toString()); file.createNewFile(); try (final InputStream inputStream = slot.manager().inner().webApps() .listPublishingProfileXmlWithSecretsSlot(slot.resourceGroupName(), app.name(), slotName, PublishingProfileFormat.FTP); OutputStream outputStream = new FileOutputStream(file); ) { IOUtils.copy(inputStream, outputStream); return true; } catch (IOException e) { e.printStackTrace(); return false; } }
public void restartDeploymentSlot(final String subscriptionId, final String appId, final String slotName) throws IOException { final WebApp app = AuthMethodManager.getInstance().getAzureClient(subscriptionId).webApps().getById(appId); app.deploymentSlots().getByName(slotName).restart(); }
@Override protected WebAppBase getWebAppBase(@NotNull final String sid, @NotNull final String webAppId, @Nullable final String name) throws Exception { return AzureWebAppMvpModel.getInstance().getWebAppById(sid, webAppId).deploymentSlots().getByName(name); } }
public void startDeploymentSlot(final String subscriptionId, final String appId, final String slotName) throws IOException { final WebApp app = AuthMethodManager.getInstance().getAzureClient(subscriptionId).webApps().getById(appId); app.deploymentSlots().getByName(slotName).start(); }
public void stopDeploymentSlot(final String subscriptionId, final String appId, final String slotName) throws IOException { final WebApp app = AuthMethodManager.getInstance().getAzureClient(subscriptionId).webApps().getById(appId); app.deploymentSlots().getByName(slotName).stop(); }
public void swapSlotWithProduction(final String subscriptionId, final String appId, final String slotName) throws IOException { final WebApp app = AuthMethodManager.getInstance().getAzureClient(subscriptionId).webApps().getById(appId); final DeploymentSlot slot = app.deploymentSlots().getByName(slotName); slot.swap("production"); }
/** * Update app settings of deployment slot. */ public void updateDeploymentSlotAppSettings(final String subsciptionId, final String webAppId, final String slotName, final Map<String, String> toUpdate, final Set<String> toRemove) throws Exception { final DeploymentSlot slot = getWebAppById(subsciptionId, webAppId).deploymentSlots().getByName(slotName); clearTags(slot); com.microsoft.azure.management.appservice.WebAppBase.Update<DeploymentSlot> update = slot.update() .withAppSettings(toUpdate); for (String key : toRemove) { update = update.withoutAppSetting(key); } update.apply(); }
public void onRefreshNode(final String subscriptionId, final String webAppId, final String slotName) throws Exception { final WebApp app = AzureWebAppMvpModel.getInstance().getWebAppById(subscriptionId, webAppId); final DeploymentSlot slot = app.deploymentSlots().getByName(slotName); final DeploymentSlotNodeView view = getMvpView(); if (!isViewDetached()) { view.renderNode(WebAppBaseState.fromString(slot.state())); } }