Repository navigation
Expand file tree
/
Copy pathAzureCluster.fsx
More file actions
79 lines (64 loc) · 3.15 KB
/
Copy pathAzureCluster.fsx
File metadata and controls
79 lines (64 loc) · 3.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#I __SOURCE_DIRECTORY__
#I "../packages/MBrace.Azure/tools"
#I "../packages/Streams/lib/net45"
#r "../packages/Streams/lib/net45/Streams.dll"
#I "../packages/MBrace.Flow/lib/net45"
#r "../packages/MBrace.Flow/lib/net45/MBrace.Flow.dll"
#load "../packages/MBrace.Azure/MBrace.Azure.fsx"
#load "../packages/MBrace.Azure.Management/MBrace.Azure.Management.fsx"
namespace global
module Config =
open System.IO
open MBrace.Core
open MBrace.Runtime
open MBrace.Azure
open MBrace.Azure.Management
// This script is used to reconnect to your cluster.
// You can download your publication settings file at
// https://manage.windowsazure.com/publishsettings
let pubSettingsFile = @"C:\path\to\your.publishsettings"
// If your publication settings defines more than one subscription,
// you will need to specify which one you will be using here.
let subscriptionId : string option = None
// Your prefered Azure service name for the cluster.
// NB: must be a valid DNS prefix unique across Azure.
let clusterName = "enter a valid and unique cloud service name"
// Your prefered Azure region. Assign this to a data center close to your location.
let region = Region.North_Europe
// Your prefered VM size
let vmSize = VMSize.Large
// Your prefered cluster count
let vmCount = 4
// set to true if you would like to provision
// the custom cloud service bundled with the StarterKit
// In order to use this feature, you will need to open
// the `CustomCloudService` solution under the `azure` folder
// inside the MBrace.StarterKit repo.
// Right click on the cloud service item and hit "Package.."
let useCustomCloudService = false
let private tryGetCustomCsPkg () =
if useCustomCloudService then
let path = __SOURCE_DIRECTORY__ + "/../azure/CustomCloudService/bin/app.publish/MBrace.Azure.CloudService.cspkg" |> Path.GetFullPath
if not <| File.Exists path then failwith "Find the 'MBrace.Azure.CloudService' project under 'azure\CustomCloudService' and hit 'Package...'."
Some path
else
None
let GetSubscriptionManager() =
SubscriptionManager.FromPublishSettingsFile(pubSettingsFile, region, ?subscriptionId = subscriptionId, logger = new ConsoleLogger())
/// Gets the already existing deployment
let GetDeployment() = GetSubscriptionManager().GetDeployment(clusterName)
/// Provisions a new cluster to Azure with supplied parameters
let ProvisionCluster() =
GetSubscriptionManager().Provision(vmCount, serviceName = clusterName, vmSize = vmSize, ?cloudServicePackage = tryGetCustomCsPkg())
/// Resizes the cluster using an updated VM count
let ResizeCluster(newVmCount : int) =
let deployment = GetDeployment()
deployment.Resize(newVmCount)
/// Deletes an existing cluster deployment
let DeleteCluster() =
let deployment = GetDeployment()
deployment.Delete()
/// Connect to the cluster
let GetCluster() =
let deployment = GetDeployment()
AzureCluster.Connect(deployment, logger = ConsoleLogger(true), logLevel = LogLevel.Info)