Skip to content

Commit 5e30dce

Browse files
authored
Add more logs to help with Auto-Upgrade (#6988)
1 parent e43847e commit 5e30dce

File tree

13 files changed

+185
-16
lines changed

13 files changed

+185
-16
lines changed

azure-pipelines.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ name: 2.0.$(buildNumber)
66
pr:
77
branches:
88
include:
9-
- release/2.0
9+
- release/2.0*
1010
- v2.x
1111

1212
trigger:
1313
branches:
1414
include:
15-
- release/2.0
15+
- release/2.0*
1616
- v2.x
1717

1818
jobs:

build/initialize-pipeline.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ $bypassPackaging = $true
44
$suffix = "-ci"
55
Write-Host "SourceBranch: $sourceBranch, Build reason: $buildReason"
66

7-
if($sourceBranch.endsWith('release/2.0')) {
7+
if($sourceBranch.endsWith('release/2.0') -or $sourceBranch.startsWith('release/2.0-hotfix')) {
88
$suffix = ""
99
}
1010

11-
if(($sourceBranch.endsWith('v2.x') -or $sourceBranch.endsWith('release/2.0')) -and ($buildReason -ne "PullRequest"))
11+
if(($sourceBranch.endsWith('v2.x') -or $sourceBranch.endsWith('release/2.0') -or $sourceBranch.startsWith('release/2.0-hotfix')) -and ($buildReason -ne "PullRequest"))
1212
{
1313
$bypassPackaging = $false
1414
}

src/WebJobs.Script.WebHost/FileMonitoringService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ internal static async Task SetAppOfflineState(string rootPath, bool offline)
354354
if (offline && !offlineFileExists)
355355
{
356356
// create the app_offline.htm file in the root script directory
357-
string content = FileUtility.ReadResourceString($"{ScriptConstants.ResourcePath}.{ScriptConstants.AppOfflineFileName}");
357+
string content = FileUtility.ReadResourceString($"{ScriptConstants.WebHostResourcePath}.{ScriptConstants.AppOfflineFileName}");
358358
await FileUtility.WriteAsync(path, content);
359359
}
360360
else if (!offline && offlineFileExists)

src/WebJobs.Script.WebHost/Standby/StandbyManager.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -199,17 +199,17 @@ private async Task CreateStandbyWarmupFunctions()
199199
await FileUtility.DeleteDirectoryAsync(scriptPath, true);
200200
FileUtility.EnsureDirectoryExists(scriptPath);
201201

202-
string content = FileUtility.ReadResourceString($"{ScriptConstants.ResourcePath}.Functions.host.json");
202+
string content = FileUtility.ReadResourceString($"{ScriptConstants.WebHostResourcePath}.Functions.host.json");
203203
File.WriteAllText(Path.Combine(scriptPath, "host.json"), content);
204204

205-
content = FileUtility.ReadResourceString($"{ScriptConstants.ResourcePath}.Functions.proxies.json");
205+
content = FileUtility.ReadResourceString($"{ScriptConstants.WebHostResourcePath}.Functions.proxies.json");
206206
File.WriteAllText(Path.Combine(scriptPath, "proxies.json"), content);
207207

208208
string functionPath = Path.Combine(scriptPath, WarmUpConstants.FunctionName);
209209
Directory.CreateDirectory(functionPath);
210-
content = FileUtility.ReadResourceString($"{ScriptConstants.ResourcePath}.Functions.{WarmUpConstants.FunctionName}.function.json");
210+
content = FileUtility.ReadResourceString($"{ScriptConstants.WebHostResourcePath}.Functions.{WarmUpConstants.FunctionName}.function.json");
211211
File.WriteAllText(Path.Combine(functionPath, "function.json"), content);
212-
content = FileUtility.ReadResourceString($"{ScriptConstants.ResourcePath}.Functions.{WarmUpConstants.FunctionName}.run.csx");
212+
content = FileUtility.ReadResourceString($"{ScriptConstants.WebHostResourcePath}.Functions.{WarmUpConstants.FunctionName}.run.csx");
213213
File.WriteAllText(Path.Combine(functionPath, "run.csx"), content);
214214

215215
_logger.LogInformation($"StandbyMode placeholder function directory created");

src/WebJobs.Script.WebHost/WebJobs.Script.WebHost.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.NET.Sdk.Web">
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
22
<Import Project="..\..\build\common.props" />
33
<Import Project="..\..\build\python.props" />
44
<PropertyGroup>
@@ -59,7 +59,7 @@
5959
<PackageReference Include="Microsoft.Azure.AppService.Proxy.Client" Version="2.0.8100001-0126c21e" />
6060
<PackageReference Include="Microsoft.Azure.Services.AppAuthentication" Version="1.0.3" />
6161
<PackageReference Include="Microsoft.Azure.Storage.File" Version="11.1.7" />
62-
<PackageReference Include="Microsoft.Azure.WebJobs" Version="3.0.23" />
62+
<PackageReference Include="Microsoft.Azure.WebJobs" Version="3.0.25" />
6363
<PackageReference Include="Microsoft.Azure.WebJobs.Host.Storage" Version="4.0.1" />
6464
<PackageReference Include="Microsoft.Azure.KeyVault" Version="3.0.3" />
6565
<PackageReference Include="Microsoft.Azure.WebJobs.Logging" Version="4.0.1" />

src/WebJobs.Script/Diagnostics/Extensions/LoggerExtension.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Licensed under the MIT License. See License.txt in the project root for license information.
33

44
using System;
5+
using Microsoft.Azure.WebJobs.Script.Description;
56
using Microsoft.Extensions.Logging;
67

78
namespace Microsoft.Azure.WebJobs.Script.Diagnostics.Extensions
@@ -208,6 +209,12 @@ internal static class LoggerExtension
208209
new EventId(331, nameof(JobHostFunctionTimeoutNotSet)),
209210
"FunctioTimeout is not set.");
210211

212+
private static readonly Action<ILogger, string, Exception> _logSharedFxAssembliesInBin =
213+
LoggerMessage.Define<string>(
214+
LogLevel.Debug,
215+
new EventId(333, nameof(LogSharedFxAssembliesInBin)),
216+
"{logMessage}.");
217+
211218
public static void ExtensionsManagerRestoring(this ILogger logger)
212219
{
213220
_extensionsManagerRestoring(logger, null);
@@ -379,5 +386,10 @@ public static void JobHostFunctionTimeoutNotSet(this ILogger logger)
379386
{
380387
_jobHostFunctionTimeoutNotSet(logger, null);
381388
}
389+
390+
public static void LogSharedFxAssembliesInBin(this ILogger logger, string assemblyNames)
391+
{
392+
_logSharedFxAssembliesInBin(logger, assemblyNames, null);
393+
}
382394
}
383395
}

src/WebJobs.Script/Host/ScriptHost.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,8 @@ public async Task InitializeAsync(CancellationToken cancellationToken = default)
295295
}
296296

297297
_metricsLogger.LogEvent(string.Format(MetricEventNames.HostStartupRuntimeLanguage, runtimeStack));
298+
299+
Utility.LogSharedFxAssembliesInScriptRootPath(ScriptOptions.RootScriptPath, _workerRuntime, functionMetadataList, _logger);
298300
}
299301

300302
var directTypes = GetDirectTypes(functionMetadataList);
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
e_sqlite3.dll
2+
libuv.dll
3+
MessagePack.dll
4+
Microsoft.AI.DependencyCollector.dll
5+
Microsoft.ApplicationInsights.AspNetCore.dll
6+
Microsoft.ApplicationInsights.dll
7+
Microsoft.AspNetCore.ApplicationInsights.HostingStartup.dll
8+
Microsoft.AspNetCore.AzureAppServices.HostingStartup.dll
9+
Microsoft.AspNetCore.AzureAppServicesIntegration.dll
10+
Microsoft.AspNetCore.DataProtection.AzureKeyVault.dll
11+
Microsoft.AspNetCore.DataProtection.AzureStorage.dll
12+
Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.dll
13+
Microsoft.AspNetCore.SignalR.Redis.dll
14+
Microsoft.Azure.KeyVault.dll
15+
Microsoft.Azure.KeyVault.WebKey.dll
16+
Microsoft.Azure.Services.AppAuthentication.dll
17+
Microsoft.Data.Edm.dll
18+
Microsoft.Data.OData.dll
19+
Microsoft.Data.Sqlite.dll
20+
Microsoft.EntityFrameworkCore.Sqlite.dll
21+
Microsoft.Extensions.Caching.Redis.dll
22+
Microsoft.Extensions.Configuration.AzureKeyVault.dll
23+
Microsoft.Extensions.Logging.AzureAppServices.dll
24+
Microsoft.Extensions.PlatformAbstractions.dll
25+
Microsoft.IdentityModel.Clients.ActiveDirectory.dll
26+
Microsoft.IdentityModel.Clients.ActiveDirectory.Platform.dll
27+
Microsoft.Rest.ClientRuntime.Azure.dll
28+
Microsoft.Rest.ClientRuntime.dll
29+
Microsoft.VisualStudio.Web.BrowserLink.dll
30+
Microsoft.WindowsAzure.Storage.dll
31+
SQLitePCLRaw.batteries_green.dll
32+
SQLitePCLRaw.batteries_v2.dll
33+
SQLitePCLRaw.core.dll
34+
SQLitePCLRaw.provider.e_sqlite3.dll
35+
StackExchange.Redis.StrongName.dll
36+
System.Spatial.dll
37+
mscordaccore_amd64_amd64_4.6.28207.03.dll
38+
sos.dll
39+
sos.netcore.dll
40+
sos_amd64_amd64_4.6.28207.03.dll
41+
microsoft.aspnetcore.authentication.facebook.dll
42+
microsoft.aspnetcore.authentication.google.dll
43+
microsoft.aspnetcore.authentication.jwtbearer.dll
44+
microsoft.aspnetcore.authentication.microsoftaccount.dll
45+
microsoft.aspnetcore.authentication.openidconnect.dll
46+
microsoft.aspnetcore.authentication.twitter.dll
47+
microsoft.aspnetcore.authentication.wsfederation.dll
48+
microsoft.aspnetcore.diagnostics.entityframeworkcore.dll
49+
microsoft.aspnetcore.identity.entityframeworkcore.dll
50+
microsoft.aspnetcore.identity.ui.dll
51+
microsoft.aspnetcore.identity.ui.views.v3.dll
52+
microsoft.aspnetcore.identity.ui.views.v4.dll
53+
microsoft.aspnetcore.jsonpatch.dll
54+
microsoft.aspnetcore.middlewareanalysis.dll
55+
microsoft.aspnetcore.mvc.razor.extensions.dll
56+
microsoft.aspnetcore.nodeservices.dll
57+
microsoft.aspnetcore.owin.dll
58+
microsoft.aspnetcore.razor.language.dll
59+
microsoft.aspnetcore.server.kestrel.https.dll
60+
microsoft.aspnetcore.server.kestrel.transport.abstractions.dll
61+
microsoft.aspnetcore.spaservices.dll
62+
microsoft.aspnetcore.spaservices.extensions.dll
63+
microsoft.codeanalysis.csharp.dll
64+
microsoft.codeanalysis.dll
65+
microsoft.codeanalysis.razor.dll
66+
microsoft.dotnet.platformabstractions.dll
67+
microsoft.entityframeworkcore.abstractions.dll
68+
microsoft.entityframeworkcore.design.dll
69+
microsoft.entityframeworkcore.dll
70+
microsoft.entityframeworkcore.inmemory.dll
71+
microsoft.entityframeworkcore.relational.dll
72+
microsoft.entityframeworkcore.sqlserver.dll
73+
microsoft.extensions.caching.sqlserver.dll
74+
microsoft.extensions.dependencymodel.dll
75+
microsoft.extensions.diagnosticadapter.dll
76+
microsoft.identitymodel.jsonwebtokens.dll
77+
microsoft.identitymodel.logging.dll
78+
microsoft.identitymodel.protocols.dll
79+
microsoft.identitymodel.protocols.openidconnect.dll
80+
microsoft.identitymodel.protocols.wsfederation.dll
81+
microsoft.identitymodel.tokens.dll
82+
microsoft.identitymodel.tokens.saml.dll
83+
microsoft.identitymodel.xml.dll
84+
newtonsoft.json.bson.dll
85+
newtonsoft.json.dll
86+
remotion.linq.dll
87+
sni.dll
88+
system.data.sqlclient.dll
89+
system.identitymodel.tokens.jwt.dll
90+
system.interactive.async.dll
91+
system.net.http.formatting.dll
92+
system.net.websockets.websocketprotocol.dll
93+
system.runtime.compilerservices.unsafe.dll
94+
system.text.encoding.codepages.dll
95+
system.text.encodings.web.dll
96+
system.threading.channels.dll

src/WebJobs.Script/ScriptConstants.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ public static class ScriptConstants
7878
public const string AppOfflineFileName = "app_offline.htm";
7979
public const string RunFromPackageFailedFileName = "FAILED TO INITIALIZE RUN FROM PACKAGE.txt";
8080
public const string DisableContainerFileName = "container_offline";
81-
public const string ResourcePath = "Microsoft.Azure.WebJobs.Script.WebHost.Resources";
81+
public const string WebHostResourcePath = "Microsoft.Azure.WebJobs.Script.WebHost.Resources";
82+
public const string ScriptResourcePath = "Microsoft.Azure.WebJobs.Script.Resources";
8283

8384
public const string DefaultMasterKeyName = "master";
8485
public const string DefaultFunctionKeyName = "default";

src/WebJobs.Script/Utility.cs

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
using System.Text.RegularExpressions;
1616
using System.Threading;
1717
using System.Threading.Tasks;
18-
using Microsoft.Azure.WebJobs.Host;
1918
using Microsoft.Azure.WebJobs.Logging;
2019
using Microsoft.Azure.WebJobs.Script.Description;
20+
using Microsoft.Azure.WebJobs.Script.Diagnostics.Extensions;
2121
using Microsoft.Azure.WebJobs.Script.Workers.Rpc;
2222
using Microsoft.Extensions.Logging;
2323
using Newtonsoft.Json;
@@ -805,6 +805,62 @@ public static void ValidateRetryOptions(RetryOptions
805805
}
806806
}
807807

808+
public static void LogSharedFxAssembliesInScriptRootPath(string rootScriptPath, string workerRuntime, IEnumerable<FunctionMetadata> functionMetadataList, ILogger logger)
809+
{
810+
if (string.IsNullOrEmpty(workerRuntime))
811+
{
812+
return;
813+
}
814+
815+
if (functionMetadataList == null || !functionMetadataList.Any())
816+
{
817+
return;
818+
}
819+
820+
// Skip logging for non-dotnet apps
821+
if (!workerRuntime.Equals(RpcWorkerConstants.DotNetLanguageWorkerName, StringComparison.OrdinalIgnoreCase))
822+
{
823+
return;
824+
}
825+
826+
StringBuilder assembliesExistLog = new StringBuilder();
827+
bool containsScriptFunctionsOnly = functionMetadataList.All(f => !string.IsNullOrEmpty(f.Language) && f.Language.Equals(DotNetScriptTypes.CSharp));
828+
assembliesExistLog.Append($"ContainsCsxFunctionsOnly: '{containsScriptFunctionsOnly}';");
829+
830+
string binDir = Path.Combine(rootScriptPath, "bin");
831+
if (FileUtility.DirectoryExists(binDir))
832+
{
833+
string depsFilePath = Path.Combine(binDir, DotNetConstants.FunctionsDepsFileName);
834+
if (!containsScriptFunctionsOnly && !FileUtility.FileExists(depsFilePath))
835+
{
836+
assembliesExistLog.Append($"File: '{DotNetConstants.FunctionsDepsFileName}' does not exist.");
837+
}
838+
839+
// Removed assemblies list includes :
840+
// 1. Assemblies present in Microsoft.AspNetCore.App\2.2.8 but removed from Microsoft.AspNetCore.App\3.1.*
841+
// 2. Assemblies present in Microsoft.AspNetCore.All\2.2.8 as this folder does not exist in .Net Core > 3.0.*
842+
// 3. Assemblies present in Microsoft.NETCore.App\2.2.8 but removed from Microsoft.NETCore.App\3.1.*
843+
var removedAssembliesString = FileUtility.ReadResourceString($"{ScriptConstants.ScriptResourcePath}.AssembliesRemoved.txt");
844+
StringReader strReader = new StringReader(removedAssembliesString);
845+
string sharedFxAssembly = strReader.ReadLine();
846+
assembliesExistLog.Append($"SharedFxAssemblies in bin folder: ");
847+
do
848+
{
849+
string filePath = Path.Combine(binDir, sharedFxAssembly);
850+
if (FileUtility.FileExists(filePath))
851+
{
852+
assembliesExistLog.Append($" '{sharedFxAssembly}'; ");
853+
}
854+
sharedFxAssembly = strReader.ReadLine();
855+
}
856+
while (sharedFxAssembly != null);
857+
}
858+
if (assembliesExistLog.Length > 0)
859+
{
860+
logger.LogSharedFxAssembliesInBin(assembliesExistLog.ToString());
861+
}
862+
}
863+
808864
private class FilteredExpandoObjectConverter : ExpandoObjectConverter
809865
{
810866
public override bool CanWrite => true;

0 commit comments

Comments
 (0)