How to get the user information like location, machine name or client IP, application name or source etc., when accessing and querying Azure SQL using Logs?

VeeraGanesh Ponnada 0 Reputation points
2024-05-20T19:40:01.02+00:00

Trace the user information when executes sql queries on Azure SQL

Azure Monitor
Azure Monitor
An Azure service that is used to collect, analyze, and act on telemetry data from Azure and on-premises environments.
3,651 questions
Azure
Azure
A cloud computing platform and infrastructure for building, deploying and managing applications and services through a worldwide network of Microsoft-managed datacenters.
1,435 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Monalla-MSFT 13,071 Reputation points Moderator
    2024-05-21T02:44:55.46+00:00

    @Veera Ganesh - Welcome to Microsoft Q&A and thanks for reaching out to us.

    You can use Azure Monitor Logs. Azure Monitor Logs provides a way to collect, analyze, and query log data from various sources, including Azure SQL.

    To get user information, you can use the sys.fn_get_audit_file function to query the audit logs.

    This query retrieves information about successful SELECT statements executed on the server, including the client IP, application name, and server and database principal names.

    The audit logs contain information about all the events that occur on the server, including successful and failed login attempts, and the IP address of the client machine.

    Hope this helps. and please feel free to reach out if you have any further questions.


    Please don't forget to "Accept as Answer" and click "Yes" if the above response is helpful, so it can be beneficial to the community.

    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.