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!

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 15+ years of experience building enterprise systems both in the cloud and on-premises. He is also a Microsoft Certified (MCSD) Azure Solutions Architect. 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) […]

    Like

    Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s