@@ -130,7 +130,7 @@ internal void EnsureInitialized(WebHostSettings settings)
130130 _activeScriptHostConfig = CreateScriptHostConfiguration ( settings ) ;
131131 _activeHostManager = new WebScriptHostManager ( _activeScriptHostConfig , _secretManagerFactory , _eventManager , _settingsManager , settings ) ;
132132 _activeReceiverManager = new WebHookReceiverManager ( _activeHostManager . SecretManager ) ;
133- InitializeFileSystem ( ) ;
133+ InitializeFileSystem ( _settingsManager . FileSystemIsReadOnly ) ;
134134
135135 if ( _standbyHostManager != null )
136136 {
@@ -165,7 +165,7 @@ internal void EnsureInitialized(WebHostSettings settings)
165165 _standbyHostManager = new WebScriptHostManager ( _standbyScriptHostConfig , _secretManagerFactory , _eventManager , _settingsManager , standbySettings ) ;
166166 _standbyReceiverManager = new WebHookReceiverManager ( _standbyHostManager . SecretManager ) ;
167167
168- InitializeFileSystem ( ) ;
168+ InitializeFileSystem ( _settingsManager . FileSystemIsReadOnly ) ;
169169 StandbyManager . Initialize ( _standbyScriptHostConfig ) ;
170170
171171 // start a background timer to identify when specialization happens
@@ -285,7 +285,7 @@ private void OnSpecializationTimerTick(object state)
285285 _activeHostManager ? . EnsureInitialized ( ) ;
286286 }
287287
288- private static void InitializeFileSystem ( )
288+ private static void InitializeFileSystem ( bool readOnlyFileSystem )
289289 {
290290 if ( ScriptSettingsManager . Instance . IsAzureEnvironment )
291291 {
@@ -294,17 +294,23 @@ private static void InitializeFileSystem()
294294 string home = ScriptSettingsManager . Instance . GetSetting ( EnvironmentSettingNames . AzureWebsiteHomePath ) ;
295295 if ( ! string . IsNullOrEmpty ( home ) )
296296 {
297- // Delete hostingstart.html if any. Azure creates that in all sites by default
298- string siteRootPath = Path . Combine ( home , @"site\wwwroot" ) ;
299- string hostingStart = Path . Combine ( siteRootPath , "hostingstart.html" ) ;
300- if ( File . Exists ( hostingStart ) )
297+ if ( ! readOnlyFileSystem )
301298 {
302- File . Delete ( hostingStart ) ;
299+ // Delete hostingstart.html if any. Azure creates that in all sites by default
300+ string siteRootPath = Path . Combine ( home , @"site\wwwroot" ) ;
301+ string hostingStart = Path . Combine ( siteRootPath , "hostingstart.html" ) ;
302+ if ( File . Exists ( hostingStart ) )
303+ {
304+ File . Delete ( hostingStart ) ;
305+ }
303306 }
304307
305- // Create the tools folder if it doesn't exist
306308 string toolsPath = Path . Combine ( home , @"site\tools" ) ;
307- Directory . CreateDirectory ( toolsPath ) ;
309+ if ( ! readOnlyFileSystem )
310+ {
311+ // Create the tools folder if it doesn't exist
312+ Directory . CreateDirectory ( toolsPath ) ;
313+ }
308314
309315 var folders = new List < string > ( ) ;
310316 folders . Add ( Path . Combine ( home , @"site\tools" ) ) ;
0 commit comments