Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modify VM size on a .csdef. #687

Merged
merged 1 commit into from
Mar 10, 2015
Merged
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
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