Manage Azure SQL Database Auditing using APIs
Applies to: Azure SQL Database Azure Synapse Analytics
This article provides an overview of the different APIs used for managing Auditing for Azure SQL Database and Azure Synapse Analytics.
Use Azure PowerShell
PowerShell cmdlets (including WHERE clause support for additional filtering):
- Create or Update Database Auditing Policy (Set-AzSqlDatabaseAudit)
- Create or Update Server Auditing Policy (Set-AzSqlServerAudit)
- Get Database Auditing Policy (Get-AzSqlDatabaseAudit)
- Get Server Auditing Policy (Get-AzSqlServerAudit)
- Remove Database Auditing Policy (Remove-AzSqlDatabaseAudit)
- Remove Server Auditing Policy (Remove-AzSqlServerAudit)
- Create or Update auditing for Microsoft support operations (Set-AzSqlServerMSSupportAudit)
For a script example, see Configure auditing and threat detection using PowerShell.
Use REST API
REST API:
- Create or Update Database Auditing Policy
- Create or Update Server Auditing Policy
- Create or Update Microsoft support operations audit policy
- Get Database Auditing Policy
- Get Server Auditing Policy
Extended policy with WHERE clause support for additional filtering:
- Create or Update Database Extended Auditing Policy
- Create or Update Server Extended Auditing Policy
- Get Database Extended Auditing Policy
- Get Server Extended Auditing Policy
Use Azure CLI
- Manage a server's auditing policy
- Manage a database's auditing policy
- Manage Microsoft support operations audit policy
Use Azure Resource Manager templates
You can manage Azure SQL Database auditing using Azure Resource Manager templates, as shown in these examples:
- Deploy an Azure SQL Database with Auditing enabled to write audit logs to Azure Blob storage account
- Deploy an Azure SQL Database with Auditing enabled to write audit logs to Log Analytics
- Deploy an Azure SQL Database with Auditing enabled to write audit logs to Event Hubs
Note
The linked samples are on an external public repository and are provided 'as is', without warranty, and are not supported under any Microsoft support program/service.