Rename-Database
Azure: Renames an Azure SQL database
param(
[Parameter(Mandatory = $true)]
[string]$ResourceGroupName,
[Parameter(Mandatory = $true)]
[string]$ServerName,
[Parameter(Mandatory = $true)]
[string]$DatabaseName,
[Parameter(Mandatory = $true)]
[string]$NewName
)
try {
Import-Module Az.Sql -ErrorAction Stop
Set-AzSqlDatabase -ResourceGroupName $ResourceGroupName -ServerName $ServerName -DatabaseName $DatabaseName -NewName $NewName -ErrorAction Stop | Out-Null
Write-Output "Successfully renamed database from '$DatabaseName' to '$NewName'."
} catch {
Write-Error $_
exit 1
}The name of the resource group.
The name of the Azure SQL Server.
The current name of the database.
The new name for the database.