示例#1
0
        /// <summary>
        /// Checks for the existence of a specific Cloud Service, if it doesn't exist it will create it.
        /// </summary>
        /// <param name="client">The <see cref="ComputeManagementClient"/> that is performing the operation.</param>
        /// <param name="model">The DevOpsFlex rich model object that contains everything there is to know about this cloud service spec.</param>
        /// <returns>The async <see cref="Task"/> wrapper.</returns>
        public static async Task CreateServiceIfNotExistsAsync(this ComputeManagementClient client, AzureCloudService model)
        {
            Contract.Requires(client != null);
            Contract.Requires(model != null);

            await client.CreateServiceIfNotExistsAsync(model.AzureParameters);
        }
示例#2
0
        /// <summary>
        /// Provisions all the services in the <see cref="IEnumerable{T}"/> of <see cref="AzureCloudService"/>.
        /// </summary>
        /// <param name="services">The list of <see cref="AzureCloudService"/> to provision.</param>
        /// <param name="client">The <see cref="ComputeManagementClient"/> that is performing the operation.</param>
        /// <returns>The async <see cref="Task"/> wrapper.</returns>
        public static IEnumerable <Task> ProvisionAllAsync(this IEnumerable <AzureCloudService> services, ComputeManagementClient client)
        {
            Contract.Requires(services != null);
            Contract.Requires(client != null);

            return(services.Select(s =>
                                   Task.Factory.StartNew(() => client.CreateServiceIfNotExistsAsync(s).Wait())));
        }
        /// <summary>
        /// Provisions all the services in the <see cref="IEnumerable{T}"/> of <see cref="AzureCloudService"/>.
        /// </summary>
        /// <param name="services">The list of <see cref="AzureCloudService"/> to provision.</param>
        /// <param name="client">The <see cref="ComputeManagementClient"/> that is performing the operation.</param>
        /// <returns>The async <see cref="Task"/> wrapper.</returns>
        public static async Task ProvisionAllAsync(this IEnumerable <AzureCloudService> services, ComputeManagementClient client)
        {
            Contract.Requires(services != null);
            Contract.Requires(client != null);

            var tasks = services.Select(
                async s =>
            {
                await client.CreateServiceIfNotExistsAsync(s);
            });

            await Task.WhenAll(tasks);
        }