OK, I don't know if this is going to solve your issue. I'll post what I have and then explain:
"autoHealEnabled": true,
"autoHealRules": {
"triggers": {
"requests": null,
"privateBytesInKB": 0,
"statusCodes": [],
"statusCodesRange": [
{
"statusCodes": "500-530",
"path": "",
"count": 10,
"timeInterval": "00:02:00"
}
],
"slowRequests": null,
"slowRequestsWithPath": []
},
"actions": {
"actionType": 0,
"customAction": null,
"minProcessExecutionTime": "00:00:00"
}
},
Here's what I did:
- Went to the activity log for the app service and pulled up the most recent change JSON. no result
- Exported the template for that resource in the resource group export. Looked through all history. no result - only what appeared to be an empty config for auto heal
- Ran Export-AzResourceGroup to do the same thing, same as 2.
- Went to the diagnostics blade for the app service and pulled up Auto Heal with the debugger turned on, and went to the custom rules tab. In the traffic log, I found a request to the management API that returned a result which included the configuration above. Success???
Bottom line? I think you could try this. It might work. I'm not convinced this is completely wired into ARM in a standard way, and it may be possible that it has to be done by API.
Edit: I just verified in Postman that https://management.azure.com/subscriptions/{{subscriptionId}}/resourceGroups/{{resourceGroupName}}/providers/Microsoft.Web/sites/{{appServiceName}}/config/web?api-version=2015-08-01 returns the auto-heal settings. So, it's probable that if ARM templates aren't doing the trick you might be able to do this with the API.
Edit: So, I used $app = Get-AzWebApp ...
on an app service where I had this set up, and $app.SiteConfig.AutoHealRules.Triggers
only includes Requests, PrivateBytesInKB, StatusCodes (not range), and SlowRequests. So, using Set-AzWebApp
looks like it's not ready for that yet.
You could try something like this - it's not debugged:
$props = @{
autoHealEnabled = $true
autoHealRules = @{
triggers = @{
requests = $null
privateBytesInKB = 0
statusCodes = @()
statusCodesRange = @(
{
statusCodes = "500-530"
path = ""
count = 10
timeInterval = "00:02:00"
}
)
slowRequests = $null
slowRequestsWithPath = @()
}
actions = @{
actionType = 0
customAction = $null
minProcessExecutionTime = "00:00:00"
}
}
}
Set-AzResource -$props -ResourceGroupName "YourResourceGroup" -ResourceName "YourAppServiceName/web" -ResourceType "Microsoft.Web/sites/config"