Hi @Muriuki, Levi M Welcome to the Microsoft Q&A and thank you for posting your questions here.
You are asking on how to log information about the user that performed an action on a Service Fabric cluster.
Yes, you can log information about the user who performed an action on a Service Fabric cluster, including actions like deleting an application.
The first thing that should come to mind on how to achieve this is Azure Application Insights. Ensure that Application Insights is enabled for your Service Fabric application. You can do this during application setup or by adding it later through Azure portal or ARM templates.
You can also implement Instrumentation in code within your Service Fabric application code.
Thirdly, you can log the user information along with the action details when an action is performed.
Since you're using Azure AD or Entra ID for authentication and assigning roles, you can leverage the claims provided by these identity providers to capture user information.
This is an example of how you might log user information when deleting an application, if you're a developer using C#:
// Example code snippet in C#
// Assuming you have access to the current request's claims principal
var user = ClaimsPrincipal.Current.Identity.Name; // Retrieve user's identity from claims
// Log the user's action along with their identity
TelemetryClient telemetryClient = new TelemetryClient();
telemetryClient.TrackEvent("ApplicationDeleted", new Dictionary<string, string> {
{ "User", user },
{ "ApplicationId", applicationId } // Assuming you have the application ID as well
});
telemetryClient.Flush(); // Ensure logs are sent immediately
Remember, this is a basic example, and you'll need to adapt it to fit your specific application structure and logging requirements. I hope this is helpful! Do not hesitate to let me know if you have any other questions. Please remember to "Accept Answer" if answer helped, so that others in the community facing similar issues can easily find the solution. Best Regards, Sina