@@ -18,6 +18,7 @@ import { durableUtils } from '../utils/durableUtils';
1818import { isPythonV2Plus } from '../utils/programmingModelUtils' ;
1919import { getDebugConfigs , isDebugConfigEqual } from '../vsCodeConfig/launch' ;
2020import { getWorkspaceSetting , tryGetFunctionsWorkerRuntimeForProject } from "../vsCodeConfig/settings" ;
21+ import { getPreLaunchTaskChain } from './getPreLaunchTaskChain' ;
2122import { validateDTSConnectionPreDebug } from './storageProviders/validateDTSConnectionPreDebug' ;
2223import { validateNetheriteConnectionPreDebug } from './storageProviders/validateNetheriteConnectionPreDebug' ;
2324import { validateSQLConnectionPreDebug } from './storageProviders/validateSQLConnectionPreDebug' ;
@@ -32,12 +33,20 @@ export interface IPreDebugContext extends Omit<ISetConnectionSettingContext, 'pr
3233 projectPath ?: string ;
3334}
3435
36+ const emulatorTaskRegExp : RegExp = / a z u r i t e | e m u l a t o r / i;
37+
3538export async function preDebugValidate ( actionContext : IActionContext , debugConfig : vscode . DebugConfiguration ) : Promise < IPreDebugValidateResult > {
3639 const context : IPreDebugContext = Object . assign ( actionContext , { action : CodeAction . Debug } ) ;
3740 const workspace : vscode . WorkspaceFolder = getMatchingWorkspace ( debugConfig ) ;
3841 let shouldContinue : boolean ;
3942 context . telemetry . properties . debugType = debugConfig . type ;
4043
44+ // If one of the `preLaunchTasks` already handles starting emulators, we should skip the pre-validate prompts and setup for them
45+ const preLaunchTaskName : string | undefined = debugConfig . preLaunchTask ;
46+ const preLaunchTaskChain : string [ ] = preLaunchTaskName ? getPreLaunchTaskChain ( workspace , preLaunchTaskName ) : [ ] ;
47+ const hasEmulatorTask : boolean = preLaunchTaskChain . some ( label => emulatorTaskRegExp . test ( label ) ) ;
48+ context . telemetry . properties . hasEmulatorTask = String ( hasEmulatorTask ) ;
49+
4150 try {
4251 context . telemetry . properties . lastValidateStep = 'funcInstalled' ;
4352 const message : string = localize ( 'installFuncTools' , 'You must have the Azure Functions Core Tools installed to debug your local functions.' ) ;
@@ -62,28 +71,30 @@ export async function preDebugValidate(actionContext: IActionContext, debugConfi
6271 context . telemetry . properties . lastValidateStep = 'workerRuntime' ;
6372 await validateWorkerRuntime ( context , projectLanguage , context . projectPath ) ;
6473
65- switch ( durableStorageType ) {
66- case DurableBackend . DTS :
67- context . telemetry . properties . lastValidateStep = 'dtsConnection' ;
68- await validateDTSConnectionPreDebug ( context , context . projectPath ) ;
69- break ;
70- case DurableBackend . Netherite :
71- context . telemetry . properties . lastValidateStep = 'netheriteConnection' ;
72- await validateNetheriteConnectionPreDebug ( context , context . projectPath ) ;
73- break ;
74- case DurableBackend . SQL :
75- context . telemetry . properties . lastValidateStep = 'sqlDbConnection' ;
76- await validateSQLConnectionPreDebug ( context , context . projectPath ) ;
77- break ;
78- case DurableBackend . Storage :
79- default :
74+ if ( ! hasEmulatorTask ) {
75+ switch ( durableStorageType ) {
76+ case DurableBackend . DTS :
77+ context . telemetry . properties . lastValidateStep = 'dtsConnection' ;
78+ await validateDTSConnectionPreDebug ( context , context . projectPath ) ;
79+ break ;
80+ case DurableBackend . Netherite :
81+ context . telemetry . properties . lastValidateStep = 'netheriteConnection' ;
82+ await validateNetheriteConnectionPreDebug ( context , context . projectPath ) ;
83+ break ;
84+ case DurableBackend . SQL :
85+ context . telemetry . properties . lastValidateStep = 'sqlDbConnection' ;
86+ await validateSQLConnectionPreDebug ( context , context . projectPath ) ;
87+ break ;
88+ case DurableBackend . Storage :
89+ default :
90+ }
91+
92+ context . telemetry . properties . lastValidateStep = 'azureWebJobsStorage' ;
93+ await validateAzureWebJobsStorage ( context , context . projectPath ) ;
94+
95+ context . telemetry . properties . lastValidateStep = 'emulatorRunning' ;
96+ shouldContinue = hasEmulatorTask || await validateEmulatorIsRunning ( context , context . projectPath ) ;
8097 }
81-
82- context . telemetry . properties . lastValidateStep = 'azureWebJobsStorage' ;
83- await validateAzureWebJobsStorage ( context , context . projectPath ) ;
84-
85- context . telemetry . properties . lastValidateStep = 'emulatorRunning' ;
86- shouldContinue = await validateEmulatorIsRunning ( context , context . projectPath ) ;
8798 }
8899 }
89100 } catch ( error ) {
0 commit comments