Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 19 additions & 4 deletions src/commands/restartWebApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,28 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { type IActionContext } from "@microsoft/vscode-azext-utils";
import { commands } from "vscode";
import { DialogResponses, type IActionContext } from "@microsoft/vscode-azext-utils";
import { ext } from "../extensionVariables";
import { localize } from "../localize";
import { type SiteTreeItem } from "../tree/SiteTreeItem";
import { pickWebApp } from "../utils/pickWebApp";

export async function restartWebApp(context: IActionContext, node?: SiteTreeItem): Promise<void> {
node ??= await pickWebApp(context);
await commands.executeCommand('appService.Stop', node);
await commands.executeCommand('appService.Start', node);
await node.initSite(context);

if (!node.site.isSlot) {
const confirmMessage: string = localize('confirmRestart', 'Restart web app "{0}"? Traffic will be interrupted.', node.site.fullName);
await context.ui.showWarningMessage(confirmMessage, { modal: true, stepName: 'confirmRestart' }, DialogResponses.yes, DialogResponses.cancel);
}

const client = await node.site.createClient(context);
const restartingApp: string = localize('restartingApp', 'Restarting "{0}"...', node.site.fullName);
const restartedApp: string = localize('restartedApp', '"{0}" has been restarted.', node.site.fullName);
await node.runWithTemporaryDescription(context, localize('restarting', "Restarting..."), async () => {
ext.outputChannel.appendLog(restartingApp);
await client.stop();
await client.start();
ext.outputChannel.appendLog(restartedApp);
});
}
8 changes: 7 additions & 1 deletion src/commands/stopWebApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { type IActionContext } from "@microsoft/vscode-azext-utils";
import { DialogResponses, type IActionContext } from "@microsoft/vscode-azext-utils";
import { ext } from "../extensionVariables";
import { localize } from "../localize";
import { type SiteTreeItem } from "../tree/SiteTreeItem";
Expand All @@ -15,6 +15,12 @@ export async function stopWebApp(context: IActionContext, node?: SiteTreeItem):
}

await node.initSite(context);

if (!node.site.isSlot) {
const confirmMessage: string = localize('confirmStop', 'Stop web app "{0}"? Traffic will be interrupted.', node.site.fullName);
await context.ui.showWarningMessage(confirmMessage, { modal: true, stepName: 'confirmStop' }, DialogResponses.yes, DialogResponses.cancel);
}

const client = await node.site.createClient(context);
const stoppingApp: string = localize('stoppingApp', 'Stopping "{0}"...', node.site.fullName);
const stoppedApp: string = localize('stoppedApp', '"{0}" has been stopped. App Service plan charges still apply.', node.site.fullName);
Expand Down