private void CleanupDatabaseServers(AzureResourceType type, Dictionary <string, object> resources) { SafeExecute(() => { var manager = new AzureSqlManager(); foreach (var obj in resources.Values) { var server = obj as SqlAzureServer; if (server == null) { throw new Exception(string.Format("Incorrect resource was stored in '{0}' collection", type)); } if (manager.GetSqlServer(server.Name, server.User, server.Password) != null) { var databases = server.GetDatabases(); // if after we deleted our databases there are still more than one (master) database, // it means some one reuses this server, so don't delete it if (databases.Count() <= 1) { manager.DeleteSqlServer(server.Name); } } } resources.Clear(); }, type.ToString()); }
private void CleanupContainers(AzureResourceType type, Dictionary <string, object> resources) { SafeExecute(() => { foreach (var c in resources.Values) { var container = c as CloudBlobContainer; if (container == null) { throw new Exception(string.Format("Incorrect resource was stored in '{0}' collection", type)); } container.DeleteIfExists(); } resources.Clear(); }, type.ToString()); }
private void CleanupBlobs(AzureResourceType type, Dictionary <string, object> resources) { SafeExecute(() => { foreach (var b in resources.Values) { var blob = b as CloudBlockBlob; if (blob == null) { throw new Exception(string.Format("Incorrect resource was stored in '{0}' collection", type)); } blob.DeleteIfExists(); } resources.Clear(); }, type.ToString()); }
private void CleanupWebSites(AzureResourceType type, Dictionary <string, object> resources) { SafeExecute(() => { var manager = new AzureWebSiteManager(); foreach (var obj in resources.Values) { var site = obj as WAML.WebSites.Models.WebSite; if (site == null) { throw new Exception(string.Format("Incorrect resource was stored in '{0}' collection", type)); } if (manager.WebSiteExists(site.Name)) { manager.DeleteWebSite(site.Name); } } resources.Clear(); }, type.ToString()); }
private void CleanupHostedServices(AzureResourceType type, Dictionary <string, object> resources) { SafeExecute(() => { var manager = new AzureCloudServiceManager(); foreach (var obj in resources.Values) { var service = obj as string; if (service == null) { throw new Exception(string.Format("Incorrect resource was stored in '{0}' collection", type)); } if (manager.GetHostedService(service) != null) { manager.DeleteHostedService(service); } } resources.Clear(); }, type.ToString()); }
private void CleanupDeployments(AzureResourceType type, Dictionary <string, object> resources) { SafeExecute(() => { var manager = new AzureCloudServiceManager(); foreach (var obj in resources.Values) { var deployment = obj as DeploymentInfo; if (deployment == null) { throw new Exception(string.Format("Incorrect resource was stored in '{0}' collection", type)); } if (manager.GetDeployment(deployment.HostedService, deployment.Deployment.Name) != null) { manager.DeleteDeployment(deployment.HostedService, deployment.Deployment.Name); } } resources.Clear(); }, type.ToString()); }
private void CleanupAffinityGroups(AzureResourceType type, Dictionary <string, object> resources) { SafeExecute(() => { var manager = new AzureAffinityGroupManager(); foreach (var obj in resources.Values) { var group = obj as string; if (group == null) { throw new Exception(string.Format("Incorrect resource was stored in '{0}' collection", type)); } if (manager.GetAffinityGroup(group) != null) { manager.DeleteAffinityGroup(group); } } resources.Clear(); }, type.ToString()); }
private void CleanupDatabases(AzureResourceType type, Dictionary <string, object> resources) { SafeExecute(() => { var manager = new AzureSqlManager(); foreach (var obj in resources.Values) { var database = obj as SqlAzureDatabase; if (database == null) { throw new Exception(string.Format("Incorrect resource was stored in '{0}' collection", type)); } if (manager.GetSqlServer(database.Server.Name, database.Server.User, database.Server.Password) != null && database.Server.DatabaseExists(database.Name)) { database.Server.DropDatabase(database.Name); } } resources.Clear(); }, type.ToString()); }
private void CleanupDatabaseServers(AzureResourceType type, Dictionary<string, object> resources) { SafeExecute(() => { var manager = new AzureSqlManager(); foreach (var obj in resources.Values) { var server = obj as SqlAzureServer; if (server == null) { throw new Exception(string.Format("Incorrect resource was stored in '{0}' collection", type)); } if (manager.GetSqlServer(server.Name, server.User, server.Password) != null) { var databases = server.GetDatabases(); // if after we deleted our databases there are still more than one (master) database, // it means some one reuses this server, so don't delete it if (databases.Count() <= 1) { manager.DeleteSqlServer(server.Name); } } } resources.Clear(); }, type.ToString()); }
private void CleanupDatabases(AzureResourceType type, Dictionary<string, object> resources) { SafeExecute(() => { var manager = new AzureSqlManager(); foreach (var obj in resources.Values) { var database = obj as SqlAzureDatabase; if (database == null) { throw new Exception(string.Format("Incorrect resource was stored in '{0}' collection", type)); } if (manager.GetSqlServer(database.Server.Name, database.Server.User, database.Server.Password) != null && database.Server.DatabaseExists(database.Name)) { database.Server.DropDatabase(database.Name); } } resources.Clear(); }, type.ToString()); }
private void CleanupWebSites(AzureResourceType type, Dictionary<string, object> resources) { SafeExecute(() => { var manager = new AzureWebSiteManager(); foreach (var obj in resources.Values) { var site = obj as WAML.WebSites.Models.WebSite; if (site == null) { throw new Exception(string.Format("Incorrect resource was stored in '{0}' collection", type)); } if(manager.WebSiteExists(site.Name)) { manager.DeleteWebSite(site.Name); } } resources.Clear(); }, type.ToString()); }
private void CleanupHostedServices(AzureResourceType type, Dictionary<string, object> resources) { SafeExecute(() => { var manager = new AzureCloudServiceManager(); foreach (var obj in resources.Values) { var service = obj as string; if (service == null) { throw new Exception(string.Format("Incorrect resource was stored in '{0}' collection", type)); } if (manager.GetHostedService(service) != null) { manager.DeleteHostedService(service); } } resources.Clear(); }, type.ToString()); }
private void CleanupDeployments(AzureResourceType type, Dictionary<string, object> resources) { SafeExecute(() => { var manager = new AzureCloudServiceManager(); foreach (var obj in resources.Values) { var deployment = obj as DeploymentInfo; if (deployment == null) { throw new Exception(string.Format("Incorrect resource was stored in '{0}' collection", type)); } if (manager.GetDeployment(deployment.HostedService, deployment.Deployment.Name) != null) { manager.DeleteDeployment(deployment.HostedService, deployment.Deployment.Name); } } resources.Clear(); }, type.ToString()); }
private void CleanupAffinityGroups(AzureResourceType type, Dictionary<string, object> resources) { SafeExecute(() => { var manager = new AzureAffinityGroupManager(); foreach (var obj in resources.Values) { var group = obj as string; if (group == null) { throw new Exception(string.Format("Incorrect resource was stored in '{0}' collection", type)); } if(manager.GetAffinityGroup(group) != null) { manager.DeleteAffinityGroup(group); } } resources.Clear(); }, type.ToString()); }
private void CleanupContainers(AzureResourceType type, Dictionary<string, object> resources) { SafeExecute(() => { foreach (var c in resources.Values) { var container = c as CloudBlobContainer; if (container == null) { throw new Exception(string.Format("Incorrect resource was stored in '{0}' collection", type)); } container.DeleteIfExists(); } resources.Clear(); }, type.ToString()); }
private void CleanupBlobs(AzureResourceType type, Dictionary<string, object> resources) { SafeExecute(() => { foreach (var b in resources.Values) { var blob = b as CloudBlockBlob; if (blob == null) { throw new Exception(string.Format("Incorrect resource was stored in '{0}' collection", type)); } blob.DeleteIfExists(); } resources.Clear(); }, type.ToString()); }