Logging no longer working on Azure App Service

Hardin, Rich 31 Reputation points
2022-10-25T23:59:34.27+00:00

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:
254085-image.png

    // 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>();  
            });  
    }  
}  
Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
8,961 questions
0 comments No comments
{count} votes

Accepted answer
  1. Alexander Zhu 81 Reputation points Microsoft Employee
    2022-11-10T00:36:12.56+00:00

    Hi @Hardin, Rich , we found this is a product bug in app service's site extension version 7.0.0-rc.2.22476.2. When you install site extension 'ASP.NET Core Logging Integration' with the version 7.0.0-rc.2.22476.2, you will encounter the issue.

    Solution:
    And our product team already published version 6.0.11 to replace 7.0.0-rc.2.22476.2. Version 7.0.0 is not ready yet. Now, by default you will install site extension 'ASP.NET Core Logging Integration' with the version 6.0.11 in portal or kudu.
    258932-image.png

    Also, if you install nuget package 'Microsoft.Extensions.Logging.AzureAppServices' in VS, please also install the same version as the site extension 6.0.11. Different versions might cause conflicts.
    258941-1.png

    1 person found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Hardin, Rich 31 Reputation points
    2022-10-27T19:56:57.323+00:00

    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 <filename>.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!


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.