Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions src/MBrace.Azure.Management/Compute.fs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,20 @@ open MBrace.Runtime.Utils.PrettyPrinters
open MBrace.Azure
open MBrace.Azure.Runtime

type ServiceName = string
type InstanceCount = int
type UseDiagnostics = bool

[<RequireQualifiedAccess>]
type CloudServiceConfigurationMaker =
/// Use default Cloud Service configuration (.cscfg) that comes with MBrace.Azure.Management
| Default
/// Give a custom functor taking: service name (a string), instance count (an integer), use diagnostics (a boolean)
/// , StorageAccount instance and ServiceBusAccount instance to return a string containing the final xml matching
/// desired custom .cscfg file.
/// <remarks>One can look at implementation of MBrace.Azure.Management.Compute.buildMBraceConfig to see example of correct implementation.</remarks>
| Custom of (ServiceName -> InstanceCount -> UseDiagnostics -> StorageAccount -> ServiceBusAccount -> string)

module internal Compute =
open Microsoft.WindowsAzure.Storage.Blob
open System.Net
Expand Down Expand Up @@ -264,9 +278,15 @@ module internal Compute =
let createDeployment (logger : ISystemLogger) (serviceName : string) (clusterLabel : string)
(region : Region) packageDetails (useStaging : bool) (enableDiagnostics : bool) (instanceCount : int)
(storageAccount : StorageAccount) (serviceBusAccount : ServiceBusAccount)
(client:SubscriptionClient) = async {
(client:SubscriptionClient) (cloudServiceConfiguration: CloudServiceConfigurationMaker)
= async {
let! destinationPackageUri = deployPackage packageDetails storageAccount logger
let config = buildMBraceConfig serviceName instanceCount enableDiagnostics storageAccount serviceBusAccount
let config =
let buildConfig =
match cloudServiceConfiguration with
| CloudServiceConfigurationMaker.Default -> buildMBraceConfig
| CloudServiceConfigurationMaker.Custom buildConfigFunction -> buildConfigFunction
buildConfig serviceName instanceCount enableDiagnostics storageAccount serviceBusAccount
logger.Logf LogLevel.Info "creating cloud service %A" serviceName
let! _ = client.Compute.HostedServices.CreateAsync(HostedServiceCreateParameters(Location = region.Id, ServiceName = serviceName)) |> Async.AwaitTaskCorrect
let deployParams =
Expand Down
20 changes: 15 additions & 5 deletions src/MBrace.Azure.Management/Management.fs
Original file line number Diff line number Diff line change
Expand Up @@ -382,9 +382,12 @@ type SubscriptionManager private (client : SubscriptionClient, defaultRegion : R
/// <param name="clusterLabel">User-supplied service label. Defaults to library generated label.</param>
/// <param name="enableDiagnostics">Enable Azure diagnostics for deployment using storage account. Defaults to false.</param>
/// <param name="reuseAccounts">Reuse existing inactive mbrace storage/service bus accounts. Defaults to true.</param>
/// <param name="cloudServiceConfiguration">Member of CloudServiceConfigurationMaker which enables generating a custom Cloud Service configuration for the cluster. Defaults to CloudServiceConfigurationMaker.Default.</param>
member __.ProvisionAsync(vmCount : int, [<O;D(null:obj)>]?serviceName : string, [<O;D(null:obj)>]?region : Region, [<O;D(null:obj)>]?vmSize : VMSize,
[<O;D(null:obj)>]?mbraceVersion : string, [<O;D(null:obj)>]?storageAccount : string, [<O;D(null:obj)>]?serviceBusAccount : string, [<O;D(null:obj)>]?cloudServicePackage : string,
[<O;D(null:obj)>]?clusterLabel : string, [<O;D(null:obj)>]?enableDiagnostics : bool, [<O;D(null:obj)>]?reuseAccounts : bool) : Async<Deployment> = async {
[<O;D(null:obj)>]?clusterLabel : string, [<O;D(null:obj)>]?enableDiagnostics : bool, [<O;D(null:obj)>]?reuseAccounts : bool,
[<O;D(null:obj)>]?cloudServiceConfiguration : CloudServiceConfigurationMaker
) : Async<Deployment> = async {

if vmCount < 1 then invalidArg "vmCount" "must be positive value."
let enableDiagnostics = defaultArg enableDiagnostics false
Expand Down Expand Up @@ -417,8 +420,11 @@ type SubscriptionManager private (client : SubscriptionClient, defaultRegion : R
else Compute.CustomRemote uri), "custom-cspkg"

let clusterLabel = defaultArg clusterLabel customClusterLabel

do! Compute.createDeployment logger serviceName clusterLabel region packageDetails false enableDiagnostics vmCount storageAccount serviceBusAccount client
let cloudServiceConfiguration =
match cloudServiceConfiguration with
| Some cloudServiceConfiguration -> cloudServiceConfiguration
| None -> CloudServiceConfigurationMaker.Default
do! Compute.createDeployment logger serviceName clusterLabel region packageDetails false enableDiagnostics vmCount storageAccount serviceBusAccount client cloudServiceConfiguration
return new Deployment(client, serviceName, logger)
}

Expand All @@ -436,12 +442,16 @@ type SubscriptionManager private (client : SubscriptionClient, defaultRegion : R
/// <param name="clusterLabel">User-supplied service label. Defaults to library generated label.</param>
/// <param name="enableDiagnostics">Enable Azure diagnostics for deployment using storage account. Defaults to false.</param>
/// <param name="reuseAccounts">Reuse existing inactive mbrace storage/service bus accounts. Defaults to true.</param>
/// <param name="cloudServiceConfiguration">Member of CloudServiceConfigurationMaker which enables generating a custom Cloud Service configuration for the cluster. Defaults to CloudServiceConfigurationMaker.Default.</param>
member __.Provision(vmCount : int, [<O;D(null:obj)>]?serviceName : string, [<O;D(null:obj)>]?region : Region, [<O;D(null:obj)>]?vmSize : VMSize,
[<O;D(null:obj)>]?mbraceVersion : string, [<O;D(null:obj)>]?storageAccount : string, [<O;D(null:obj)>]?serviceBusAccount : string, [<O;D(null:obj)>]?cloudServicePackage : string,
[<O;D(null:obj)>]?clusterLabel : string, [<O;D(null:obj)>]?enableDiagnostics : bool, [<O;D(null:obj)>]?reuseAccounts : bool) =
[<O;D(null:obj)>]?clusterLabel : string, [<O;D(null:obj)>]?enableDiagnostics : bool, [<O;D(null:obj)>]?reuseAccounts : bool,
[<O;D(null:obj)>]?cloudServiceConfiguration : CloudServiceConfigurationMaker
) =
__.ProvisionAsync(vmCount, ?serviceName = serviceName, ?region = region, ?mbraceVersion = mbraceVersion, ?vmSize = vmSize,
?storageAccount = storageAccount, ?serviceBusAccount = serviceBusAccount, ?cloudServicePackage = cloudServicePackage,
?clusterLabel = clusterLabel, ?enableDiagnostics = enableDiagnostics, ?reuseAccounts = reuseAccounts)
?clusterLabel = clusterLabel, ?enableDiagnostics = enableDiagnostics, ?reuseAccounts = reuseAccounts,
?cloudServiceConfiguration = cloudServiceConfiguration)
|> Async.RunSync


Expand Down