Switch-AzSqlDatabaseInstanceFailoverGroup
Executes a failover of an Instance Failover Group.
Syntax
SwitchInstanceFailoverGroupDefaultSet (Default)
Switch-AzSqlDatabaseInstanceFailoverGroup
[-ResourceGroupName] <String>
[-Location] <String>
[-Name] <String>
[-AllowDataLoss]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
SwitchInstanceFailoverGroupByResourceIdSet
Switch-AzSqlDatabaseInstanceFailoverGroup
[-Location] <String>
[-ResourceId] <String>
[-AllowDataLoss]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Switch-AzSqlDatabaseInstanceFailoverGroup
[-InputObject] <AzureSqlInstanceFailoverGroupModel>
[-AllowDataLoss]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Description
This command swaps the roles of the managed instances in a Instance Failover Group by failing over to the specified secondary region, making it the new primary region. All new TDS sessions connecting to the primary endpoint are automatically re-routed to the new primary region.
Examples
Example 1
Get-AzSqlDatabaseInstanceFailoverGroup -ResourceGroupName rg -Location location -Name fg | Switch-AzSqlDatabaseInstanceFailoverGroup -AllowDataLoss
ResourceGroupName : rg
Location : East US
Name : fg
PartnerResourceGroupName : rg
PartnerRegion : West US
PrimaryManagedInstanceName : managedInstance1
PartnerManagedInstanceName : managedInstance2
ReplicationRole : Primary
ReplicationState : CATCH_UP
ReadWriteFailoverPolicy : Automatic
FailoverWithDataLossGracePeriodHours : 1
ReadOnlyFailoverPolicy : Disabled
Id : /subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/rg/providers/Microsoft.Sql/locations/eastus/instanceFailoverGroups/fg
Issue a failover operation allowing data loss by piping in the Instance Failover Group.
Example 2
Get-AzSqlDatabaseInstanceFailoverGroup -ResourceGroupName rg -Location location -Name fg | Switch-AzSqlDatabaseInstanceFailoverGroup
ResourceGroupName : rg
Location : East US
Name : fg
PartnerResourceGroupName : rg
PartnerRegion : West US
PrimaryManagedInstanceName : managedInstance1
PartnerManagedInstanceName : managedInstance2
ReplicationRole : Primary
ReplicationState : CATCH_UP
ReadWriteFailoverPolicy : Automatic
FailoverWithDataLossGracePeriodHours : 1
ReadOnlyFailoverPolicy : Disabled
Id : /subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/rg/providers/Microsoft.Sql/locations/eastus/instanceFailoverGroups/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: 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
-Confirm
Prompts you for confirmation before running the cmdlet.
Parameter properties
Type: SwitchParameter
Default value: None
Supports wildcards: False
DontShow: False
Aliases: cf
Parameter sets
(All)
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-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
(All)
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
The Instance Failover Group object to switch
SwitchInstanceFailoverGroupByInputObjectSet
Position: 0
Mandatory: True
Value from pipeline: True
Value from pipeline by property name: False
Value from remaining arguments: False
-Location
The name of the Local Region of the secondary instance in the Instance Failover Group.
Parameter properties
Type: String
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
SwitchInstanceFailoverGroupDefaultSet
Position: 1
Mandatory: True
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
SwitchInstanceFailoverGroupByResourceIdSet
Position: 1
Mandatory: True
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-Name
The name of the Instance Failover Group.
Parameter properties
Type: String
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
SwitchInstanceFailoverGroupDefaultSet
Position: 2
Mandatory: True
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-ResourceGroupName
The name of the resource group of the secondary instance in the Instance Failover Group.
Parameter properties
Type: String
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
SwitchInstanceFailoverGroupDefaultSet
Position: 0
Mandatory: True
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-ResourceId
The Resource ID of the Instance Failover Group to switch.
Parameter properties
Type: String
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
SwitchInstanceFailoverGroupByResourceIdSet
Position: 0
Mandatory: True
Value from pipeline: False
Value from pipeline by property name: True
Value from remaining arguments: False
-WhatIf
Shows what would happen if the cmdlet runs.
The cmdlet is not run.
Parameter properties
Type: SwitchParameter
Default value: None
Supports wildcards: False
DontShow: False
Aliases: wi
Parameter sets
(All)
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
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 .
Outputs