From 6d0dfe5653bf0e71597670895b4a87100abcc487 Mon Sep 17 00:00:00 2001 From: Eugene Tolmachev Date: Mon, 6 Jan 2025 18:16:33 -0500 Subject: [PATCH] VM extensions autoupgrade --- RELEASE_NOTES.md | 3 +++ .../api-overview/resources/vm-scale-set.md | 3 +++ src/Farmer/Arm/Compute.fs | 5 ++++- src/Farmer/Builders/Builders.Vm.fs | 2 +- src/Farmer/Builders/Builders.VmScaleSet.fs | 18 ++++++++++++++++++ 5 files changed, 29 insertions(+), 2 deletions(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 687cdd7d7..84e9261fc 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,6 +1,9 @@ Release Notes ============= +## 1.9.11 +* VM extensions: support for auto-upgrades and initial version + ## 1.9.10 * Application Gateways: Adds SSL Certificates * Network Security Groups: use ARM expressions in security rules diff --git a/docs/content/api-overview/resources/vm-scale-set.md b/docs/content/api-overview/resources/vm-scale-set.md index f9c3a46c6..eeb078796 100644 --- a/docs/content/api-overview/resources/vm-scale-set.md +++ b/docs/content/api-overview/resources/vm-scale-set.md @@ -35,6 +35,9 @@ The Virtual Machine Scale Set builder (`vmss`) creates a virtual machine scale s | applicationHealthExtension | port | TCP port to probe. | | applicationHealthExtension | interval | Interval to probe for health. | | applicationHealthExtension | number_of_probes | Sets the number of times the probe must fail to consider this instance a failure. | +| applicationHealthExtension | enable_automatic_upgrade | Enable/Disable automatic extension upgrade (not enabled by default) | +| applicationHealthExtension | type_handler_version | Extension version (default: "1.0") | + #### Example diff --git a/src/Farmer/Arm/Compute.fs b/src/Farmer/Arm/Compute.fs index 5e2d13e10..aeb552f5c 100644 --- a/src/Farmer/Arm/Compute.fs +++ b/src/Farmer/Arm/Compute.fs @@ -124,6 +124,8 @@ type ApplicationHealthExtension = { NumberOfProbes: int option GracePeriod: TimeSpan option Tags: Map + EnableAutomaticUpgrade: bool option + TypeHandlerVersion: string option } with static member Name = "HealthExtension" @@ -138,8 +140,9 @@ type ApplicationHealthExtension = { match this.OS with | Linux -> "ApplicationHealthLinux" | Windows -> "ApplicationHealthWindows" - typeHandlerVersion = "1.0" + typeHandlerVersion = this.TypeHandlerVersion |> Option.defaultValue "1.0" autoUpgradeMinorVersion = true + enableAutomaticUpgrade = this.EnableAutomaticUpgrade |> Option.map box |> Option.defaultValue null settings = {| protocol = this.Protocol.ArmValue port = this.Port diff --git a/src/Farmer/Builders/Builders.Vm.fs b/src/Farmer/Builders/Builders.Vm.fs index b7f41f70d..624158fb9 100644 --- a/src/Farmer/Builders/Builders.Vm.fs +++ b/src/Farmer/Builders/Builders.Vm.fs @@ -1051,7 +1051,7 @@ type VmGalleryApplicationBuilder() = galleryApp [] - member _.EnableAutomaticUpgrade(state, enable) = { + member _.EnableAutomaticUpgrade(state: VmGalleryApplication, enable) = { state with EnableAutomaticUpgrade = Some enable } diff --git a/src/Farmer/Builders/Builders.VmScaleSet.fs b/src/Farmer/Builders/Builders.VmScaleSet.fs index 6b633d865..32af4f65b 100644 --- a/src/Farmer/Builders/Builders.VmScaleSet.fs +++ b/src/Farmer/Builders/Builders.VmScaleSet.fs @@ -24,6 +24,8 @@ type ApplicationHealthExtensionConfig = { NumberOfProbes: int option GracePeriod: TimeSpan option Tags: Map + TypeHandlerVersion: string option + EnableAutomaticUpgrade: bool option } with interface IExtensionBuilder with @@ -37,6 +39,8 @@ type ApplicationHealthExtensionConfig = { NumberOfProbes = this.NumberOfProbes GracePeriod = this.GracePeriod Tags = this.Tags + TypeHandlerVersion = this.TypeHandlerVersion + EnableAutomaticUpgrade = this.EnableAutomaticUpgrade } interface IBuilder with @@ -279,6 +283,20 @@ type ApplicationHealthExtensionBuilder() = NumberOfProbes = None GracePeriod = None Tags = Map.empty + TypeHandlerVersion = None + EnableAutomaticUpgrade = None + } + + [] + member _.EnableAutomaticUpgrade(state: ApplicationHealthExtensionConfig, enable) = { + state with + EnableAutomaticUpgrade = Some enable + } + + [] + member _.TypeHandlerVersion(state: ApplicationHealthExtensionConfig, version) = { + state with + TypeHandlerVersion = Some version } /// Sets the VMSS where this health extension should be installed.