0

I have created two Premium Azure Cache for Redis resources and set up geo replication. There is a button in the portal to failover manually.

How can I trigger this failover with Azure CLI?

I tried the az redis force-reboot --resource-group $resourceGroupName --name $redisPrimary --reboot-type $rebootType command to no avail.

5
  • what's the problem with tis command ? could you add the error message please ? Also which version of az cli are you using ? Commented Sep 13, 2023 at 17:43
  • @Thomas the command runs fine, the cache is rebooted. But I was hoping that using the force-reboot would trigger a failover to the secondary cache, which is not the case Commented Sep 13, 2023 at 18:04
  • have you seen this article ? carlos.mendible.com/2021/11/21/… ? did you have some clients connected to the cache ? Commented Sep 13, 2023 at 18:54
  • 1
    @Thomas thanks for the article. I figured out in the meantime I will have to use Redis CLI. I will take a look and post results (how-to) Commented Sep 15, 2023 at 7:34
  • Awesome, good to hear you re making progress Commented Sep 15, 2023 at 7:36

1 Answer 1

0

I did it in PowerShell by breaking the (geo-replication) link between de caches and then re-creating it, making sure to reverse the primary and secondary cache.

Use the provisioning state to monitor the state after deleting or creating the link:

$provisioningState = (Get-AzRedisCache -Name $cacheNamePrimary).ProvisioningState if ($provisioningState -eq 'Succeeded') { etc.. } 

One gotcha, after removing the link Remove-AzRedisCacheLink and trying to create a new one New-AzRedisCacheLink, an error might occur even though the provisioning state will report 'Succeeded'. Error message: Operation returned an invalid status code 'Conflict'.

In this case I created a while loop that breaks when the New-AzRedisCacheLink returns no error:

# Create cache link (geo-replication) while ($true) { $provisioningState = (Get-AzRedisCache -Name $cacheNamePrimary).ProvisioningState if ($provisioningState -eq 'Succeeded') { try { New-AzRedisCacheLink -PrimaryServerName $cacheNameSecondary -SecondaryServerName $cacheNamePrimary -ErrorAction Stop break } catch { Write-Output "Trying to creating cache link but received an error '$($_)'.. probably busy processing something.. retrying.." Start-Sleep -Milliseconds 20000 } } else { Start-Sleep -Milliseconds 30000 Write-Output "Still waiting for cache link to be removed.. provisioning status '$provisioningState'.." } } 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.