/// <summary>
        ///     Create stirage service
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public StorageAccount CreateStorageService(StorageAccountCreateParameters input)
        {
            if (input == null)
            {
                throw new ArgumentNullException("input");
            }
            // storage services must use lowercase names
            input.Name = input.Name.ToLowerInvariant(); 

            var existing = GetStorageService(input.Name);
            if(existing != null)
            {
                return existing;
            }

            var affinityGroupManager = new AzureAffinityGroupManager();
            affinityGroupManager.EnsureAffinityGroupExists(input.AffinityGroup);

            TestEasyLog.Instance.Info(string.Format("Creating storage service '{0}'", input.Name));

            StorageManagementClient.StorageAccounts.CreateAsync(input, new CancellationToken()).Wait();

            existing = GetStorageService(input.Name);

            if (string.Compare(existing.Name, AzureServiceConstants.DefaultStorageServiceName,
                   StringComparison.InvariantCultureIgnoreCase) != 0) // never remember default storage service to avoid deletion
            {
                Dependencies.TestResourcesCollector.Remember(AzureResourceType.StorageService, existing.Name, existing.Name);
            }

            return existing;
        }
        /// <summary>
        ///     Create stirage service
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public StorageAccount CreateStorageService(StorageAccountCreateParameters input)
        {
            if (input == null)
            {
                throw new ArgumentNullException("input");
            }
            // storage services must use lowercase names
            input.Name = input.Name.ToLowerInvariant();

            var existing = GetStorageService(input.Name);

            if (existing != null)
            {
                return(existing);
            }

            var affinityGroupManager = new AzureAffinityGroupManager();

            affinityGroupManager.EnsureAffinityGroupExists(input.AffinityGroup);

            TestEasyLog.Instance.Info(string.Format("Creating storage service '{0}'", input.Name));

            StorageManagementClient.StorageAccounts.CreateAsync(input, new CancellationToken()).Wait();

            existing = GetStorageService(input.Name);

            if (string.Compare(existing.Name, AzureServiceConstants.DefaultStorageServiceName,
                               StringComparison.InvariantCultureIgnoreCase) != 0) // never remember default storage service to avoid deletion
            {
                Dependencies.TestResourcesCollector.Remember(AzureResourceType.StorageService, existing.Name, existing.Name);
            }

            return(existing);
        }
        /// <summary>
        ///     Create hosted service
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public string CreateHostedService(HostedServiceCreateParameters input)
        {
            if (input == null)
            {
                throw new ArgumentNullException("input");
            }

            if (HostedServiceExists(input.ServiceName)) return input.ServiceName;

            var affinityGroupManager = new AzureAffinityGroupManager();
            affinityGroupManager.EnsureAffinityGroupExists(input.AffinityGroup);

            ComputeManagementClient.HostedServices.CreateAsync(input, new CancellationToken()).Wait();

            Dependencies.TestResourcesCollector.Remember(AzureResourceType.HostedService, input.ServiceName, input.ServiceName);

            return input.ServiceName;
        }
예제 #4
0
        /// <summary>
        ///     Create hosted service
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public string CreateHostedService(HostedServiceCreateParameters input)
        {
            if (input == null)
            {
                throw new ArgumentNullException("input");
            }

            if (HostedServiceExists(input.ServiceName))
            {
                return(input.ServiceName);
            }

            var affinityGroupManager = new AzureAffinityGroupManager();

            affinityGroupManager.EnsureAffinityGroupExists(input.AffinityGroup);

            ComputeManagementClient.HostedServices.CreateAsync(input, new CancellationToken()).Wait();

            Dependencies.TestResourcesCollector.Remember(AzureResourceType.HostedService, input.ServiceName, input.ServiceName);

            return(input.ServiceName);
        }