how to write sql server audit log to azure storage account

k shaz 36 Reputation points
2023-05-23T20:17:49.6933333+00:00

i have azure sql , and i need to use bellow script to enable audit for selected objects, but i am not able to write the logs to azure storage account, i am getting below error

Msg 40517, Level 15, State 5, Line 7

Keyword or statement option 'FILE' is not supported in this version of SQL Server.

-- Use the master database for creating the audit
USE master;
GO

-- Create a Server Audit object
CREATE SERVER AUDIT DataAudit
--- TO azure storage account
WITH (ON_FAILURE = CONTINUE);
GO

-- Enable the Server Audit
ALTER SERVER AUDIT DataAudit
WITH (STATE = ON);
GO

Azure SQL Database
Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
7,129 questions
Azure Storage Accounts
Azure Storage Accounts
Globally unique resources that provide access to data management services and serve as the parent namespace for the services.
2,687 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Tamarick Hill 11 Reputation points Microsoft Employee
    2023-05-24T13:35:45.7866667+00:00

    As stated above, this is a built in feature to the Azure SQL Service. Assuming you are using Azure SQL Database, go into the logical server settings within the Azure Portal. Then under the Security section, you should see an option for 'Auditing'. Once you click that Auditing tab, you can enable auditing for the server and send your logs to a storage account.

    0 comments No comments

  2. Oury Ba-MSFT 16,156 Reputation points Microsoft Employee
    2023-05-24T18:32:20.8866667+00:00

    k shaz Thank you for reaching out.

    My understanding is that you are trying to set up auditing for your Azure SQL database.

    In addition to @Tamarick Hill 's answer.

    For Azure SQL, the portal experience is the best way to do it, we don't have t-SQL support yet. Please check the doc below for step-by-step instructions.

    Set up Auditing for Azure SQL Database and Azure Synapse Analytics

    Regards,

    Oury