public override void ExecuteCmdlet() { base.ExecuteCmdlet(); string deletedSiteId = string.IsNullOrEmpty(DeletedId) ? GetDeletedSiteResourceId() : DeletedId; ResolveTargetParameters(); DeletedAppRestoreRequest restoreReq = new DeletedAppRestoreRequest() { DeletedSiteId = deletedSiteId, RecoverConfiguration = !this.RestoreContentOnly, UseDRSecondary = UseDisasterRecovery }; Action restoreAction = () => WebsitesClient.RestoreDeletedWebApp(TargetResourceGroupName, TargetName, TargetSlot, restoreReq); if (WebsitesClient.WebAppExists(TargetResourceGroupName, TargetName, TargetSlot)) { ConfirmAction(this.Force.IsPresent, "Target web app contents will be overwritten with the contents of the deleted app.", "The deleted app has been restored.", TargetName, restoreAction); } else { if (string.IsNullOrEmpty(TargetAppServicePlanName)) { throw new Exception("Target app " + TargetName + " does not exist. Specify TargetAppServicePlanName for it to be created automatically."); } AppServicePlan plan = WebsitesClient.GetAppServicePlan(TargetResourceGroupName, TargetAppServicePlanName); if (plan == null) { throw new Exception("Target App Service Plan " + TargetAppServicePlanName + " not found in target Resource Group " + TargetResourceGroupName); } try { Action createRestoreAction = () => { WebsitesClient.CreateWebApp(TargetResourceGroupName, TargetName, TargetSlot, plan.Location, TargetAppServicePlanName, null, string.Empty, string.Empty); restoreAction(); }; string confirmMsg = string.Format("This web app will be created. App Name: {0}, Resource Group: {1}", TargetName, TargetResourceGroupName); if (!string.IsNullOrEmpty(TargetSlot)) { confirmMsg += ", Slot: " + TargetSlot; } ConfirmAction(this.Force.IsPresent, confirmMsg, "The deleted app has been restored.", TargetName, createRestoreAction); } catch (Exception e) { WebsitesClient.RemoveWebApp(TargetResourceGroupName, TargetName, TargetSlot, true, true, false); throw e; } } PSSite restoredApp = new PSSite(WebsitesClient.GetWebApp(TargetResourceGroupName, TargetName, TargetSlot)); WriteObject(restoredApp); }
public override void ExecuteCmdlet() { base.ExecuteCmdlet(); ConfirmAction( Force.IsPresent, string.Format(Properties.Resources.RemoveWebappSlotWarning, Name, Slot), Properties.Resources.RemoveWebappSlotMessage, Name, () => WebsitesClient.RemoveWebApp(ResourceGroupName, Name, Slot, deleteEmptyServerFarmByDefault, deleteMetricsByDefault, deleteSlotsByDefault)); }
protected override void ProcessRecord() { base.ProcessRecord(); ConfirmAction( Force.IsPresent, string.Format(Properties.Resources.RemoveWebsiteWarning, Name), Properties.Resources.RemoveWebsiteMessage, Name, () => { WebsitesClient.RemoveWebApp(ResourceGroupName, Name, null, deleteEmptyServerFarmByDefault, deleteMetricsByDefault, deleteSlotsByDefault); }); }
public override void ExecuteCmdlet() { base.ExecuteCmdlet(); ConfirmAction( Force.IsPresent, string.Format(Properties.Resources.RemoveWebsiteWarning, Name), Properties.Resources.RemoveWebsiteMessage, Name, () => { WebsitesClient.RemoveWebApp(ResourceGroupName, Name, null, DeleteAppServicePlan, deleteMetricsByDefault, deleteSlotsByDefault); }); }