public async Async.Task <bool> DeleteVmComponents(string name, Nsg?nsg) { var resourceGroup = _creds.GetBaseResourceGroup(); _logTracer.Info($"deleting vm components {resourceGroup}:{name}"); if (GetVm(name) != null) { _logTracer.Info($"deleting vm {resourceGroup}:{name}"); await DeleteVm(name); return(false); } var nic = await _ipOperations.GetPublicNic(resourceGroup, name); if (nic != null) { _logTracer.Info($"deleting nic {resourceGroup}:{name}"); if (nic.Data.NetworkSecurityGroup != null && nsg != null) { await _nsgOperations.DissociateNic((Nsg)nsg, nic); return(false); } await _ipOperations.DeleteNic(resourceGroup, name); return(false); } if (await _ipOperations.GetIp(resourceGroup, name) != null) { _logTracer.Info($"deleting ip {resourceGroup}:{name}"); await _ipOperations.DeleteIp(resourceGroup, name); return(false); } var disks = _diskOperations.ListDisks(resourceGroup) .ToAsyncEnumerable() .Where(disk => disk.Data.Name.StartsWith(name)); if (await disks.AnyAsync()) { await foreach (var disk in disks) { _logTracer.Info($"deleting disk {resourceGroup}:{disk?.Data.Name}"); await _diskOperations.DeleteDisk(resourceGroup, disk?.Data.Name !); } return(false); } return(true); }
public async Task <HttpResponseData> DeleteIp([HttpTrigger(AuthorizationLevel.Anonymous, "delete", Route = "testhooks/ipOps/ip")] HttpRequestData req) { _log.Info("Get public nic"); var query = UriExtension.GetQueryComponents(req.Url); var rg = query["rg"]; var name = query["name"]; var yes = UriExtension.GetBoolValue("force", query, false); if (yes) { await _ipOps.DeleteIp(rg, name); var resp = req.CreateResponse(HttpStatusCode.OK); return(resp); } else { var resp = req.CreateResponse(HttpStatusCode.NotModified); return(resp); } }