title | description | services | ms.service | ms.subservice | ms.custom | ms.devlang | ms.topic | author | ms.author | ms.reviewer | ms.date |
---|---|---|---|---|---|---|---|---|---|---|---|
PowerShell example of auditing and Advanced Threat Protection - Azure SQL Database |
Azure PowerShell example script to configure auditing and Advanced Threat Protection in an Azure SQL Database |
sql-database |
sql-database |
security |
security, sqldbrb=1 |
PowerShell |
sample |
DavidTrigano |
datrigan |
sstein, vanto |
04/28/2020 |
[!INCLUDEappliesto-sqldb]
This PowerShell script example configures Azure SQL Database auditing and Advanced Threat Protection.
[!INCLUDE quickstarts-free-trial-note] [!INCLUDE updated-for-az] [!INCLUDE cloud-shell-try-it.md]
If you choose to install and use PowerShell locally, this tutorial requires Az PowerShell 1.4.0 or later. If you need to upgrade, see Install Azure PowerShell module. If you are running PowerShell locally, you also need to run Connect-AzAccount
to create a connection with Azure.
[!code-powershell-interactivemain]
Use the following command to remove the resource group and all resources associated with it.
Remove-AzResourceGroup -ResourceGroupName $resourcegroupname
This script uses the following commands. Each command in the table links to command-specific documentation.
Command | Notes |
---|---|
New-AzResourceGroup | Creates a resource group in which all resources are stored. |
New-AzSqlServer | Creates a server. |
New-AzSqlDatabase | Creates a database or elastic pool. |
New-AzStorageAccount | Creates a storage account. |
Set-AzSqlDatabaseAuditing | Sets the auditing policy for a database. |
Set-AzSqlDatabaseThreatDetectionPolicy | Sets an Advanced Threat Protection policy on a database. |
Remove-AzResourceGroup | Deletes a resource group including all nested resources. |
For more information on Azure PowerShell, see Azure PowerShell documentation.
Additional SQL Database PowerShell script samples can be found in the Azure SQL Database PowerShell scripts.