I have a code base that is running on two separate app services. The first is logging fine with version 6.0.8 of the ASP.NET Core Logging Integration. The second which has ASP.NET Core Logging Integration 7.0.0-rc-2-22476-2 is not working. I get the following error when the web service starts:
2022-10-25T21:07:05 sandboxproc.exe D:\DWASFiles\Sites\teams1stdevelopment\Temp\applicationhost.config True True
2022-10-25T21:07:05 env XPROC_TYPENAME=Microsoft.Web.Hosting.Transformers.ApplicationHost.SiteExtensionHelper, Microsoft.Web.Hosting, Version=7.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
2022-10-25T21:07:05 env XPROC_METHODNAME=Transform
2022-10-25T21:07:05 Start 'Microsoft.AspNetCore.AzureAppServices.SiteExtension' site extension transform
2022-10-25T21:07:05 StartSection Executing InsertIfMissing (transform line 7, 23)
2022-10-25T21:07:05 on /configuration/system.webServer
2022-10-25T21:07:05 Applying to 'configuration' element (no source line info)
2022-10-25T21:07:05 EndSection Done executing InsertIfMissing
2022-10-25T21:07:05 StartSection Executing InsertIfMissing (transform line 8, 16)
2022-10-25T21:07:05 on /configuration/system.webServer/runtime
2022-10-25T21:07:05 Applying to 'system.webServer' element (no source line info)
2022-10-25T21:07:05 Inserted 'runtime' element
2022-10-25T21:07:05 EndSection Done executing InsertIfMissing
2022-10-25T21:07:05 StartSection Executing InsertIfMissing (transform line 9, 31)
2022-10-25T21:07:05 on /configuration/system.webServer/runtime/environmentVariables
2022-10-25T21:07:05 Applying to 'runtime' element (no source line info)
2022-10-25T21:07:05 EndSection Done executing InsertIfMissing
2022-10-25T21:07:05 :(10,406), Microsoft.Web.XmlTransform.XmlNodeException: Could not resolve 'InsertOrAppendAttribute' as a type of Transform ---> Microsoft.Web.XmlTransform.XmlTransformationException: Could not resolve 'InsertOrAppendAttribute' as a type of Transformat Microsoft.Web.XmlTransform.NamedTypeFactory.Construct[ObjectType](String typeName)at Microsoft.Web.XmlTransform.XmlElementContext.CreateObjectFromAttribute[ObjectType](String& argumentString, XmlAttribute& objectAttribute)--- End of inner exception stack trace ---at Microsoft.Web.XmlTransform.XmlElementContext.ConstructTransform(String& argumentString)at Microsoft.Web.XmlTransform.XmlTransformation.HandleElement(XmlElementContext context)at Microsoft.Web.XmlTransform.XmlTransformation.TransformLoop(XmlNodeContext parentContext)
2022-10-25T21:07:05 :(11,158), Microsoft.Web.XmlTransform.XmlNodeException: Could not resolve 'InsertOrAppendAttribute' as a type of Transform ---> Microsoft.Web.XmlTransform.XmlTransformationException: Could not resolve 'InsertOrAppendAttribute' as a type of Transformat Microsoft.Web.XmlTransform.NamedTypeFactory.Construct[ObjectType](String typeName)at Microsoft.Web.XmlTransform.XmlElementContext.CreateObjectFromAttribute[ObjectType](String& argumentString, XmlAttribute& objectAttribute)--- End of inner exception stack trace ---at Microsoft.Web.XmlTransform.XmlElementContext.ConstructTransform(String& argumentString)at Microsoft.Web.XmlTransform.XmlTransformation.HandleElement(XmlElementContext context)at Microsoft.Web.XmlTransform.XmlTransformation.TransformLoop(XmlNodeContext parentContext)
2022-10-25T21:07:05 :(12,146), Microsoft.Web.XmlTransform.XmlNodeException: Could not resolve 'InsertOrAppendAttribute' as a type of Transform ---> Microsoft.Web.XmlTransform.XmlTransformationException: Could not resolve 'InsertOrAppendAttribute' as a type of Transformat Microsoft.Web.XmlTransform.NamedTypeFactory.Construct[ObjectType](String typeName)at Microsoft.Web.XmlTransform.XmlElementContext.CreateObjectFromAttribute[ObjectType](String& argumentString, XmlAttribute& objectAttribute)--- End of inner exception stack trace ---at Microsoft.Web.XmlTransform.XmlElementContext.ConstructTransform(String& argumentString)at Microsoft.Web.XmlTransform.XmlTransformation.HandleElement(XmlElementContext context)at Microsoft.Web.XmlTransform.XmlTransformation.TransformLoop(XmlNodeContext parentContext)
2022-10-25T21:07:05 Fail 'Microsoft.AspNetCore.AzureAppServices.SiteExtension' site extension transform
2022-10-25T21:07:05 sandboxproc.exe Elapsed = 426.00 ms failed with System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.InvalidOperationException: Fail transforming applicationHost.config with 'C:\home\SiteExtensions\Microsoft.AspNetCore.AzureAppServices.SiteExtension\applicationHost.xdt' with :(10,406), Microsoft.Web.XmlTransform.XmlNodeException: Could not resolve 'InsertOrAppendAttribute' as a type of Transform ---> Microsoft.Web.XmlTransform.XmlTransformationException: Could not resolve 'InsertOrAppendAttribute' as a type of Transformat Microsoft.Web.XmlTransform.NamedTypeFactory.Construct[ObjectType](String typeName)at Microsoft.Web.XmlTransform.XmlElementContext.CreateObjectFromAttribute[ObjectType](String& argumentString, XmlAttribute& objectAttribute)--- End of inner exception stack trace ---at Microsoft.Web.XmlTransform.XmlElementContext.ConstructTransform(String& argumentString)at Microsoft.Web.XmlTransform.XmlTransformation.HandleElement(XmlElementContext context)at Microsoft.Web.XmlTransform.XmlTransformation.TransformLoop(XmlNodeContext parentContext):(11,158), Microsoft.Web.XmlTransform.XmlNodeException: Could not resolve 'InsertOrAppendAttribute' as a type of Transform ---> Microsoft.Web.XmlTransform.XmlTransformationException: Could not resolve 'InsertOrAppendAttribute' as a type of Transformat Microsoft.Web.XmlTransform.NamedTypeFactory.Construct[ObjectType](String typeName)at Microsoft.Web.XmlTransform.XmlElementContext.CreateObjectFromAttribute[ObjectType](String& argumentString, XmlAttribute& objectAttribute)--- End of inner exception stack trace ---at Microsoft.Web.XmlTransform.XmlElementContext.ConstructTransform(String& argumentString)at Microsoft.Web.XmlTransform.XmlTransformation.HandleElement(XmlElementContext context)at Microsoft.Web.XmlTransform.XmlTransformation.TransformLoop(XmlNodeContext parentContext):(12,146), Microsoft.Web.XmlTransform.XmlNodeException: Could not resolve 'InsertOrAppendAttribute' as a type of Transform ---> Microsoft.Web.XmlTransform.XmlTransformationException: Could not resolve 'InsertOrAppendAttribute' as a type of Transformat Microsoft.Web.XmlTransform.NamedTypeFactory.Construct[ObjectType](String typeName)at Microsoft.Web.XmlTransform.XmlElementContext.CreateObjectFromAttribute[ObjectType](String& argumentString, XmlAttribute& objectAttribute)--- End of inner exception stack trace ---at Microsoft.Web.XmlTransform.XmlElementContext.ConstructTransform(String& argumentString)at Microsoft.Web.XmlTransform.XmlTransformation.HandleElement(XmlElementContext context)at Microsoft.Web.XmlTransform.XmlTransformation.TransformLoop(XmlNodeContext parentContext)at Microsoft.Web.Hosting.Transformers.ApplicationHost.SiteExtensionDefinition.Transform(XmlDocument document, IDictionary`2 environments, Boolean isMainSite, Boolean separateProcessForScm)at Microsoft.Web.Hosting.Transformers.ApplicationHost.SiteExtensionHelper.Transform(XmlDocument doc, List`1 definitions, IDictionary`2 environments, Boolean isMainSite, Boolean separateProcessForScm)at Microsoft.Web.Hosting.Transformers.ApplicationHost.SiteExtensionHelper.Transform(String appHostConfig, String isMainSiteStr, String separateProcessForScmStr)--- End of inner exception stack trace ---at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)at Microsoft.Web.Hosting.ProcessModel.Program.Main(String[] args)
Installed Packages:
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
using Azure.Identity;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using System;
namespace Microsoft.BotBuilderSamples
{
public class Program
{
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureAppConfiguration((context, config) =>
{
var keyVaultEndpoint = new Uri(Environment.GetEnvironmentVariable("VaultUri"));
config.AddAzureKeyVault(keyVaultEndpoint, new DefaultAzureCredential());
})
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.ConfigureLogging((logging) =>
{
logging.AddDebug();
logging.AddConsole();
});
webBuilder.UseStartup<Startup>();
});
}
}
The band-aid fix for this is to go back to a different revision of the ASP.NET Core Logging Integration. I (fortunately!) had one app service that had not been upgraded. I'm not sure if there is another way to recreate this from source.
First download the "good" extension (in this case 6.0.8)
Select Advanced Tools in the App Service
From KUDU, select Debug console -> CMD
Click SiteExtensions
Click the "Download" button to the left of Microsoft.AspNetCore.AzureAppServices.SiteExtension
This will create a .zip file in your downloads directory.
Now follow the same steps as above to get to the SiteExtensions directory in your "bad" app service.
Click on Microsoft.AspNetCore.AzureAppServices.SiteExtension
Delete everything within this directory (using icons to the left)
Drag and drop the .zip file from the downloads directory to the KUDU web interface.
In the cmd window below type "unzip .zip", with the filename of the .zip file that was created from the download.
Now restart the service and logging will once again flourish! I have a service ticket with Microsoft alerting them to this issue. Will try to post again if they get it fixed!