I have Azure Pipeline which creates VMs, Storage , NICs etc. And i want that these resources should be deleted if any of the task in the pipeline got failed. How this can be achieved, do I need to use script in my YAML or is there any extension available?
2
Answers
You haven’t mentioned which scripting language you are using to deploy these resources. It depends on both scripting language and logic. In this case YAML pipeline can be more useful like having stages or jobs. Also use ‘continue on error’ as true
echo "##vso[task.setvariable variable=ISVALIDBUILD;isOutput=true]True"
Please refer MS documents to get to know more about this, hope it helps you get started.
A sample for you. You just need to output the vars and then use condition to check:
The above is Storage service, other service are similar.
By the way, you can deploy all of the services to a new resource group, if failed, just delete the whole group.