Deleting VNets in script #309
|
I'm writing a script that deletes vnets. I'm trying to figure out what, if any, API calls I need to make to IPAM when deleting a vnet that was created with an IPAM reservation, in order for the CIDR to become available for a new reservation. It looks like reservations become 'fulfilled' (or 'settled') once a vnet is created using that CIDR. If I then delete that vnet, the settled reservation still exists - will that prevent the CIDR from being reissued? The vnet itself shows up in red and as 'ErrNotFound' in the UI - do I need to do an API call to delete it completely? If I do have to make API calls to delete either the reservation or the network in this situation, do I really have to know the Block id to do so? It seems like if I know the reservation ID, I should be able to delete it without knowing what block it belongs to. It also doesn't appear that I can easily query the reservation by its ID alone? So would I have to get a list of all reservations in the space and filter it, if I know the Space name and the Reservation ID but not which block it might have been assigned to? (All of this may be moot if deleting the actual vnet has already returned the cidr range to circulation, which a previous thread I was reading through suggests may be the case) |
Replies: 2 comments 11 replies
|
Hey @timothycrall, allow me to explain some of these items you mentioned a bit further.... From a Reservation perspective, until a Reservation is "fulfilled" or "cancelled", the CIDR assigned to that Reservation will affect availability of future CIDR requests, meaning that the tool will not assign a CIDR that overlaps a Reservation that is in a non-fulfilled/non-cancelled state. Once the Reservation becomes fulfilled/cancelled, that CIDR is no longer blocked by the Reservation process (which leads to the next item). When a Virtual Network is associated to a Block, the CIDR space of that Virtual Network affects the availability of future CIDR requests, meaning that the tool will not assign a CIDR that overlaps a currently associated Virtual Networks address space. Once a Virtual Network is either deleted within Azure, or un-associated with a Block, that CIDR will become available for assignment once again. Here an abbreviated list of the order of the checks that happen when requesting a new CIDR:
To directly answer your question from above of what API calls that you need to worry about in order to free a CIDR space, the answer is simply to call the DELETE API to remove the Virtual Network association from the target Block. Technically, once you delete the Virtual Network from Azure then the tool will no longer see the CIDR as used, however the UI will mark that stale entry as "ErrNotFound" because the association to the Virtual Network ID is still there because the current behavior doesn't auto-remove these entries when the Virtual Network is no longer detected (this is changing shortly). Here is the API I was referring to above: So I know that was a lot, and I'm sure you'll have additional questions. Please know that I'm here to support you whatever you many need, and if you'd prefer to have a live conversation simply shoot me an email at Matthew.Garrett@microsoft.com and we can go through everything in real time. |
|
@DCMattyG has this feature been implemented in the meantime? Documented limitations are ambiguous imho. |

Hey @timothycrall, allow me to explain some of these items you mentioned a bit further....
From a Reservation perspective, until a Reservation is "fulfilled" or "cancelled", the CIDR assigned to that Reservation will affect availability of future CIDR requests, meaning that the tool will not assign a CIDR that overlaps a Reservation that is in a non-fulfilled/non-cancelled state. Once the Reservation becomes fulfilled/cancelled, that CIDR is no longer blocked by the Reservation process (which leads to the next item).
When a Virtual Network is associated to a Block, the CIDR space of that Virtual Network affects the availability of future CIDR requests, meaning that the tool will not assig…