I'm trying to enable Azure SQL auditing to a Log Analytics workspace as per the screen shot here using the Python SDK, but try as I might, I can't find the right combination of commands (nor can I see any hints in the official documentation) to make this stick programmatically.
I've tried both sql_client.extended_server_blob_auditing_policies and sql_client.server_blob_auditing_policies methods and neither show me information on the Log Analytics workspace when I enable this via the GUI.
Anyone been able to do this? Using azure-mgmt-sql 3.0.1.
To Enable Azure SQL server auditing by using python SDK azure-mgmt-sql 3.0.1 you can follow below procedure: To authenticate with azure you can use service principal authentication using below code:
Connect azure sql server using below code:
Enable auditing to a Log Analytics workspace using the
create_or_updatemethod of theServerAuditPolicyclass:code:
Complete code:
Auditing will enable on sql server level