I am using an Azure Resource Manager template to deploy a VM in Azure. I have a custom script that runs once the VM is up. The script runs, even when the script fails the VM stays up. Is there a way to tear down the VM if the custom script fails?
"properties": {
"publisher": "Microsoft.Azure.Extensions",
"type": "CustomScript",
"typeHandlerVersion": "2.0",
"autoUpgradeMinorVersion": true,
"settings": {
"fileUris": [
"[uri(parameters('_artifactsLocation'), concat('scripts/copyfilefromazure.sh', parameters('_artifactsLocationSasToken')))]"
]
},
"protectedSettings": {
"commandToExecute": "[concat('bash ', variables('scriptFileName'), ' ', variables('scriptArgs'))]"
}