/// <summary> /// Deletes an armTemplate record within an offer and removes the armTemplate file from blob storage. /// </summary> /// <param name="offerName">The name of the offer.</param> /// <param name="templateName">The name of the armTempalte to delete.</param> /// <returns>The deleted armTemplate db record.</returns> public async Task <ArmTemplate> DeleteAsync(string offerName, string templateName) { _logger.LogInformation(LoggingUtils.ComposeDeleteResourceMessage(typeof(ArmTemplate).Name, templateName, offerName: offerName)); // Get the armTemplate that matches the templateName provided var armTemplate = await GetAsync(offerName, templateName, useSaSKey : false); // Remove the armTemplate file from blob storage await _storageUtility.DeleteFileAsync(new Uri(armTemplate.TemplateFilePath)); // Remove the join entry form the db await _armTemplateArmTemplateParameterService.DeleteArmTemplateJoinEntriesAsync(armTemplate.Id); // Remove the armTemplate from the db _context.ArmTemplates.Remove(armTemplate); await _context._SaveChangesAsync(); _logger.LogInformation(LoggingUtils.ComposeResourceDeletedMessage(typeof(ArmTemplate).Name, templateName, offerName: offerName)); return(armTemplate); }