The Azure SQL Database service allows you to set an Admin login and password when you provision a database server in the service. However, if you happen to forget the password for the Azure SQL Database server, it can be problematic. There is an option in the UI of the Azure Portal to reset this admin password. However, there may be times when you want to update the password from the command-line or in an automated fashion. Perhaps, you may want to automate the updating of the admin password for your Azure SQL Database servers periodically. Thankfully, there is a command in the Azure CLI 2.0 that does support updating or changing the password.

Here’s the command to use for updating / changing the password for an Azure SQL Database Server:

# command format
az sql server update -n {database server name}
-g {resource group name}
-p {password}

# usage example
az sql server update -n StarshipDBServer
-g StarshipGroup
-p CaptPic@rdR0cks!
Azure CLI: Reset Azure SQL Database Password 1

Here’s a description of the parameters to pass into the “az sql server update” command:

-n / –name
The name of the Azure SQL Database Server.

-g / –resource-group
The name of the Azure Resource Group that contains there SQL Database server

-p / –admin-password
The new password that you want to set for the Administrator Login of the Azure SQL Database Server.

This is a simple command, but can be very useful. Especially in time when you may have forgotten the password, or if you just want to automate the changing of the password in a large automation process.

Microsoft MVP

Chris Pietschmann is a Microsoft MVP, HashiCorp Ambassador, and Microsoft Certified Trainer (MCT) with 20+ years of experience designing and building Cloud & Enterprise systems. He has worked with companies of all sizes from startups to large enterprises. He has a passion for technology and sharing what he learns with others to help enable them to learn faster and be more productive.
HashiCorp Ambassador Microsoft Certified Trainer (MCT) Microsoft Certified: Azure Solutions Architect