@@ -278,7 +278,7 @@ protected virtual void Initialize()
278278
279279 if ( string . IsNullOrEmpty ( ScriptConfig . HostConfig . HostId ) )
280280 {
281- ScriptConfig . HostConfig . HostId = GetDefaultHostId ( _settingsManager , ScriptConfig ) ;
281+ ScriptConfig . HostConfig . HostId = Utility . GetDefaultHostId ( _settingsManager , ScriptConfig ) ;
282282 }
283283 if ( string . IsNullOrEmpty ( ScriptConfig . HostConfig . HostId ) )
284284 {
@@ -1304,44 +1304,6 @@ internal static void ApplyApplicationInsightsConfig(JObject configJson, ScriptHo
13041304 }
13051305 }
13061306
1307- internal static string GetDefaultHostId ( ScriptSettingsManager settingsManager , ScriptHostConfiguration scriptConfig )
1308- {
1309- // We're setting the default here on the newly created configuration
1310- // If the user has explicitly set the HostID via host.json, it will overwrite
1311- // what we set here
1312- string hostId = null ;
1313- if ( scriptConfig . IsSelfHost )
1314- {
1315- // When running locally, derive a stable host ID from machine name
1316- // and root path. We use a hash rather than the path itself to ensure
1317- // IDs differ (due to truncation) between folders that may share the same
1318- // root path prefix.
1319- // Note that such an ID won't work in distributed scenarios, so should
1320- // only be used for local/CLI scenarios.
1321- string sanitizedMachineName = Environment . MachineName
1322- . Where ( char . IsLetterOrDigit )
1323- . Aggregate ( new StringBuilder ( ) , ( b , c ) => b . Append ( c ) ) . ToString ( ) ;
1324- hostId = $ "{ sanitizedMachineName } -{ Math . Abs ( scriptConfig . RootScriptPath . GetHashCode ( ) ) } ";
1325- }
1326- else if ( ! string . IsNullOrEmpty ( settingsManager . AzureWebsiteUniqueSlotName ) )
1327- {
1328- // If running on Azure Web App, derive the host ID from unique site slot name
1329- hostId = settingsManager . AzureWebsiteUniqueSlotName ;
1330- }
1331-
1332- if ( ! string . IsNullOrEmpty ( hostId ) )
1333- {
1334- if ( hostId . Length > ScriptConstants . MaximumHostIdLength )
1335- {
1336- // Truncate to the max host name length if needed
1337- hostId = hostId . Substring ( 0 , ScriptConstants . MaximumHostIdLength ) ;
1338- }
1339- }
1340-
1341- // Lowercase and trim any trailing '-' as they can cause problems with queue names
1342- return hostId ? . ToLowerInvariant ( ) . TrimEnd ( '-' ) ;
1343- }
1344-
13451307 private void OnUnhandledException ( object sender , UnhandledExceptionEventArgs e )
13461308 {
13471309 HandleHostError ( ( Exception ) e . ExceptionObject ) ;
0 commit comments