How to reset the sql admin password on Azure SQL Managed Instance if there is only one user/admin and the admin password is lost/forgotten?
Could it be done via portal or using some script?
The easiest way to reset the password is to go to the Azure portal, open the instance details blade and press Reset password button:
As an alternative, you can use AzureRm.Sql PowerShell library and Set-AzureRmSqlManagedInstance command:
$InstancePassword = "Newpassword1234"
$SecureString = ConvertTo-SecureString $InstancePassword -AsPlainText -Force
Set-AzureRmSqlInstance -Name "managedinstance1" -ResourceGroupName "ResourceGroup01" -AdministratorPassword $SecureString
You can also use Azure CLI with az sql mi update command:
az sql mi update -g mygroup -n myinstance -i -p mypassword