@@ -109,23 +109,7 @@ public async Task InitializeAsync()
109109 {
110110 try
111111 {
112- string scriptPath = _options . CurrentValue . ScriptPath ;
113- _logger . LogInformation ( $ "Creating StandbyMode placeholder function directory ({ scriptPath } )") ;
114-
115- await FileUtility . DeleteDirectoryAsync ( scriptPath , true ) ;
116- FileUtility . EnsureDirectoryExists ( scriptPath ) ;
117-
118- string content = FileUtility . ReadResourceString ( $ "{ ScriptConstants . ResourcePath } .Functions.host.json") ;
119- File . WriteAllText ( Path . Combine ( scriptPath , "host.json" ) , content ) ;
120-
121- string functionPath = Path . Combine ( scriptPath , WarmUpConstants . FunctionName ) ;
122- Directory . CreateDirectory ( functionPath ) ;
123- content = FileUtility . ReadResourceString ( $ "{ ScriptConstants . ResourcePath } .Functions.{ WarmUpConstants . FunctionName } .function.json") ;
124- File . WriteAllText ( Path . Combine ( functionPath , "function.json" ) , content ) ;
125- content = FileUtility . ReadResourceString ( $ "{ ScriptConstants . ResourcePath } .Functions.{ WarmUpConstants . FunctionName } .run.csx") ;
126- File . WriteAllText ( Path . Combine ( functionPath , "run.csx" ) , content ) ;
127-
128- _logger . LogInformation ( $ "StandbyMode placeholder function directory created") ;
112+ await CreateStandbyWarmupFunctions ( ) ;
129113
130114 // start a background timer to identify when specialization happens
131115 // specialization usually happens via an http request (e.g. scale controller
@@ -140,6 +124,27 @@ public async Task InitializeAsync()
140124 }
141125 }
142126
127+ private async Task CreateStandbyWarmupFunctions ( )
128+ {
129+ string scriptPath = _options . CurrentValue . ScriptPath ;
130+ _logger . LogInformation ( $ "Creating StandbyMode placeholder function directory ({ scriptPath } )") ;
131+
132+ await FileUtility . DeleteDirectoryAsync ( scriptPath , true ) ;
133+ FileUtility . EnsureDirectoryExists ( scriptPath ) ;
134+
135+ string content = FileUtility . ReadResourceString ( $ "{ ScriptConstants . ResourcePath } .Functions.host.json") ;
136+ File . WriteAllText ( Path . Combine ( scriptPath , "host.json" ) , content ) ;
137+
138+ string functionPath = Path . Combine ( scriptPath , WarmUpConstants . FunctionName ) ;
139+ Directory . CreateDirectory ( functionPath ) ;
140+ content = FileUtility . ReadResourceString ( $ "{ ScriptConstants . ResourcePath } .Functions.{ WarmUpConstants . FunctionName } .function.json") ;
141+ File . WriteAllText ( Path . Combine ( functionPath , "function.json" ) , content ) ;
142+ content = FileUtility . ReadResourceString ( $ "{ ScriptConstants . ResourcePath } .Functions.{ WarmUpConstants . FunctionName } .run.csx") ;
143+ File . WriteAllText ( Path . Combine ( functionPath , "run.csx" ) , content ) ;
144+
145+ _logger . LogInformation ( $ "StandbyMode placeholder function directory created") ;
146+ }
147+
143148 private void OnSpecializationTimerTick ( object state )
144149 {
145150 if ( ! _webHostEnvironment . InStandbyMode && _environment . IsContainerReady ( ) )
0 commit comments