import type { WebSiteManagementModels } from '@azure/arm-appservice' ; import * as vscode from 'vscode' ; import { callWithTelemetryAndErrorHandling , IActionContext , UserCancelledError } from 'vscode-azureextensionui' ; import { ext } from '../extensionVariables' ; import { localize } from '../localize' ; import { ParsedSite } from '../SiteClient' ; export function reportMessage ( message , progress , token ) { if ( token . isCancellationRequested ) { throw new UserCancelledError ( 'remoteDebugReportMessage' ) ; } ext . outputChannel . appendLog ( message ) ; progress . report ( { message : message } ) ; } export async function setRemoteDebug ( context , isRemoteDebuggingToBeEnabled , confirmMessage , noopMessage , site , siteConfig , progress , token , learnMoreLink ? ) { const client = await site . createClient ( context ) ; const state = await client . getState ( ) ; if ( state && state . toLowerCase ( ) === 'stopped' ) { throw new Error ( localize ( 'remoteDebugStopped' , 'The app must be running, but is currently in state "Stopped". Start the app to continue.' ) ) ; } if ( isRemoteDebuggingToBeEnabled !== siteConfig . remoteDebuggingEnabled ) { const confirmButton = isRemoteDebuggingToBeEnabled ? { title : 'Enable' } : { title : 'Disable' } ; await context . ui . showWarningMessage ( confirmMessage , { modal : true , learnMoreLink } , confirmButton ) ; siteConfig . remoteDebuggingEnabled = isRemoteDebuggingToBeEnabled ; reportMessage ( localize ( 'remoteDebugUpdate' , 'Updating site configuration to set remote debugging...' ) , progress , token ) ; await callWithTelemetryAndErrorHandling ( 'appService.remoteDebugUpdateConfiguration' , async ( updateContext ) => { updateContext . errorHandling . suppressDisplay = true ; updateContext . errorHandling . rethrow = true ; await client . updateConfiguration ( siteConfig ) ; } ) ; reportMessage ( localize ( 'remoteDebugUpdateDone' , 'Updating site configuration done.' ) , progress , token ) ; } else { if ( noopMessage ) { void vscode . window . showWarningMessage ( noopMessage ) ; } } }