az sql db audit-policy

Manage a database's auditing policy.

Commands

az sql db audit-policy show Gets a database's blob auditing policy.
az sql db audit-policy update Updates a database's auditing policy.

az sql db audit-policy show

Gets a database's blob auditing policy.

az sql db audit-policy show --name
--resource-group
--server

Required Parameters

--name -n

Name of the Azure SQL Database.

--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=.

--server -s

Name of the Azure SQL server.

az sql db audit-policy update

If the policy is being enabled, storage_account or both storage_endpoint and storage_account_access_key must be specified.

az sql db audit-policy update --name
--resource-group
--server
[--actions]
[--add]
[--remove]
[--retention-days]
[--set]
[--state {Disabled, Enabled}]
[--storage-account]
[--storage-endpoint]
[--storage-key]

Examples

Enable by specifying storage account name

az sql db audit-policy update -g mygroup -s myserver -n mydb --state Enabled --storage-account mystorage

Enable by specifying storage endpoint and key

az sql db audit-policy update -g mygroup -s myserver -n mydb --state Enabled --storage-endpoint https://mystorage.blob.core.windows.net --storage-key MYKEY==

Set the list of audit actions

az sql db audit-policy update -g mygroup -s myserver -n mydb --actions FAILED_DATABASE_AUTHENTICATION_GROUP 'UPDATE on database::mydb by public'

Add an audit action

az sql db audit-policy update -g mygroup -s myserver -n mydb --add auditActionsAndGroups FAILED_DATABASE_AUTHENTICATION_GROUP

Remove an audit action by list index

az sql db audit-policy update -g mygroup -s myserver -n mydb --remove auditActionsAndGroups 0

Disable an auditing policy

az sql db audit-policy update -g mygroup -s myserver -n mydb --state Disabled

Required Parameters

--name -n

Name of the Azure SQL Database.

--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=.

--server -s

Name of the Azure SQL server.

Optional Parameters

--actions

List of actions and action groups to audit.

--add

Add an object to a list of objects by specifying a path and key value pairs. Example: --add property.listProperty .

--remove

Remove a property or an element from a list. Example: --remove property.list OR --remove propertyToRemove.

--retention-days

The number of days to retain audit logs.

--set

Update an object by specifying a property path and value to set. Example: --set property1.property2=.

--state

Auditing policy state.

accepted values: Disabled, Enabled
--storage-account

Name of the storage account.

--storage-endpoint

The storage account endpoint.

--storage-key

Access key for the storage account.