Skip to content

Commit

Permalink
Allow null priority to allow updating non-spot VM instances
Browse files Browse the repository at this point in the history
  • Loading branch information
TheRSP committed Sep 2, 2022
1 parent aa4dafe commit 11590e1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
14 changes: 9 additions & 5 deletions src/Farmer/Arm/Compute.fs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ type VirtualMachine =
DiagnosticsEnabled: bool option
StorageAccount: ResourceName option
Size: VMSize
Priority: Priority
Priority: Priority option
Credentials: {| Username: string
Password: SecureParameter |}
CustomData: string option
Expand Down Expand Up @@ -137,7 +137,10 @@ type VirtualMachine =

let properties =
{|
priority = this.Priority.ArmValue
priority =
match this.Priority with
| Some priority -> priority.ArmValue
| _ -> Unchecked.defaultof<_>
hardwareProfile = {| vmSize = this.Size.ArmValue |}
osProfile =
{|
Expand Down Expand Up @@ -260,9 +263,10 @@ type VirtualMachine =
this.Identity.ToArmJson
properties =
match this.Priority with
| Low
| Regular -> box properties
| Spot (evictionPolicy, maxPrice) ->
| None
| Some Low
| Some Regular -> box properties
| Some (Spot (evictionPolicy, maxPrice)) ->
{| properties with
evictionPolicy = evictionPolicy.ArmValue
billingProfile = {| maxPrice = maxPrice |}
Expand Down
2 changes: 1 addition & 1 deletion src/Farmer/Builders/Builders.Vm.fs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ type VmConfig =
StorageAccount = this.DiagnosticsStorageAccount |> Option.map (fun r -> r.resourceId(this).Name)
NetworkInterfaceName = this.NicName.Name
Size = this.Size
Priority = this.Priority |> Option.defaultValue Regular
Priority = this.Priority
Credentials =
match this.Username with
| Some username ->
Expand Down

0 comments on commit 11590e1

Please sign in to comment.