Skip to content

Set-Database

Azure: Updates an 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]$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 ($ServiceObjectiveName) { $cmdArgs.Add('ServiceObjectiveName', $ServiceObjectiveName) }

	$db = Set-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 of the database to update.

The edition of the database (e.g. Standard, Premium).

The service level objective (e.g. S1, S2).

An interactive directory of PowerShell scripts.