New-Database
Azure: Creates a new Azure SQL database
param(
[Parameter(Mandatory = $true)]
[string]$ResourceGroupName,
[Parameter(Mandatory = $true)]
[string]$ServerName,
[Parameter(Mandatory = $true)]
[string]$DatabaseName,
[Parameter(Mandatory = $false)]
[string]$Edition,
[Parameter(Mandatory = $false)]
[string]$ComputeModel,
[Parameter(Mandatory = $false)]
[string]$ServiceObjectiveName
)
try {
Import-Module Az.Sql -ErrorAction Stop
[hashtable]$cmdArgs = @{
'ResourceGroupName' = $ResourceGroupName;
'ServerName' = $ServerName;
'DatabaseName' = $DatabaseName;
'ErrorAction' = 'Stop'
}
if ($Edition) { $cmdArgs.Add('Edition', $Edition) }
if ($ComputeModel) { $cmdArgs.Add('ComputeModel', $ComputeModel) }
if ($ServiceObjectiveName) { $cmdArgs.Add('ServiceObjectiveName', $ServiceObjectiveName) }
$db = New-AzSqlDatabase @cmdArgs
Write-Output $db
} catch {
Write-Error $_
exit 1
}The name of the resource group.
The name of the Azure SQL Server.
The name for the new database.
The edition of the database (e.g. Basic, Standard, Premium, GeneralPurpose).
The compute model (e.g. Serverless, Provisioned).
The service level objective (e.g. S0, S1, GP_S_Gen5_1).