public AutomationTestBase()
        {
            var handler = new RecordedDelegatingHandler();
            AutomationClient = ResourceGroupHelper.GetAutomationClient(handler);

            ResourceManagementClient resourcesClient = ResourceGroupHelper.GetResourcesClient(handler);

            try
            {
                resourcesClient.ResourceGroups.CreateOrUpdate(resourceGroup,
                new ResourceGroup
                {
                    Location = location
                });

                AutomationClient.AutomationAccounts.CreateOrUpdate(resourceGroup, new AutomationAccountCreateOrUpdateParameters
                {
                    Name = automationAccount,
                    Location = location,
                    Properties = new AutomationAccountCreateOrUpdateProperties()
                    {
                        Sku = new Sku() { Name = "Free", Family = "Test", Capacity = 1 }
                    }
                });
            }
            catch (CloudException ex)
            {
                if (ex.Response.StatusCode != HttpStatusCode.Conflict) throw;
            }
            

            // Clean up the automation account, delete runbooks, schedules, variables, etc.
            this.CleanUpCredentials();
            this.CleanUpRunbooks();
            this.CleanUpSchedules();
            this.CleanUpVariables();
            this.CleanUpWebhooks();
        }
 public static ResourceManagementClient GetResourcesClient(RecordedDelegatingHandler handler)
 {
     return TestBase.GetServiceClient<ResourceManagementClient>(new CSMTestEnvironmentFactory()).WithHandler(handler);
 }
 public static AutomationManagementClient GetAutomationClient(RecordedDelegatingHandler handler)
 {
     return TestBase.GetServiceClient<AutomationManagementClient>(new CSMTestEnvironmentFactory());
 }