Example #1
0
        /// <summary>
        /// Provisions all the web sites in the <see cref="IEnumerable{T}"/> of <see cref="AzureWebSite"/>.
        /// </summary>
        /// <param name="sites">The list of <see cref="AzureWebSite"/> to provision.</param>
        /// <param name="client">The <see cref="WebSiteManagementClient"/> that is performing the operation.</param>
        /// <returns>The async <see cref="Task"/> wrapper.</returns>
        public static IEnumerable <Task> ProvisionAllAsync(this IEnumerable <AzureWebSite> sites, WebSiteManagementClient client)
        {
            Contract.Requires(sites != null);
            Contract.Requires(client != null);

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

            var tasks = sites.Select(
                async s =>
            {
                await client.CreateWebSiteIfNotExistsAsync(s);
            });

            await Task.WhenAll(tasks);
        }