Note
Access to this page requires authorization. You can try signing in or .
Access to this page requires authorization. You can try .
Switch-AzSqlDatabaseFailoverGroup
- Module:
- Az.Sql Module
Executes a failover of an Azure SQL Database Failover Group.
Syntax
Default (Default)
Switch-AzSqlDatabaseFailoverGroup
[-ServerName] <String>
[[-FailoverGroupName] <String>]
[-AllowDataLoss]
[-TryPlannedBeforeForcedFailover]
[-AsJob]
[-ResourceGroupName] <String>
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Description
This command swaps the roles of the servers in a Failover Group and switches all secondary databases to the primary role. All new TDS sessions are automatically re-routed to the secondary server after the DNS client cache is refreshed. When the original primary server is back online, all formerly primary databases in it will switch to the secondary role. The Failover Group's secondary server must be used to execute this command. If the AllowDataLoss parameter is not specified, this command waits until both roles are switched. If the AllowDataLoss parameter is specified, the command only waits until the new primary assumes its role.
Examples
Example 1
Get-AzSqlDatabaseFailoverGroup -ResourceGroupName rg -ServerName secondaryserver -FailoverGroupName fg | Switch-AzSqlDatabaseFailoverGroup -AllowDataLoss
Issue a failover operation allowing data loss by piping in the Failover Group.
Example 2
Switch-AzSqlDatabaseFailoverGroup -ResourceGroupName rg -ServerName secondaryserver -FailoverGroupName fg
Issue a best effort failover operation that will either succeed without losing data or fail and roll back.
Parameters
-AllowDataLoss
Complete the failover even if doing so may result in data loss. This will allow the failover to proceed even if a primary database is unavailable.
Parameter properties
| Type: | SwitchParameter |
| Default value: | False |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-AsJob
Run cmdlet in the background
Parameter properties
| Type: | SwitchParameter |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-Confirm
Prompts you for confirmation before running the cmdlet.
Parameter properties
| Type: | SwitchParameter |
| Default value: | False |
| Supports wildcards: | False |
| DontShow: | False |
| Aliases: | cf |
Parameter sets
-DefaultProfile
The credentials, account, tenant, and subscription used for communication with azure
Parameter properties
| Type: | IAzureContextContainer |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
| Aliases: | AzContext, AzureRmContext, AzureCredential |
Parameter sets
-FailoverGroupName
The name of the Azure SQL Database Failover Group.
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-ResourceGroupName
The name of the resource group.
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-ServerName
The name of the secondary Azure SQL Database Server of the Failover Group.
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-TryPlannedBeforeForcedFailover
Performs planned failover as first step and if it fails for any reason then forced failover with potential data loss is initiated. This will allow the failover to proceed even if a primary database is unavailable.
Parameter properties
| Type: | SwitchParameter |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-WhatIf
Shows what would happen if the cmdlet runs. The cmdlet is not run.
Parameter properties
| Type: | SwitchParameter |
| Default value: | False |
| Supports wildcards: | False |
| DontShow: | False |
| Aliases: | wi |
Parameter sets
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
String
Outputs
AzureSqlFailoverGroupModel
Related Links
Azure PowerShell
Feedback
Was this page helpful?
