public void deleteWebApp(String sid, String appId) throws IOException { AuthMethodManager.getInstance().getAzureClient(sid).webApps().deleteById(appId); subscriptionIdToWebApps.remove(sid); }
/** * get the web app by ID. */ public WebApp getWebAppById(String sid, String id) throws Exception { Azure azure = AuthMethodManager.getInstance().getAzureClient(sid); WebApp app = azure.webApps().getById(id); if (app == null) { throw new Exception(CANNOT_GET_WEB_APP_WITH_ID + id); // TODO: specify the type of exception. } return app; }
public WebApp getWebApp() throws AzureAuthFailureException { try { return getAzureClient().webApps().getByResourceGroup(getResourceGroup(), getAppName()); } catch (AzureAuthFailureException authEx) { throw authEx; } catch (Exception ex) { // Swallow exception for non-existing web app } return null; }
public static WithCreate defineWindowsApp(final String resourceGroup, final String appName, final Azure azureClient, final AppServicePlan plan) throws Exception { assureWindowsPlan(plan); final ExistingWindowsPlanWithGroup existingWindowsPlanWithGroup = azureClient.webApps() .define(appName).withExistingWindowsPlan(plan); return azureClient.resourceGroups().contain(resourceGroup) ? existingWindowsPlanWithGroup.withExistingResourceGroup(resourceGroup) : existingWindowsPlanWithGroup.withNewResourceGroup(resourceGroup); }
/** * List all web apps by subscription id. */ @NotNull public List<ResourceEx<WebApp>> listWebApps(final String subscriptionId, final boolean force) { if (!force && subscriptionIdToWebApps.get(subscriptionId) != null) { return subscriptionIdToWebApps.get(subscriptionId); } List<ResourceEx<WebApp>> webApps = new ArrayList<>(); try { final Azure azure = AuthMethodManager.getInstance().getAzureClient(subscriptionId); webApps = azure.webApps().list() .stream() .map(app -> new ResourceEx<WebApp>(app, subscriptionId)) .collect(Collectors.toList()); subscriptionIdToWebApps.put(subscriptionId, webApps); } catch (IOException e) { e.printStackTrace(); } return webApps; }
public static WithDockerContainerImage defineLinuxApp(final String resourceGroup, final String appName, final Azure azureClient, final AppServicePlan plan) throws Exception { assureLinuxPlan(plan); final ExistingLinuxPlanWithGroup existingLinuxPlanWithGroup = azureClient.webApps() .define(appName).withExistingLinuxPlan(plan); return azureClient.resourceGroups().contain(resourceGroup) ? existingLinuxPlanWithGroup.withExistingResourceGroup(resourceGroup) : existingLinuxPlanWithGroup.withNewResourceGroup(resourceGroup); }
private WebApp.DefinitionStages.WithNewAppServicePlan prepareServicePlan( @NotNull Azure azure, @NotNull WebAppSettingModel model) { final WebApp.DefinitionStages.NewAppServicePlanWithGroup appWithGroup = azure .webApps() .define(model.getWebAppName()) .withRegion(model.getRegion()); final String resourceGroup = model.getResourceGroup(); if (model.isCreatingResGrp()) { return appWithGroup.withNewResourceGroup(resourceGroup); } return appWithGroup.withExistingResourceGroup(resourceGroup); }
/** * 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; }
public static void deleteAppService(WebAppDetails webAppDetails) throws IOException { AzureManager azureManager = AuthMethodManager.getInstance().getAzureManager(); Azure azure = azureManager.getAzure(webAppDetails.subscriptionDetail.getSubscriptionId()); azure.webApps().deleteById(webAppDetails.webApp.id()); // check asp still exists AppServicePlan asp = azure.appServices().appServicePlans().getById(webAppDetails.appServicePlan.id()); System.out.println("asp is " + (asp == null ? "null -> removing form cache" : asp.name())); // update cache AzureModelController.removeWebAppFromResourceGroup(webAppDetails.resourceGroup, webAppDetails.webApp); if (asp == null) { AzureModelController.removeAppServicePlanFromResourceGroup(webAppDetails.appServicePlanResourceGroup, webAppDetails.appServicePlan); } }
private WebApp.DefinitionStages.WithDockerContainerImage withExistingLinuxServicePlan( @NotNull Azure azure, @NotNull WebAppSettingModel model) { AppServicePlan servicePlan = azure.appServices().appServicePlans().getById(model.getAppServicePlanId()); WebApp.DefinitionStages.ExistingLinuxPlanWithGroup withGroup = azure .webApps() .define(model.getWebAppName()) .withExistingLinuxPlan(servicePlan); if (model.isCreatingResGrp()) { return withGroup.withNewResourceGroup(model.getResourceGroup()); } return withGroup.withExistingResourceGroup(model.getResourceGroup()); }
public void restartWebApp(String sid, String appid) throws IOException { AuthMethodManager.getInstance().getAzureClient(sid).webApps().getById(appid).restart(); }
private WebApp.DefinitionStages.WithCreate withExistingWindowsServicePlan( @NotNull Azure azure, @NotNull WebAppSettingModel model) { AppServicePlan servicePlan = azure.appServices().appServicePlans().getById(model.getAppServicePlanId()); WebApp.DefinitionStages.ExistingWindowsPlanWithGroup withGroup = azure .webApps() .define(model.getWebAppName()) .withExistingWindowsPlan(servicePlan); if (model.isCreatingResGrp()) { return withGroup.withNewResourceGroup(model.getResourceGroup()); } return withGroup.withExistingResourceGroup(model.getResourceGroup()); }
public void startWebApp(String sid, String appid) throws IOException { AuthMethodManager.getInstance().getAzureClient(sid).webApps().getById(appid).start(); }
PricingTier pricingTier = new PricingTier(model.getPricingSkuTier(), model.getPricingSkuSize()); WebApp.DefinitionStages.Blank webAppDefinition = azure.webApps().define(model.getWebAppName()); if (model.isCreatingNewAppServicePlan()) {
public void stopWebApp(String sid, String appid) throws IOException { AuthMethodManager.getInstance().getAzureClient(sid).webApps().getById(appid).stop(); }
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); }
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(); }
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"); }