To log actual application admin users in Azure SQL audit logs instead of the authenticated Entra ID admin, you can consider the following approaches:
- Custom Application-Level Logging: Implement a logging mechanism within your application that records which specific admin performed an action. This can be done by capturing the admin's identity at the application level and storing this information in a separate log or database table. This way, even if the audit logs show the Entra ID admin, you will have a record of which admin initiated the action.
- Use of Separate Database Users: While you mentioned that using separate database users for each admin might not fully solve the problem due to how Azure SQL logs the authenticated user, it could still be beneficial to create distinct database users for different roles (e.g., Admin A and Admin B). You can then implement a mechanism to switch users based on the action being performed. However, this approach may require more complex connection management.
- Service Accounts: As you suggested, using different service accounts for customer-related queries and admin-related queries can help. This way, you can have one service account for general operations and another for admin tasks, which can help in segregating logs based on the type of operation.
- Audit Configuration: Ensure that your audit logging is configured correctly to capture the necessary details. While Azure SQL does log the authenticated user, you might want to explore additional logging features or settings that could provide more granular insights.
Ultimately, the best solution may involve a combination of these strategies. Implementing application-level logging is crucial to ensure you can track actions performed by individual admins, while also considering how to manage database connections effectively.
References: