From 11590e167bd0672228855104b2a375a25d535729 Mon Sep 17 00:00:00 2001 From: Richard Sanderson-Pope Date: Fri, 2 Sep 2022 12:21:15 +0100 Subject: [PATCH] Allow null priority to allow updating non-spot VM instances --- src/Farmer/Arm/Compute.fs | 14 +++++++++----- src/Farmer/Builders/Builders.Vm.fs | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/Farmer/Arm/Compute.fs b/src/Farmer/Arm/Compute.fs index b1df5fedc..fd14299c6 100644 --- a/src/Farmer/Arm/Compute.fs +++ b/src/Farmer/Arm/Compute.fs @@ -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 @@ -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 = {| @@ -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 |} diff --git a/src/Farmer/Builders/Builders.Vm.fs b/src/Farmer/Builders/Builders.Vm.fs index 7c0a3da3b..0a6a7525d 100644 --- a/src/Farmer/Builders/Builders.Vm.fs +++ b/src/Farmer/Builders/Builders.Vm.fs @@ -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 ->