@@ -278,7 +278,7 @@ protected virtual void Initialize()
278
278
279
279
if ( string . IsNullOrEmpty ( ScriptConfig . HostConfig . HostId ) )
280
280
{
281
- ScriptConfig . HostConfig . HostId = GetDefaultHostId ( _settingsManager , ScriptConfig ) ;
281
+ ScriptConfig . HostConfig . HostId = Utility . GetDefaultHostId ( _settingsManager , ScriptConfig ) ;
282
282
}
283
283
if ( string . IsNullOrEmpty ( ScriptConfig . HostConfig . HostId ) )
284
284
{
@@ -1304,44 +1304,6 @@ internal static void ApplyApplicationInsightsConfig(JObject configJson, ScriptHo
1304
1304
}
1305
1305
}
1306
1306
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
-
1345
1307
private void OnUnhandledException ( object sender , UnhandledExceptionEventArgs e )
1346
1308
{
1347
1309
HandleHostError ( ( Exception ) e . ExceptionObject ) ;
0 commit comments