New‑AzSqlServer (Az.SqlServer)

Synopsis

Creates a new Azure SQL Server instance.

Description

The New‑AzSqlServer cmdlet creates a logical server for Azure SQL Database. The server provides a namespace for databases and can be associated with a firewall configuration, administrator credentials, and Azure AD identities.

Use this cmdlet to provision a server before creating databases or configuring firewall rules.

Syntax

New‑AzSqlServer
    -ResourceGroupName <String>
    -ServerName <String>
    -Location <String>
    -AdministratorLogin <String>
    -AdministratorLoginPassword <SecureString>
    [-Version {12.0 | 12.1}]
    [-AssignIdentity]
    [-IdentityType <String>]
    [-Tag <Hashtable>]
    [-WhatIf] [-Confirm] []

Parameters

NameTypeRequiredDescription
-ResourceGroupName String Yes Name of the resource group that will contain the server.
-ServerName String Yes Unique name for the logical server.
-Location String Yes Azure region where the server will be created (e.g., eastus).
-AdministratorLogin String Yes Administrator user name for the server.
-AdministratorLoginPassword SecureString Yes Secure password for the administrator account.
-Version String No SQL server version. Default is 12.0.
-AssignIdentity SwitchParameter No Assign a system‑assigned managed identity to the server.
-IdentityType String No Specify UserAssigned to attach a user‑assigned identity.
-Tag Hashtable No Key/value pairs for resource tagging.
-WhatIf SwitchParameter No Shows what would happen if the cmdlet runs.
-Confirm SwitchParameter No Prompts for confirmation before executing.

Examples

Example 1: Create a new SQL server with a password

# Securely store the password
$pwd = ConvertTo-SecureString "P@ssw0rd!" -AsPlainText -Force

New‑AzSqlServer `
    -ResourceGroupName "MyResourceGroup" `
    -ServerName "mynewsqlserver" `
    -Location "westus2" `
    -AdministratorLogin "sqladmin" `
    -AdministratorLoginPassword $pwd

Example 2: Create a server with a managed identity and tags

$pwd = ConvertTo-SecureString "StrongP@ss123" -AsPlainText -Force

New‑AzSqlServer `
    -ResourceGroupName "ProdRG" `
    -ServerName "prodsqlsrv" `
    -Location "eastus" `
    -AdministratorLogin "adminUser" `
    -AdministratorLoginPassword $pwd `
    -AssignIdentity `
    -Tag @{ Environment="Production"; Department="Finance" }

Example 3: Simulate creation with -WhatIf

New‑AzSqlServer -ResourceGroupName "TestRG" -ServerName "testsql01" `
    -Location "centralus" -AdministratorLogin "testadmin" `
    -AdministratorLoginPassword (Read-Host -AsSecureString) -WhatIf

Remarks

  • The -ServerName must be globally unique across Azure.
  • Passwords must meet Azure SQL password complexity requirements.
  • When -AssignIdentity is used, a system‑assigned managed identity is created automatically.
  • Use New‑AzSqlServer in combination with New‑AzSqlFirewallRule to allow client IP addresses.