In MS docs for AzureCLI, we couldn't find, az command to do perform the Switchover activity from our primary Service Bus to the Secondary Service Bus.
We are performing, below activities as part of the switchover and couldn't find the required AZ commands to fulfill our requirements.
Task 1. Re-initiate the Pairing with secondary namespace (for which the alias already present, for which we already have the alias created). Here we cold find only to create a new paring , but not with existing.
az servicebus georecovery-alias create --alias <prim-second-existing alias-name> --namespace-name <primary-sb-namespace-name> --partner-namespace <secondary-sb-namespace-name> --resource-group <primary-sb-namespace-RGName>
Perform Failover:-
az servicebus georecovery-alias fail-over <prim-second-existing alias-name> --ids <secondary-sb-namespace-name> --is-safe-failover y -namespace-name <primary-sb-namespace-name> --resource-group <primary-sb-namespace-RGName>
task3:- Once Failover done, Delete Ques and topics from the Primary-SB-instance Namespace. Here how to find the pending ques and topics in the primary instance to set it for deletion
az servicebus topic delete --ids pending-TopicIds --name yyyy --namespace-name <primary-sb-namespace-name> --resource-group <primary-sb-namespace-RGName> --subscription ssssss
For ques
az servicebus queue delete --ids pending-queids --name que-name --namespace-name <primary-sb-namespace-name> --resource-group <primary-sb-namespace-RGName> --subscription ssssssss
Firstly, I have created an alias for disaster recovery configuration of a service bus namespace with the partner namespace as shown below.
Now before reinitiating the pair, use
az servicebus georecovery-alias break-pairbash command to disable the disaster recovery existed alias configuration for avoiding conflicts.Once it is disabled, now again set it with the new alias or the same alias with the
az servicebus georecovery-alias setas shown.Note:
If you wanted to check the existed or recently created alias under a service bus namespace, use below command to list it out.
Now you can go ahead with the other tasks like fail over as well as deleting the topics or queues according to your requirement with the corresponding commands.
az servicebus queue deleteRefer MS Doc for Az bash commands
az servicebus georecovery-alias.