Target unhealthy during release

We have an azure VM as a deployment target with polling tentacle . During deployment we switch ON the vm in one of the process steps and then run the health check on that target via powershell . The deploy to iis step still skips as it cannot find the target. Do i need make the target healthy before triggering off the release process ?
How do i automate this piece.

Hi @vinayak.tillu,

Thanks for reaching out.

I think the way you will want to go about this is to use the Step Template “Health Check” step:
image

This will run a health check on a role(or roles), and then based on its results you can have it add newly healthy targets to the deployment. You will need to place this step after the step that turns on your VMs.

Can you please give that step a look and a test and let me know if it will work for your use case?

Best,
Jeremy

That helped. Thank you ! I was trying this
$OctopusURL = “https://xyz.octopus.app”
$OctopusAPIKey = “API-xxxxxxxxxxxxxxxxxxxxxxxxx”
$MachineName = “vm##” #Machine Display Name
$spaceName = “default”
$header = @{ “X-Octopus-ApiKey” = $OctopusAPIKey }

Get space

$space = (Invoke-RestMethod -Method Get -Uri “$octopusURL/api/spaces/all” -Headers $header) | Where-Object {$_.Name -eq $spaceName}

Get machine

$machine = (Invoke-RestMethod -Method Get -Uri “$octopusURL/api/$($space.Id)/machines/all” -Headers $header) | Where-Object {$.Name -eq $MachineName}
$machineId = $machine.Id
$body = @{
Name = “Health”
Description = “Checking health of $MachineName”
Arguments = @{
Timeout= “00:05:00”
MachineIds = @($machineId) #$MachinID could contain an array of machines too
}
} | ConvertTo-Json
try {
$response = Invoke-RestMethod $OctopusURL/api/tasks -Method Post -Body $body -Headers $header -TimeoutSec 120
Write-Host $response.IsCompleted $response.FinishedSuccessfully
}
catch { Write-Host $
}

1 Like

Hi @vinayak.tillu,

You’re very welcome! Thanks for letting me know it worked for you.

Please let me know if you have any other questions or concerns.

Best,
Jeremy

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.