Get-AzureSqlDatabase
Retrieves one or more databases.
Note
The cmdlets referenced in this documentation are for managing legacy Azure resources that use Azure Service Manager (ASM) APIs. This legacy PowerShell module isn't recommended when creating new resources since ASM is scheduled for retirement. For more information, see Azure Service Manager retirement.
The Az PowerShell module is the recommended PowerShell module for managing Azure Resource Manager (ARM) resources with PowerShell.
Syntax
ByConnectionContext (Default)
Get-AzureSqlDatabase
-ConnectionContext <IServerDataServiceContext>
[-Database <Database>]
[-DatabaseName <String>]
[-RestorableDropped]
[-RestorableDroppedDatabase <RestorableDroppedDatabase>]
[-DatabaseDeletionDate <DateTime>]
[-Profile <AzureSMProfile>]
[<CommonParameters>]
ByServerName
Get-AzureSqlDatabase
-ServerName <String>
[-Database <Database>]
[-DatabaseName <String>]
[-RestorableDropped]
[-RestorableDroppedDatabase <RestorableDroppedDatabase>]
[-DatabaseDeletionDate <DateTime>]
[-Profile <AzureSMProfile>]
[<CommonParameters>]
Description
The Get-AzureSqlDatabase cmdlet retrieves one or more instances of an Azure SQL Database from an Azure SQL Database server. You can specify the server with an Azure SQL Database server connection context that you create using the New-AzureSqlDatabaseServerContext cmdlet. Or, if you specify the Azure SQL Database server name, the cmdlet uses the current Azure subscription information to authenticate the request to access the server.
If you do not specify a database, the Get-AzureSqlDatabase cmdlet returns all databases from the specified server.
Retrieving restorable dropped databases:
Retrieve restorable dropped databases by using the RestorableDropped parameter. To return all restorable dropped databases use the RestorableDropped parameter without DatabaseName and DatabaseDeletionDate. To return a specific restorable dropped database use the RestorableDropped parameter with the DatabaseName and DatabaseDeletionDate parameters. When retrieving a specific restorable dropped database by using the DatabaseName parameter you must also include the DatabaseDeletionDate parameter and the specified DatabaseDeletionDate value must include milliseconds to match the desired database.
The Get-AzureSqlDatabase cmdlet returns either all restorable dropped databases on a server, or one specific database that matches both DatabaseName and DatabaseDeletionDate. To return restorable dropped databases that satisfy different criteria, such as all restorable dropped databases of a specific name, you must return all restorable dropped databases, and then filter the results on the client.
Examples
Example 1: Retrieve all databases on a server
PS C:\> Get-AzureSqlDatabase -ServerName "lpqd0zbr8y"
This command retrieves all databases on the server named lpqd0zbr8y.
Example 2: Retrieve all restorable dropped databases on a server
PS C:\> Get-AzureSqlDatabase -ServerName "lpqd0zbr8y" -RestorableDropped
This command retrieves all restorable dropped databases on the server named lpqd0zbr8y.
Example 3: Retrieve a database from a server specified by a connection context
PS C:\> $Database01 = Get-AzureSqlDatabase -ConnectionContext $Context -DatabaseName "Database01"
This command retrieves database named Database01 from the server specified by the connection context $Context.
Example 4: Store a database object in a variable
PS C:\> $Database01 = Get-AzureSqlDatabase -ServerName "lpqd0zbr8y" -DatabaseName "Database01"
This command retrieves database named Database01 from the server named lpqd0zbr8y. The command stores the database object in the $Database01 variable.
Example 5: Retrieve a restorable dropped database
PS C:\> $DroppedDB = Get-AzureSqlDatabase -ServerName "lpqd0zbr8y" -DatabaseName "Database01" -DatabaseDeletionDate "2012-11-09T22:59:43.000Z" -RestorableDropped
This command retrieves the restorable dropped database named Database01 that was deleted on 11/9/2012 from the server named lpqd0zbr8y. This command stores the results in the $DroppedDB variable.
Example 6: Retrieve all restorable dropped databases on a server and filter the results
PS C:\> Get-AzureSqlDatabase -ServerName "lpqd0zbr8y" -RestorableDropped | Where-Object {$_.Name -eq "ContactDB"}
This command retrieves all restorable dropped databases on the server named lpqd0zbr8y, and then filters the results to only the databases named ContactDB.
Parameters
-ConnectionContext
Specifies the connection context of a server from which to retrieve a database.
Parameter properties
Type: | IServerDataServiceContext |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Aliases: | Context |
Parameter sets
ByConnectionContext
Position: | Named |
Mandatory: | True |
Value from pipeline: | True |
Value from pipeline by property name: | True |
Value from remaining arguments: | False |
-Database
Specifies an object that represents the database that this cmdlet retrieves.
Parameter properties
Type: | Database |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Parameter sets
(All)
Position: | Named |
Mandatory: | False |
Value from pipeline: | True |
Value from pipeline by property name: | False |
Value from remaining arguments: | False |
-DatabaseDeletionDate
Specifies the date and time of a deletion. If you specify the RestorableDropped parameter, specify this parameter to retrieve a restorable dropped database based on the deletion date and time.
The DatabaseDeletionDate parameter must include milliseconds to match the time of the desired database. Specifying a value without milliseconds results in the database not being found.
Parameter properties
Type: | DateTime |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Parameter sets
(All)
Position: | Named |
Mandatory: | False |
Value from pipeline: | False |
Value from pipeline by property name: | False |
Value from remaining arguments: | False |
-DatabaseName
Specifies the name of the database that this cmdlet retrieves.
Parameter properties
Type: | String |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Parameter sets
(All)
Position: | Named |
Mandatory: | False |
Value from pipeline: | False |
Value from pipeline by property name: | False |
Value from remaining arguments: | False |
-Profile
Specifies the Azure profile from which this cmdlet reads. If you do not specify a profile, this cmdlet reads from the local default profile.
Parameter properties
Type: | AzureSMProfile |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Parameter sets
(All)
Position: | Named |
Mandatory: | False |
Value from pipeline: | False |
Value from pipeline by property name: | False |
Value from remaining arguments: | False |
-RestorableDropped
Indicates that this cmdlet returns RestorableDroppedDatabase objects instead of Database objects. You can use the DatabaseDeletionDate parameter to select a specific restorable dropped database.
Parameter properties
Type: | SwitchParameter |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Parameter sets
(All)
Position: | Named |
Mandatory: | False |
Value from pipeline: | False |
Value from pipeline by property name: | False |
Value from remaining arguments: | False |
-RestorableDroppedDatabase
Specifies an object that represents the restorable dropped database that this cmdlet retrieves.
Parameter properties
Type: | RestorableDroppedDatabase |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Parameter sets
(All)
Position: | Named |
Mandatory: | False |
Value from pipeline: | True |
Value from pipeline by property name: | False |
Value from remaining arguments: | False |
-ServerName
Specifies the name of the server that contains the database that this cmdlet retrieves. The cmdlet uses the current Azure subscription to access the server.
Parameter properties
Type: | String |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Parameter sets
ByServerName
Position: | Named |
Mandatory: | True |
Value from pipeline: | False |
Value from pipeline by property name: | True |
Value from remaining arguments: | False |
CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
Inputs
Microsoft.WindowsAzure.Commands.SqlDatabase.Services.Server.Database
Microsoft.WindowsAzure.Commands.SqlDatabase.Services.Server.RestorableDroppedDatabase
Outputs
IEnumerable
This cmdlet returns a Database object if you do not specify the RestorableDropped parameter.
IEnumerable
This cmdlet returns a RestorableDroppedDatabase object if you specify the RestorableDropped parameter.