Follow dba-ninja.com

Subscribe to RSS feed  Follow @jackvamvas - Twitter

*Use the Comments section for questions

dba-ninja.com Links

Dba_db2_button

Sqlserver_dba_button

Azure CLI commands cheatsheet

02 May,2025 by Rambler

Azure CLI commands I use regularly for managing SQL Server & dependant resources in Azure 

 

Account

--List regions supported in subscription

az account list-locations --output table

Resources 

--List Resource Groups in a Subscription 

az group list 

az group list --query "[].id"

SQL Servers

--List available SQL Servers

az sql server list --output table

Managed Instances

--List managed instances -- all details 

az sql mi list 

--List managed instances -- id only 

az sql mi list --query "[].id"

--Get details of a managed instance

az sql mi show -g <replace_with_resource_group> -n <replace_with_managed_instance)

--list databases within a specific managed instance

az sql midb list -g  <replace_with_resource_group_name>  --mi <replace_with_managed_instance_name> 

 

--list databases within a specific managed instance and just certain columns - 

az sql midb list -g  <replace_with_managed_instance> --mi <replace_with_managed_instance>  --query "[].{Name:name,Location:location,defaultSecondaryLocation:defaultSecondaryLocation}" --output table

 

Availability Zones 

--Region to Availability Zone Mappings 

az rest --method get --uri "/subscriptions/{subscriptionId}/locations?api-version=2022-12-01" --query "value[?availabilityZoneMappings != `null`].{displayName: displayName, name: name, availabilityZoneMappings: availabilityZoneMappings}"

 

SQL Server restores

--Restore a database to an existing resource group\sql server managed instance using point in time recovery 

az sql midb restore -g <replace_with_resource_group> --mi <replace_with_managed_instance> -n <replace_with_db_name> --dest-name <replace_with_target_db_name> --time "2025-05-26T05:34:22"

Note: You cannot replace the existing db . If you attempt to recover over an existing db , you'll get an error message 


Author: Rambler (http://www.dba-ninja.com)


Share:

Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Working...
Your comment could not be posted. Error type:
Your comment has been posted. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.

Working...

Post a comment on Azure CLI commands cheatsheet


dba-ninja.com