/// <summary> /// Provisions all the namespaces in the <see cref="IEnumerable{T}"/> of <see cref="AzureServiceBusNamespace"/>. /// </summary> /// <param name="namespaces">The list of <see cref="AzureServiceBusNamespace"/> to provision.</param> /// <param name="client">The <see cref="ServiceBusManagementClient"/> that is performing the operation.</param> /// <returns>The async <see cref="Task"/> wrapper.</returns> public static IEnumerable <Task> ProvisionAllAsync(this IEnumerable <AzureServiceBusNamespace> namespaces, ServiceBusManagementClient client) { Contract.Requires(namespaces != null); Contract.Requires(client != null); return(namespaces.Select(n => Task.Factory.StartNew(() => client.CreateNamespaceIfNotExistsAsync(n).Wait()))); }
/// <summary> /// Provisions all the namespaces in the <see cref="IEnumerable{T}"/> of <see cref="AzureServiceBusNamespace"/>. /// </summary> /// <param name="namespaces">The list of <see cref="AzureServiceBusNamespace"/> to provision.</param> /// <param name="client">The <see cref="ServiceBusManagementClient"/> that is performing the operation.</param> /// <returns>The async <see cref="Task"/> wrapper.</returns> public static async Task ProvisionAllAsync(this IEnumerable <AzureServiceBusNamespace> namespaces, ServiceBusManagementClient client) { Contract.Requires(namespaces != null); Contract.Requires(client != null); var tasks = namespaces.Select( async n => { await client.CreateNamespaceIfNotExistsAsync(n); }); await Task.WhenAll(tasks); }
/// <summary> /// Checks for the existence of a specific Azure Web Site, if it doesn't exist it will create it. /// </summary> /// <param name="client">The <see cref="ServiceBusManagementClient"/> that is performing the operation.</param> /// <param name="model">The DevOpsFlex rich model object that contains everything there is to know about this service bus spec.</param> /// <returns>The async <see cref="Task"/> wrapper.</returns> public static async Task CreateNamespaceIfNotExistsAsync(this ServiceBusManagementClient client, AzureServiceBusNamespace model) { Contract.Requires(client != null); Contract.Requires(model != null); await client.CreateNamespaceIfNotExistsAsync( FlexDataConfiguration.GetNaming <AzureServiceBusNamespace>() .GetSlotName( model, FlexDataConfiguration.Branch, FlexDataConfiguration.Configuration), model.Region.GetEnumDescription()); }