Runbooks can be executed on a recurring schedule called a trigger. Using this feature, you can have a runbook execute periodically to ensure that your application is up and running, then automatically failover if it is not.
The following example tests the URL of an application, if the expected 200
code is not returned, the runbook will automatically start the DR web and SQL Server in Azure, then update the DNS to point to the DR site.
Create the runbook
- To create a runbook, navigate to Project ➜ Operations ➜ Runbooks ➜ Add Runbook.
- Give the runbook a name and click SAVE.
- Click DEFINE YOUR RUNBOOK PROCESS, then click ADD STEP.
Add the following steps:
- Community Step Template HTTP - Test URL.
Run an Azure Script
to start Web server; configured to run only on failure:
$name = $OctopusParameters["OctoFX.Azure.WebApp.Name"]
$resourceGroup = $OctopusParameters["OctoFX.Azure.Resource.Group"]
Write-Highlight "Starting $name"
Start-AzureRmVM -ResourceGroupName $resourceGroup -Name $name
Run an Azure Script
to start the database server; configured to run only on failure and in parallel with the web server step:
$name = $OctopusParameters["OctoFX.Azure.SQL.Name"]
$resourceGroup = $OctopusParameters["OctoFX.Azure.Resource.Group"]
Start-AzureRmVM -ResourceGroupName $resourceGroup -Name $name
Run an Azure Script
to update the DNS entry; configured to run only on failure:
$resourceGroup = $OctopusParameters["OctoFX.Azure.Resource.Group"]
$zoneName = $OctopusParameters["OctoFX.DNS.Name"]
$ipAddressDR = $OctopusParameters["OctoFX.DR.IP.Address"]
$ipAddressProd = $OctopusParameters["OctoFX.Production.IP.Address"]
az network dns record-set a add-record --resource-group $resourceGroup --zone-name $zoneName --record-set-name www --ipv4-address $ipAddressProd
az network dns record-set a remove-record --resource-group $resourceGroup --zone-name $zoneName --record-set-name www --ipv4-address $ipAddressDR
Create the trigger
- To create a trigger, navigate to Project ➜ Operations ➜ Triggers ➜ Add Scheduled Trigger.
- Give the trigger a name and a description
- Fill in Trigger Action section:
- Runbook: Select the runbook to execute.
- Target environments: Select the environment(s) this runbook will execute against.
- Fill in the Trigger Schedule section:
- Schedule: Daily | Days per month | Cron expression.
- Scheduled Timezone:
- Select timezone: Select the timezone to use when evaluating when to run.
Samples
We have a Target - Windows Space on our Samples instance of Octopus. You can sign in as Guest
to take a look at this example and more runbooks in the OctoFX
project.
Help us continuously improve
Please let us know if you have any feedback about this page.
Page updated on Sunday, January 1, 2023