Access issue with old Microsoft.Practices.EnterpriseLibrary.Data when running from Azure App Service

Gola, Mariusz 45 Reputation points
2023-07-19T18:12:50.9733333+00:00

Hi and thank you in advance.

We have an older asp.net 4.5 web form application we are migrating to Azure App Service. After deploying it to the app service we are getting the following error related to an older Microsoft.Practices.EnterpriseLibrary.Data, please see below.

The source was not found, but some or all event logs could not be searched. To create the source, you need permission to read all event logs to make sure that the new source name is unique. Inaccessible logs: Security.    at System.Diagnostics.EventLog.FindSourceRegistration(String source, String machineName, Boolean readOnly, Boolean wantToCreate)    at System.Diagnostics.EventLog.SourceExists(String source, String machineName, Boolean wantToCreate)    at System.Diagnostics.EventLogInternal.VerifyAndCreateSource(String sourceName, String currentMachineName)    at System.Diagnostics.EventLogInternal.WriteEntry(String message, EventLogEntryType type, Int32 eventID, Int16 category, Byte[] rawData)    at System.Diagnostics.EventLog.WriteEntry(String message, EventLogEntryType type)    at Microsoft.Practices.EnterpriseLibrary.Common.Instrumentation.PerformanceCounterInstances.ReportCounterFailure(String message)    at Microsoft.Practices.EnterpriseLibrary.Common.Instrumentation.PerformanceCounterInstances..ctor(String categoryName, String counterName, Boolean createNewInstance)    at Microsoft.Practices.EnterpriseLibrary.Common.Instrumentation.InstrumentedEvent.AddPerformanceCounter(String category, String[] counterNames, Boolean createNewInstance)    at Microsoft.Practices.EnterpriseLibrary.Common.Instrumentation.InstrumentedEvent.Initialize(String counterCategory, String[] counterNames, Boolean createNewInstance, String eventLogSource, EventLogIdentifier[] eventIds)    at Microsoft.Practices.EnterpriseLibrary.Common.Instrumentation.InstrumentedEvent..ctor(String counterCategory, String[] counterNames, Boolean createNewInstance, String eventLogSource, EventLogIdentifier[] eventIds)    at Microsoft.Practices.EnterpriseLibrary.Data.Instrumentation.DataServiceEvent..ctor(String[] counterNames, EventLogIdentifier[] eventLogIds)    at Microsoft.Practices.EnterpriseLibrary.Data.Instrumentation.DataConnectionFailedEvent..ctor(String[] counterNames, EventLogIdentifier[] eventLogIDs)    at Microsoft.Practices.EnterpriseLibrary.Data.Instrumentation.DataConnectionFailedEvent..cctor()

From my findings there is a permissions issue of trying to write the logs within the Microsoft.Practices.EnterpriseLibrary.Data library. It works as expected running in VS2022 as admin.

Please advise,

Mariusz

Thank you

External resource

https://stackoverflow.com/questions/20389248/the-source-was-not-found-but-some-or-all-event-logs-could-not-be-searched-inac

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
8,939 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

  2. ajkuma 28,036 Reputation points Microsoft Employee Moderator
    2023-07-25T19:02:06.15+00:00

    Thanks for the follow-up and update.

    All Azure Web Apps (as well as Mobile App/Services, WebJobs and Functions) run in a secure environment called a sandbox.

    Azure App Service does not allow the registration of COM components on the platform. If your app makes use of any COM components, these need to be rewritten in managed code and deployed with the site or application.
    Apps are not permitted to read from or write to the Event Log service.

    Microsoft.Practices.EnterpriseLibrary.Data - The Database class leverages the provider factory model from ADO.NET.

    Areas of diagnostics logging and tracing that aren't available to apps are Windows ETW events and common Windows event logs (for example, System, Application, and Security event logs). Since ETW trace information can potentially be viewable machine-wide (with the right ACLs), read and write access to ETW events are blocked.

    You may checkout the approach outlined in this doc:

    Migrate your .NET web app or service to Azure App Service
    Migrate ASP.NET Web App to Azure App Service

    If your app cannot be migrated directly to App Service, consider App Service using Windows Containers, which enables usage of the GAC, COM components, MSIs, full access to .NET FX APIs, DirectX, and more.

    Reference: Operating system functionality on Azure App Service

    0 comments No comments

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.