diff --git a/src/commands/restartWebApp.ts b/src/commands/restartWebApp.ts index 1d203010..c7530cde 100644 --- a/src/commands/restartWebApp.ts +++ b/src/commands/restartWebApp.ts @@ -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 { 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); + }); } diff --git a/src/commands/stopWebApp.ts b/src/commands/stopWebApp.ts index 7e67dff0..f37fdb9c 100644 --- a/src/commands/stopWebApp.ts +++ b/src/commands/stopWebApp.ts @@ -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"; @@ -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);