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 2.0: Reset Azure SQL Database Password 2

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.

Posted by Chris Pietschmann

Chris is a Microsoft MVP and has nearly 20 years of experience building enterprise systems both in the cloud and on-premises. He is also a Microsoft Certified Azure Solutions Architect and developer, a Microsoft Certified Trainer (MCT), and Cloud Advocate. He has a passion for technology and sharing what he learns with others to help enable them to learn faster and be more productive.

One Comment

  1. […] Azure CLI 2.0: Reset Azure SQL Database Password (Chris Pietschmann) […]


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.