static void Main(string[] args) { Scenario scenario = null; try { scenario = ScenarioFactory.GetScenario(Scenarios.CreateSingleVmExample); scenario.Execute(); } finally { foreach (var rgId in Scenario.CleanUp) { ResourceIdentifier id = new ResourceIdentifier(rgId); var rg = new AzureResourceManagerClient().GetSubscriptionOperations(id.Subscription).GetResourceGroupOperations(id.ResourceGroup); Console.WriteLine($"--------Deleting {rg.Id.Name}--------"); try { _ = rg.DeleteAsync(); } catch { //ignore exceptions in case the rg doesn't exist } } } }
public override void Execute() { var list = Enum.GetValues(typeof(Scenarios)).Cast <Scenarios>().ToList(); try { foreach (var scenario in list) { if (scenario != Scenarios.All) { Console.WriteLine($"########## Starting Scenario {scenario} ##########"); var executable = ScenarioFactory.GetScenario(scenario); executable.Execute(); Console.WriteLine($"########## Finished Scenario {scenario} ##########"); } } } finally { foreach (var rgId in CleanUp) { ResourceIdentifier id = new ResourceIdentifier(rgId); var rg = new AzureResourceManagerClient().ResourceGroup(rgId); Console.WriteLine($"--------Deleting {rg.Id.Name}--------"); try { _ = rg.DeleteAsync(); } catch { //ignore exceptions in case rg doesn't exist } } } }