az.sqlserver Module Reference

This document provides a comprehensive reference for the az.sqlserver PowerShell module, which allows you to manage Azure SQL Servers and their associated resources.

Overview of az.sqlserver

The az.sqlserver module enables you to perform various administrative tasks on Azure SQL Servers using PowerShell. You can create, configure, and manage SQL Servers, including their security settings like firewall rules, auditing, and DNS configurations.

Get-AzSqlServer

Retrieves information about Azure SQL Servers.

Syntax

Get-AzSqlServer [-ResourceGroupName <String>] [-ServerName <String>] [-DefaultProfile <IAzureContextContainer>] [<CommonParameters>]

Parameters

Name Type Description Required
-ResourceGroupName String The name of the resource group that contains the SQL Server. No
-ServerName String The name of the Azure SQL Server. No
-DefaultProfile IAzureContextContainer Azure context for the command. No

Example

# Get all SQL Servers in a resource group
Get-AzSqlServer -ResourceGroupName "MyResourceGroup"

# Get a specific SQL Server
Get-AzSqlServer -ResourceGroupName "MyResourceGroup" -ServerName "my-sql-server-001"

New-AzSqlServer

Creates a new Azure SQL Server.

Syntax

New-AzSqlServer -ResourceGroupName <String> -ServerName <String> -Location <String> [-AdministratorLogin <String>] [-AdministratorLoginPassword <SecureString>] [-Tags <Hashtable>] [-Version <String>] [-SslEnforcement <String>] [-MinimumTlsVersion <String>] [-DefaultProfile <IAzureContextContainer>] [<CommonParameters>]

Parameters

Name Type Description Required
-ResourceGroupName String The name of the resource group for the new SQL Server. Yes
-ServerName String The name for the new Azure SQL Server. Must be globally unique. Yes
-Location String The Azure region where the SQL Server will be created. Yes
-AdministratorLogin String The administrator login name for the SQL Server. No
-AdministratorLoginPassword SecureString The password for the administrator login. No
-Tags Hashtable A hash table of tags to assign to the SQL Server. No

Example

# Create a new SQL Server with admin credentials
$password = ConvertTo-SecureString "P@ssw0rd123!" -AsPlainText -Force
New-AzSqlServer -ResourceGroupName "MyResourceGroup" -ServerName "my-new-sql-server" -Location "East US" -AdministratorLogin "sqladmin" -AdministratorLoginPassword $password

Set-AzSqlServer

Updates an existing Azure SQL Server.

(Details and syntax similar to Get-AzSqlServer and New-AzSqlServer, omitted for brevity)

Remove-AzSqlServer

Deletes an Azure SQL Server.

(Details and syntax similar to Get-AzSqlServer, omitted for brevity)

Get-AzSqlServerFirewallRule

Retrieves information about Azure SQL Server firewall rules.

(Details and syntax omitted for brevity)

New-AzSqlServerFirewallRule

Creates a new Azure SQL Server firewall rule.

(Details and syntax omitted for brevity)

Remove-AzSqlServerFirewallRule

Deletes an Azure SQL Server firewall rule.

(Details and syntax omitted for brevity)