Manage Access Audits¶
The Microsoft SQL Server connector provides access auditing capabilities to help organizations track user activity, ensure compliance, and enhance security monitoring. This feature allows you to collect and process audit logs from Microsoft SQL Server audit files. Audit logs can be stored in Azure Blob Storage (for Azure SQL) or in local file systems (for on-premises SQL Server installations).
Audit Configuration¶
Audit Enable: Enables audit logs for the Microsoft SQL Server connector. Set this property to true to enable audit logs.
Storage URL: Specifies the storage location where SQL Server audit logs are stored. For Azure SQL, this should be an Azure Blob Storage URL. For on-premises SQL Server, this should be the local file system path where audit logs are written. For Azure Blob Storage, the URL format should be: https://<storage_account>.blob.core.windows.net/<container>/<mssql_server_name>.
- Example:
https://sqlaudit.blob.core.windows.net/sqldbauditlogs/my-sql-server
Important
The <mssql_server_name> portion of the URL must be your actual MSSQL server name. You can find this by checking your Azure Blob Storage container - the server name will appear as a directory inside the container. See the Verify Audit Configuration section below for details.
Audit Load Key: Specifies the audit loading mechanism used by the connector. This property determines how audit logs are processed:
load: Use this value for standard Microsoft SQL Server databases.load_synapse: Use this value for Azure Synapse Analytics databases.
Audit Initial Pull Minutes: Specifies the number of minutes in the past from which to start pulling audit logs when the connector first runs. This helps ensure that historical audit data is captured. Default: 30 minutes.
Audit Excluded Users: Comma-separated list of users to exclude from audit processing. Audit logs for these users will not be processed by the connector. This is useful for excluding service accounts or administrative users from audit collection.
- Example:
admin_user,service_account@domain.com
Audit Sync Interval: Specifies the interval (in seconds) at which the connector synchronizes and processes audit logs. Default: 30 seconds.
Prerequisites¶
Before configuring access audits, you need to set up SQL Server auditing in Azure. Follow these steps:
Enable Azure SQL Auditing¶
- Log in to the Azure portal.
- Search for the SQL Servers in which you want to configure MSSQL auditing.
- Select the SQL Server (or SQL Database), and then click Auditing.
- Click the Enable Azure SQL Auditing toggle button to turn on Azure SQL Auditing.
- Select the Storage checkbox to set the audit log destination to a storage account, and then select your existing storage account from the Storage Details.
- Click Save.
Configure Azure Cloud Shell¶
- Click the Cloud shell icon in the top menu bar, and then select PowerShell.
- Click Show advanced settings.
- In the Cloud Shell region, enter your region.
- In the Storage account, select Use existing.
- In the File share, select Create new, and then enter a name.
- Click Create storage.
- The Cloud PowerShell window will appear. You can now run your commands in PowerShell.
- If you have an Azure SQL Database, run:
- If you have an Azure Synapse Database, run:
Verify Audit Configuration and Get Storage URL¶
-
Go to the storage account configured for MSSQL auditing and click Containers.
Note
Make sure that your MSSQL Server name directory is visible inside your audit log container. It may take a few minutes to appear.
-
Navigate into your audit log container (e.g.,
sqldbauditlogs). You should see a directory with your MSSQL server name (e.g.,my-sql-server). -
Go to Properties, and copy the container URL (e.g.,
https://sqlaudit.blob.core.windows.net/sqldbauditlogs). -
Your Audit storage URL will be:
${CONTAINER_URL}/${MSSQL_SERVER_NAME}For example:
https://sqlaudit.blob.core.windows.net/sqldbauditlogs/my-sql-serverDo not use only the container URL
The storage URL must include the SQL Server name directory, otherwise the connector will not find audit logs and will show:
auditLogsCount: 0
SQL Server On-Premises Setup¶
Perform the following steps to enable auditing locally.
Supported Version
The MSSQL connector currently supports SQL Server 2019 for on-premises deployments. Refer to the supported matrix for the latest supported versions.
Step 1: Docker Compose
Create a docker-compose.yml file with the following configuration:
Step 2: Create Audit Logs Directory
Create the audit logs directory on the host and set appropriate permissions:
Step 3: Start SQL Server Container
Start the SQL Server container using Docker Compose:
| Bash | |
|---|---|
Step 4: Configure Server Audit
Connect to SQL Server using a database management tool (such as DBeaver) and run the following SQL queries to create and enable the server audit:
Step 5: Verify Server Audit Configuration
Verify that the server audit is configured and enabled:
| SQL | |
|---|---|
Query audit logs to verify they are being written:
| SQL | |
|---|---|
To check recent audit events:
| SQL | |
|---|---|
Step 6: Create Database Audit Specification
To capture table-level operations, create a database audit specification for your target database:
Note
This audits all operations on all objects in the customer_schema schema. If you want to audit specific tables only, you can modify the specification accordingly.
Step 7: Verify Database Audit Specification
Verify that the database audit specification is enabled:
| SQL | |
|---|---|
Step 8: Test Audit Logging
Perform test operations to verify audit logging is working:
Query audit logs filtered for your table:
Check recent audit events:
| SQL | |
|---|---|
Step 9: Configure Service User Permissions
The service user (e.g., privacera_connector) requires specific permissions to query audit logs and configuration.
Grant Server-Level Permissions¶
The sys.fn_get_audit_file() function requires VIEW SERVER STATE permission:
| SQL | |
|---|---|
For querying audit configuration:
| SQL | |
|---|---|
Grant Database Permissions¶
For read-only audit access:
| SQL | |
|---|---|
For full database operations (if connector manages resources):
| SQL | |
|---|---|
File System Permissions¶
Important
The SQL Server service account must have read/write access to the audit output path directory (e.g., /var/opt/mssql/audit/). Ensure the service account has appropriate file system permissions to access the audit log files.
Setup¶
Warning
- Ensure that SQL Server audit is properly configured and writing logs to the specified Azure Blob Storage location.
- The Storage URL must be accessible by the JDBC user credentials configured in the connector.
- Replace the example values with your actual values.
-
SSH to the instance where Privacera Manager is installed.
-
Run the following command to open the
.ymlfile to be edited.If you have multiple connectors, then replace
instance1with the appropriate connector instance name.Bash -
Update or add the following properties:
-
Once the properties are configured, run the following commands to update your Privacera Manager platform instance:
Step 1 - Setup which generates the helm charts. This step usually takes few minutes.
Step 2 - Apply the Privacera Manager helm charts. Step 3 - (Optional) Post-installation step which generates Plugin tar ball, updates Route 53 DNS and so on. This step is not required if you are updating only connector properties.
-
In PrivaceraCloud portal, navigate to Settings → Applications.
-
On the Connected Applications screen, select MSSQL.
-
Click the pen icon or the Account Name to modify the settings.
-
On the Edit Application screen, go to Access Management.
-
Under the BASIC tab, enable Enable access audits using the toggle button.
-
Enter a value in the Audits storage URL field. Example:
https://sqlaudit.blob.core.windows.net/sqldbauditlogs/my-sql-server -
Under the ADVANCED tab, enter the following value:
- Users to exclude when fetching access audits:
admin_user,service_account@domain.com
- Users to exclude when fetching access audits:
-
Add the following custom properties to control audit loading and synchronization behavior under Add New Custom Properties:
-
Click SAVE to apply the changes.
- Prev topic: Advanced Configuration