Skip to content

Commit

Permalink
Merge pull request #687 from isaacabraham/master
Browse files Browse the repository at this point in the history
Modify VM size on a .csdef.
  • Loading branch information
forki committed Mar 10, 2015
2 parents a820dea + 33975cd commit bc1e919
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
29 changes: 27 additions & 2 deletions src/app/FakeLib/AzureCloudServices.fs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,32 @@ type PackageCloudServiceParams =
OutputPath : string option }

let DefaultCloudServiceParams = { CloudService = ""; WorkerRole = ""; SdkVersion = None; OutputPath = None }


module VmSizes =
type VmSize = | VmSize of size:string
let ExtraSmall = VmSize "ExtraSmall"
let Small = VmSize "Small"
let Medium = VmSize "Medium"
let Large = VmSize "Large"
let ExtraLarge = VmSize "ExtraLarge"
let A5 = VmSize "A5"
let A6 = VmSize "A6"
let A7 = VmSize "A7"
let A8 = VmSize "A8"
let A9 = VmSize "A9"

/// Modifies the size of the Worker Role in the csdef.
let ModifyVMSize (VmSizes.VmSize vmSize) cloudService =
let csdefPath = sprintf @"%s\ServiceDefinition.csdef" cloudService
csdefPath
|> File.ReadAllText
|> XMLHelper.XMLDoc
|> XMLHelper.XPathReplaceNS
"/svchost:ServiceDefinition/svchost:WorkerRole/@vmsize"
vmSize
[ "svchost", "http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition" ]
|> fun doc -> doc.Save csdefPath

/// Packages a cloud service role into a .cspkg, ready for deployment.
let PackageRole packageCloudServiceParams =
let csPack =
Expand All @@ -27,7 +52,7 @@ let PackageRole packageCloudServiceParams =
let availableCsPacks =
sdkRoots
|> Seq.collect(fun sdkRoot ->
!! (sdkRoot + "**\cspack.exe")
!! (sdkRoot + @"**\cspack.exe")
|> Seq.filter(fun path -> path.Substring(sdkRoot.Length).StartsWith "v")
|> Seq.map(fun path -> sdkRoot, path))
|> Seq.map(fun (sdkRoot, cspackPath) ->
Expand Down
2 changes: 1 addition & 1 deletion src/app/FakeLib/FakeLib.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@
<Compile Include="XDTHelper.fs" />
<Compile Include="AzureWebJobs.fs" />
<Compile Include="HockeyAppHelper.fs" />
<None Include="app.config" />
<Compile Include="AzureCloudServices.fs" />
<None Include="app.config" />
</ItemGroup>
<ItemGroup>
<Reference Include="ICSharpCode.SharpZipLib">
Expand Down

0 comments on commit bc1e919

Please sign in to comment.