Get-AzSqlDatabase

In this Azure PowerShell article, we will discuss the syntax and the usage of the Get-AzSqlDatabase PowerShell command with examples.

Get-AzSqlDatabase

This is an excellent Azure PowerShell command to retrieve the lists of Azure SQL databases from your Azure SQL Database Server.

Syntax

Below is the syntax of the Get-AzSqlDatabase PowerShell command.

Get-AzSqlDatabase
 [[-ResourceGroupName] <String>
 [-ServerName] <String>
Get-AzSqlDatabase [[-ResourceGroupName] <String>  [-ServerName] <String>
[[-DatabaseName] <String>]

Let’s discuss a quick example of how to use the Get-AzSqlDatabase PowerShell command.

Example-1

You can execute the below PowerShell command to get the lists of the Azure SQL databases from the specified Azure SQL Server.

Get-AzSqlDatabase -ResourceGroupName "Demo1234" -ServerName "azurelessonssql"

After executing the above PowerShell command, I got the below output as expected.

ResourceGroupName                : Demo1234
ServerName                       : azurelessonssql
DatabaseName                     : DemoAzureLessons
Location                         : eastus
DatabaseId                       : d62d1382-01fe-4e99-9d9f-0792d524d601
Edition                          : Basic
CollationName                    : SQL_Latin1_General_CP1_CI_AS
CatalogCollation                 : 
MaxSizeBytes                     : 2147483648
Status                           : Online
CreationDate                     : 05-09-2023 07:55:23
CurrentServiceObjectiveId        : 00000000-0000-0000-0000-000000000000
CurrentServiceObjectiveName      : Basic
RequestedServiceObjectiveName    : Basic
RequestedServiceObjectiveId      : 
ElasticPoolName                  : 
EarliestRestoreDate              : 
Tags                             : {}
ResourceId                       : /subscriptions/1cdf4300-dee5-4518-9c9c-feaa72a5cbd1/resourceGroups/Demo1234/providers/Microsoft.Sql/servers/azureles
                                   sonssql/databases/DemoAzureLessons
CreateMode                       : 
ReadScale                        : Disabled
ZoneRedundant                    : False
Capacity                         : 5
Family                           : 
SkuName                          : Basic
LicenseType                      : 
AutoPauseDelayInMinutes          : 
MinimumCapacity                  : 
ReadReplicaCount                 : 
HighAvailabilityReplicaCount     : 
CurrentBackupStorageRedundancy   : Geo
RequestedBackupStorageRedundancy : Geo
SecondaryType                    : 
MaintenanceConfigurationId       : /subscriptions/1cdf4300-dee5-4518-9c9c-feaa72a5cbd1/providers/Microsoft.Maintenance/publicMaintenanceConfigurations/
                                   SQL_Default
EnableLedger                     : False
PreferredEnclaveType             : 
PausedDate                       : 
ResumedDate                      : 
Identity                         : 
EncryptionProtector              : 
Keys                             : 
FederatedClientId                : 

ResourceGroupName                : Demo1234
ServerName                       : azurelessonssql
DatabaseName                     : master
Location                         : eastus
DatabaseId                       : 54072818-4cc8-4c60-9f13-fcaaca708ed2
Edition                          : System
CollationName                    : SQL_Latin1_General_CP1_CI_AS
CatalogCollation                 : 
MaxSizeBytes                     : 53687091200
Status                           : Online
CreationDate                     : 05-09-2023 07:54:22
CurrentServiceObjectiveId        : 00000000-0000-0000-0000-000000000000
CurrentServiceObjectiveName      : System2
RequestedServiceObjectiveName    : System2
RequestedServiceObjectiveId      : 
ElasticPoolName                  : 
EarliestRestoreDate              : 
Tags                             : 
ResourceId                       : /subscriptions/1cdf4300-dee5-4518-9c9c-feaa72a5cbd1/resourceGroups/Demo1234/providers/Microsoft.Sql/servers/azureles
                                   sonssql/databases/master
CreateMode                       : 
ReadScale                        : Disabled
ZoneRedundant                    : False
Capacity                         : 0
Family                           : 
SkuName                          : System
LicenseType                      : 
AutoPauseDelayInMinutes          : 
MinimumCapacity                  : 
ReadReplicaCount                 : 
HighAvailabilityReplicaCount     : 
CurrentBackupStorageRedundancy   : Local
RequestedBackupStorageRedundancy : Local
SecondaryType                    : 
MaintenanceConfigurationId       : /subscriptions/1cdf4300-dee5-4518-9c9c-feaa72a5cbd1/providers/Microsoft.Maintenance/publicMaintenanceConfigurations/
                                   SQL_Default
EnableLedger                     : False
PreferredEnclaveType             : 
PausedDate                       : 
ResumedDate                      : 
Identity                         : 
EncryptionProtector              : 
Keys                             : 
FederatedClientId                : 

You can see the same output below

Get-AzSqlDatabase

Example-2

You can execute the below PowerShell command to get a database by the name specified on the mentioned server.

Get-AzSqlDatabase -ResourceGroupName "Demo1234" -ServerName "azurelessonssql" -DatabaseName "DemoAzureLessons"

After executing the above PowerShell script, I got the expected output as below.

Get-AzSqlDatabase PowerShell

Get-AzSqlDatabase – Video Tutorial

You may also like following the below articles

Conclusion

In this Azure PowerShell article, we discussed the syntax and the usage of the Get-AzSqlDatabase PowerShell command with examples. Thanks for reading this article !!!