You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Logging improvements to DiagnosticEventTableStorageRepository (#10996)
* Moving logging to defined methods in DiagnosticEventsTableStorageRepository. Disabling service when the client is not authorized to use the table storage service.
* Disable service when we fail to write events due to permissions.
Check first for initialized _tableClient.
* Added test for permissions via using AzuriteFixture
* Improved messages and disabled the service in more cases
* Cleanup comments
* Deleting test table to verify delete tables permission.
* PR feedback
* Add release notes
"We couldn’t initialize the Table Storage Client using the 'AzureWebJobsStorage' connection string. We are unable to record diagnostic events, so the diagnostic logging service is being stopped. Please check the 'AzureWebJobsStorage' connection string in Application Settings.");
"We couldn’t access the Table service in the Azure Storage account defined by the 'AzureWebJobsStorage' setting. We are unable to record diagnostic events, so the diagnostic logging service is being stopped. Please ensure the connection string or managed identity has permissions to access the Table service and that any network rules allow connectivity. If you're using an identity-based connection, make sure it has been assigned the 'Storage Table Data Contributor' role.");
"We couldn’t reach the Table service endpoint specified in the 'AzureWebJobsStorage' setting. We are unable to record diagnostic events, so the diagnostic logging service is being stopped. Please confirm network connectivity and endpoint accessibility.");
LoggerMessage.Define<string>(LogLevel.Debug,newEventId(4,nameof(PurgingDiagnosticEvents)),"Purging diagnostic events with versions older than '{currentEventVersion}'.");
LoggerMessage.Define<string>(LogLevel.Debug,newEventId(5,nameof(DeletingTableWithoutEventVersion)),"Deleting table '{tableName}' as it contains records without an EventVersion.");
LoggerMessage.Define<string>(LogLevel.Debug,newEventId(6,nameof(DeletingTableWithOutdatedEventVersion)),"Deleting table '{tableName}' as it contains records with an outdated EventVersion.");
LoggerMessage.Define(LogLevel.Error,newEventId(7,nameof(ErrorPurgingDiagnosticEventVersions)),"Error occurred when attempting to purge previous diagnostic event versions.");
LoggerMessage.Define(LogLevel.Error,newEventId(9,nameof(UnableToGetTableReferenceOrCreateTable)),"Unable to get table reference or create table. Aborting write operation.");
LoggerMessage.Define(LogLevel.Debug,newEventId(11,nameof(PrimaryHostStateProviderNotAvailable)),"PrimaryHostStateProvider is not available. Skipping the check for primary host.");
_logger.LogWarning("An error occurred initializing the Table Storage Client. We are unable to record diagnostic events, so the diagnostic logging service is being stopped.");
// TableClient is initialized lazily and it will stop the timer that schedules flush logs whenever it fails to initialize.
171
211
// We need to check if the TableClient is null before proceeding. This helps when the first time the property is accessed is as part of the FlushLogs method.
172
212
// We should not have any events stored pending to be written since WriteDiagnosticEvent will check for an initialized TableClient.
// If we reach this point, we already checked for permissions on TableClient initialization. It is possible that the permissions changed after the initialization or any storage firewall/network configuration changed.
// If we reach this point, we already checked for permissions on TableClient initialization.
286
+
// It is possible that the permissions changed after the initialization, any firewall/network rules were changed or it's a custom role where we don't have permissions to write entities.
0 commit comments