public void DeleteSite(string applicationName) { var iis = new IIS.ServerManager(); // Get the app pool for this application string appPoolName = GetAppPool(applicationName); IIS.ApplicationPool kuduPool = iis.ApplicationPools[appPoolName]; // Make sure the acls are gone RemoveAcls(applicationName, appPoolName); if (kuduPool == null) { // If there's no app pool then do nothing return; } DeleteSite(iis, GetLiveSite(applicationName)); DeleteSite(iis, GetDevSite(applicationName)); // Don't delete the physical files for the service site DeleteSite(iis, GetServiceSite(applicationName), deletePhysicalFiles: false); iis.CommitChanges(); string appPath = _pathResolver.GetApplicationPath(applicationName); var sitePath = _pathResolver.GetLiveSitePath(applicationName); var devPath = _pathResolver.GetDeveloperApplicationPath(applicationName); try { kuduPool.StopAndWait(); DeleteSafe(sitePath); DeleteSafe(devPath); DeleteSafe(appPath); } catch (Exception ex) { Debug.WriteLine(ex.ToString()); } finally { // Remove the app pool and commit changes iis.ApplicationPools.Remove(iis.ApplicationPools[appPoolName]); iis.CommitChanges(); // Clear out the app pool user profile directory if it exists string userDir = Path.GetDirectoryName(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile).TrimEnd(Path.DirectorySeparatorChar)); string appPoolDirectory = Path.Combine(userDir, appPoolName); DeleteSafe(appPoolDirectory); } }
public void DeleteSite(string applicationName) { var iis = new IIS.ServerManager(); // Get the app pool for this application string appPoolName = GetAppPool(applicationName); IIS.ApplicationPool kuduPool = iis.ApplicationPools[appPoolName]; // Make sure the acls are gone RemoveAcls(applicationName, appPoolName); if (kuduPool == null) { // If there's no app pool then do nothing return; } DeleteSite(iis, GetLiveSite(applicationName)); DeleteSite(iis, GetDevSite(applicationName)); // Don't delete the physical files for the service site DeleteSite(iis, GetServiceSite(applicationName), deletePhysicalFiles: false); iis.CommitChanges(); string appPath = _pathResolver.GetApplicationPath(applicationName); var sitePath = _pathResolver.GetLiveSitePath(applicationName); var devPath = _pathResolver.GetDeveloperApplicationPath(applicationName); try { kuduPool.StopAndWait(); DeleteSafe(sitePath); DeleteSafe(devPath); DeleteSafe(appPath); } catch (Exception ex) { Debug.WriteLine(ex.ToString()); } finally { // Remove the app pool and commit changes iis.ApplicationPools.Remove(iis.ApplicationPools[appPoolName]); iis.CommitChanges(); } }