Delete created resources if deployment failed

Keren Zubovsky 21 Reputation points
2022-08-15T13:59:12.347+00:00

Hi,
I am using Python SDK to create a deployment with 2 resources.
In case the deployment fails - is there a flag or a parameter that can be passed to begin_create_or_update deployment function that will cause created resources to be deleted?
Is there any other way?

Thanks!

Not Monitored
Not Monitored
Tag not monitored by Microsoft.
35,882 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Joe Carlyle 661 Reputation points MVP
    2022-08-16T16:15:19.76+00:00

    Hi,

    There is no delete operation that you can run explicitly.

    However, you could create an empty template and deploy that in complete mode rather than incremental, this would remove that NIC for your next deployment. Obviously you would need to add the logic on your side to catch the failure and deploy the empty template - https://learn.microsoft.com/en-us/azure/azure-resource-manager/templates/deployment-modes