Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deleting deployment in a resource group doesn't delete the resources in the deployment #585

Closed
lyan-git opened this issue Apr 20, 2016 · 6 comments

Comments

@lyan-git
Copy link

Hi,

I was trying to delete a resource group deployment by calling
resource_client.deployments.delete()...
But found that the deployment was gone but the resources in the deployment were not deleted actually. Tried with ARM portal as well, same result.
I know this is not related to SDK but more of the result of REST API. Just want to find out a way to delete the deployment and included resources without deleting resource group.

Thanks.
Li

@devigned
Copy link
Member

devigned commented Apr 20, 2016

Hi @lyan-git. Thank you for reaching out.

What you are experiencing is exactly what I ran into initially when developing in ARM. I expected that when I delete a deployment, that all of the resources created in that deployment would also be deleted. Unfortunately, that is not the case.

To clean up a deployment, you will have to delete the resources one by one, or you would need to delete the resource group. That is why I usually create a new resource group for each of my deployments. That way, I can just delete the resource group, and that would cause all of my resources to be deleted as well.

I hope this helps. If you have any questions, please ping back. I'm going to close the issue, but don't let that discourage further conversation.

@lyan-git
Copy link
Author

Hi David,

Thanks for your reply.
But we have a case where we have a vnet that contains a load balancer with multiple gateways attached to it. The load balancer and the gateway need to be within one resource group according to my experience in ARM. So we have a resource group that contain both load balancer deployment and multiple gateway deployments.
Now if the user want to delete a gateway only, we try to delete deployment logic entity rather than delete the whole resource group which will delete both load balancer and all gateway deployments.Then we are facing the fact that the resources under deployment are not deleted. Do we need to delete those resources one by one? If we can create a deployment in one template, why can't we delete the deployment template resources at one time just like resource group? I thought the delete deployment should bring in that function...

Just my 2 cents. Hope to hear back from you.

Thanks.
Li

@devigned
Copy link
Member

Thank you for your thorough explanation of why and how you are approaching this problem. I'm including @ravbhatnagar from the Azure Resource Manager team to provide some additional guidance (and to correct me if I'm guiding you down the wrong path).

As far as I know, you will need to delete the resources one by one. You don't need to delete the whole resource group as that will delete all of the resources in that group.

"Why can't we delete the deployment template resources at one time just like resource group?

As I had mentioned before, I thought the same way about deployments as you are thinking about them, but deleting a deployment does not remove the resources deployed in that deployment. In fact, I'd love to see Azure Resource Manager function this way with regard to deployments.

@ravbhatnagar
Copy link

@lyan-git - Yes, deleting the resource group will delete all the resources in that resource group. So if you want to only delete specific resources, you will have to delete the resources individually.

However, depending on your scenario, there might be another option. If all these resources, are now part of the same template, you can remove the resources you don't need anymore from the template. Then deploy that template to the same resource group but using Mode = Complete. This is delete all the resources that are not defned in your template but present in your resource group.

Does that make sense? Let me know if you have further questions on this. I would be happy to discuss this further.

@lyan-git
Copy link
Author

I thought that is what the delete API of the deployment suppose do. So you create a deployment with a template of resources as a logical group in a resource group and when you delete the deployment the resources in the template are removed. Right now the delete of the deployment is not removing any of the resource in the deployment as a delete of resource group does.

Thanks.
Li

@arocki7
Copy link

arocki7 commented Dec 4, 2018

@lyan-git - Yes, deleting the resource group will delete all the resources in that resource group. So if you want to only delete specific resources, you will have to delete the resources individually.

However, depending on your scenario, there might be another option. If all these resources, are now part of the same template, you can remove the resources you don't need anymore from the template. Then deploy that template to the same resource group but using Mode = Complete. This is delete all the resources that are not defned in your template but present in your resource group.

Does that make sense? Let me know if you have further questions on this. I would be happy to discuss this further.

Complete mode will wipe out the resources which are already there. Be careful while using this mode.

@github-actions github-actions bot locked and limited conversation to collaborators Apr 13, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants