New-AzSqlDatabase

Creates a database or an elastic database.

Syntax

New-AzSqlDatabase
   -DatabaseName <String>
   [-CollationName <String>]
   [-CatalogCollation <String>]
   [-MaxSizeBytes <Int64>]
   [-Edition <String>]
   [-RequestedServiceObjectiveName <String>]
   [-ElasticPoolName <String>]
   [-ReadScale <DatabaseReadScale>]
   [-Tags <Hashtable>]
   [-SampleName <String>]
   [-ZoneRedundant]
   [-AsJob]
   [-Force]
   [-LicenseType <String>]
   [-AutoPauseDelayInMinutes <Int32>]
   [-MinimumCapacity <Double>]
   [-HighAvailabilityReplicaCount <Int32>]
   [-BackupStorageRedundancy <String>]
   [-SecondaryType <String>]
   [-MaintenanceConfigurationId <String>]
   [-EnableLedger]
   [-PreferredEnclaveType <String>]
   [-AssignIdentity]
   [-EncryptionProtector <String>]
   [-UserAssignedIdentityId <String[]>]
   [-KeyList <String[]>]
   [-FederatedClientId <Guid>]
   [-EncryptionProtectorAutoRotation]
   [-UseFreeLimit]
   [-FreeLimitExhaustionBehavior <String>]
   [-ServerName] <String>
   [-ResourceGroupName] <String>
   [-DefaultProfile <IAzureContextContainer>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
New-AzSqlDatabase
   -DatabaseName <String>
   [-CollationName <String>]
   [-CatalogCollation <String>]
   [-MaxSizeBytes <Int64>]
   -Edition <String>
   [-ReadScale <DatabaseReadScale>]
   [-Tags <Hashtable>]
   [-SampleName <String>]
   [-ZoneRedundant]
   [-AsJob]
   [-Force]
   -VCore <Int32>
   -ComputeGeneration <String>
   [-LicenseType <String>]
   [-ComputeModel <String>]
   [-AutoPauseDelayInMinutes <Int32>]
   [-MinimumCapacity <Double>]
   [-HighAvailabilityReplicaCount <Int32>]
   [-BackupStorageRedundancy <String>]
   [-SecondaryType <String>]
   [-MaintenanceConfigurationId <String>]
   [-EnableLedger]
   [-PreferredEnclaveType <String>]
   [-AssignIdentity]
   [-EncryptionProtector <String>]
   [-UserAssignedIdentityId <String[]>]
   [-KeyList <String[]>]
   [-FederatedClientId <Guid>]
   [-EncryptionProtectorAutoRotation]
   [-UseFreeLimit]
   [-FreeLimitExhaustionBehavior <String>]
   [-ServerName] <String>
   [-ResourceGroupName] <String>
   [-DefaultProfile <IAzureContextContainer>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]

Description

The New-AzSqlDatabase cmdlet creates an Azure SQL database. You can also create an elastic database by setting the ElasticPoolName parameter to an existing elastic pool.

Examples

Example 1: Create a database on a specified server

New-AzSqlDatabase -ResourceGroupName "ResourceGroup01" -ServerName "Server01" -DatabaseName "Database01"

ResourceGroupName             : ResourceGroup01
ServerName                    : Server01
DatabaseName                  : Database01
Location                      : Central US
DatabaseId                    : a1e6bd1a-735a-4d48-8b98-afead5ef1218
Edition                       : Standard
CollationName                 : SQL_Latin1_General_CP1_CI_AS
CatalogCollation              :
MaxSizeBytes                  : 268435456000
Status                        : Online
CreationDate                  : 7/3/2015 7:33:37 AM
CurrentServiceObjectiveId     : f1173c43-91bd-4aaa-973c-54e79e15235b
CurrentServiceObjectiveName   : S0
RequestedServiceObjectiveId   : f1173c43-91bd-4aaa-973c-54e79e15235b
RequestedServiceObjectiveName :
ElasticPoolName               :
EarliestRestoreDate           :
LicenseType                   :
Tags                          :
EnableLedger                  : False

This command creates a database named Database01 on server Server01.

Example 2: Create an elastic database on a specified server

New-AzSqlDatabase -ResourceGroupName "ResourceGroup01" -ServerName "Server01" -DatabaseName "Database02" -ElasticPoolName "ElasticPool01"

ResourceGroupName             : ResourceGroup01
ServerName                    : Server01
DatabaseName                  : Database02
Location                      : Central US
DatabaseId                    : 7bd9d561-42a7-484e-bf05-62ddef8015ab
Edition                       : Standard
CollationName                 : SQL_Latin1_General_CP1_CI_AS
CatalogCollation              :
MaxSizeBytes                  : 268435456000
Status                        : Online
CreationDate                  : 8/26/2015 10:04:29 PM
CurrentServiceObjectiveId     : d1737d22-a8ea-4de7-9bd0-33395d2a7419
CurrentServiceObjectiveName   : ElasticPool
RequestedServiceObjectiveId   : d1737d22-a8ea-4de7-9bd0-33395d2a7419
RequestedServiceObjectiveName :
ElasticPoolName               : ElasticPool01
EarliestRestoreDate           :
LicenseType                   :
Tags                          :
EnableLedger                  : False

This command creates a database named Database02 in the elastic pool named ElasticPool01 on server Server01.

Example 3: Create an Vcore database on a specified server

New-AzSqlDatabase -ResourceGroupName "ResourceGroup01" -ServerName "Server01" -DatabaseName "Database03" -Edition "GeneralPurpose" -Vcore 2 -ComputeGeneration "Gen4"

ResourceGroupName             : ResourceGroup01
ServerName                    : Server01
DatabaseName                  : Database03
Location                      : Central US
DatabaseId                    : 34d9d561-42a7-484e-bf05-62ddef8000ab
Edition                       : GeneralPurpose
CollationName                 : SQL_Latin1_General_CP1_CI_AS
CatalogCollation              :
MaxSizeBytes                  : 268435456000
Status                        : Online
CreationDate                  : 8/26/2015 10:04:29 PM
CurrentServiceObjectiveName   : GP_Gen4_2
RequestedServiceObjectiveName :
ElasticPoolName               :
EarliestRestoreDate           :
LicenseType                   : LicenseIncluded
Tags                          :
EnableLedger                  : False

This command creates a Vcore database named Database03 on server Server01.

Example 4: Create an Serverless database on the specified server

New-AzSqlDatabase -ResourceGroupName "ResourceGroup01" -ServerName "Server01" -DatabaseName "Database04" -Edition "GeneralPurpose" -Vcore 2 -ComputeGeneration "Gen5" -ComputeModel Serverless

ResourceGroupName             : ResourceGroup01
ServerName                    : Server01
DatabaseName                  : Database04
Location                      : Central US
DatabaseId                    : ef5a9698-012c-4def-8d94-7f6bfb7b4f04
Edition                       : GeneralPurpose
CollationName                 : SQL_Latin1_General_CP1_CI_AS
CatalogCollation              :
MaxSizeBytes                  : 34359738368
Status                        : Online
CreationDate                  : 4/12/2019 11:20:29 PM
CurrentServiceObjectiveName   : GP_S_Gen5_2
RequestedServiceObjectiveName : GP_S_Gen5_2
ElasticPoolName               :
EarliestRestoreDate           : 4/12/2019 11:50:29 PM
Tags                          :
CreateMode                    :
ReadScale                     : Disabled
ZoneRedundant                 : False
Capacity                      : 2
Family                        : Gen5
SkuName                       : GP_S_Gen5
LicenseType                   : LicenseIncluded
AutoPauseDelayInMinutes       : 360
EnableLedger                  : False
MinimumCapacity          : 0.5

This command creates a Serverless database named Database04 on server Server01.

Example 5: Create a database configured with preferred enclave type as VBS

New-AzSqlDatabase -ResourceGroupName "ResourceGroup01" -DatabaseName "Database01" -ServerName "Server01" -Edition "GeneralPurpose" -Vcore 2 -ComputeGeneration "Gen5" -PreferredEnclaveType "VBS"

ResourceGroupName             : ResourceGroup01
ServerName                    : Server01
DatabaseName                  : Database01
Location                      : Central US
DatabaseId                    : 34d9d561-42a7-484e-bf05-62ddef8000ab
Edition                       : GeneralPurpose
CollationName                 : SQL_Latin1_General_CP1_CI_AS
CatalogCollation              :
MaxSizeBytes                  : 268435456000
Status                        : Online
CreationDate                  : 8/26/2015 10:04:29 PM
CurrentServiceObjectiveName   : GP_Gen5_2
RequestedServiceObjectiveName :
ElasticPoolName               :
EarliestRestoreDate           :
LicenseType                   : LicenseIncluded
Tags                          :
EnableLedger                  : False
PreferredEnclaveType          : VBS

This command creates a database configured with VBS enclave

Parameters

-AsJob

Run cmdlet in the background

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-AssignIdentity

Generate and assign a Microsoft Entra identity for this database for use with key management services like Azure KeyVault.

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-AutoPauseDelayInMinutes

The auto pause delay in minutes for database(serverless only), -1 to opt out

Type:Int32
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-BackupStorageRedundancy

The Backup storage redundancy used to store backups for the SQL Database. Options are: Local, Zone and Geo.

Type:String
Accepted values:Local, Zone, Geo, GeoZone
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-CatalogCollation

Specifies the name of the SQL database catalog collation.

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-CollationName

Specifies the name of the SQL database collation.

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-ComputeGeneration

The compute generation to assign.

Type:String
Aliases:Family
Position:Named
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-ComputeModel

The compute model for Azure Sql database. Serverless or Provisioned

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Confirm

Prompts you for confirmation before running the cmdlet.

Type:SwitchParameter
Aliases:cf
Position:Named
Default value:False
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-DatabaseName

Specifies the name of the database.

Type:String
Aliases:Name
Position:Named
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-DefaultProfile

The credentials, account, tenant, and subscription used for communication with azure

Type:IAzureContextContainer
Aliases:AzContext, AzureRmContext, AzureCredential
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Edition

Specifies the edition to assign to the database. The acceptable values for this parameter are:

  • None
  • Basic
  • Standard
  • Premium
  • DataWarehouse
  • Free
  • Stretch
  • GeneralPurpose
  • BusinessCritical
Type:String
Position:Named
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-ElasticPoolName

Specifies the name of the elastic pool in which to put the database.

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-EnableLedger

Creates a ledger database, in which the integrity of all data is protected by the ledger feature. All tables in the ledger database must be ledger tables. Note: the value of this property cannot be changed after the database has been created.

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-EncryptionProtector

The encryption protector key for SQL Database.

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-EncryptionProtectorAutoRotation

The AKV Key Auto Rotation status

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False

-FederatedClientId

The federated client id for the SQL Database. It is used for cross tenant CMK scenario.

Type:Nullable<T>[Guid]
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Force

Skip confirmation message for performing the action

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-FreeLimitExhaustionBehavior

Exhaustion behavior of free limit database.

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-HighAvailabilityReplicaCount

The number of readonly secondary replicas associated with the database to which readonly application intent connections may be routed. This property is only settable for Hyperscale edition databases.

Type:Int32
Aliases:ReadReplicaCount
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-KeyList

The list of AKV keys for the SQL Database.

Type:String[]
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-LicenseType

The license type for the Azure Sql database. Possible values are:

  • BasePrice - Azure Hybrid Benefit (AHB) discounted pricing for existing SQL Server license owners is applied. Database price will be discounted for existing SQL Server license owners.
  • LicenseIncluded - Azure Hybrid Benefit (AHB) discount pricing for existing SQL Server license owners is not applied. Database price will include a new SQL Server license costs.
Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-MaintenanceConfigurationId

The Maintenance configuration id for the SQL Database.

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-MaxSizeBytes

Specifies the maximum size of the database in bytes.

Type:Int64
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-MinimumCapacity

The Minimal capacity that database will always have allocated, if not paused. For serverless Azure Sql databases only.

Type:Double
Aliases:MinVCore, MinCapacity
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-PreferredEnclaveType

The preferred enclave type for the Azure Sql database. Possible values are Default and VBS.

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-ReadScale

If enabled, connections that have application intent set to readonly in their connection string may be routed to a readonly secondary replica. This property is only settable for Premium and Business Critical databases.

Type:DatabaseReadScale
Accepted values:Disabled, Enabled
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-RequestedServiceObjectiveName

Specifies the name of the service objective to assign to the database.

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-ResourceGroupName

Specifies the name of the resource group to which the server is assigned.

Type:String
Position:0
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-SampleName

The name of the sample schema to apply when creating this database.

Type:String
Accepted values:AdventureWorksLT
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-SecondaryType

The secondary type of the database if it is a secondary. Valid values are Geo and Named.

Type:String
Accepted values:Named, Geo
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-ServerName

Specifies the name of the server that hosts the database.

Type:String
Position:1
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-Tags

Specifies a dictionary of Key-value pairs in the form of a hash table that this cmdlet associates with the new database. For example: @{key0="value0";key1=$null;key2="value2"}

Type:Hashtable
Aliases:Tag
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-UseFreeLimit

Use free limit on this database.

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-UserAssignedIdentityId

The list of user assigned identity for the SQL Database.

Type:String[]
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-VCore

The Vcore number for the Azure Sql database

Type:Int32
Aliases:Capacity, MaxVCore, MaxCapacity
Position:Named
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.

Type:SwitchParameter
Aliases:wi
Position:Named
Default value:False
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-ZoneRedundant

The zone redundancy to associate with the Azure Sql Database

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

Inputs

String

Outputs

AzureSqlDatabaseModel