From dfc8cdcc93d143e1a30a5a2d64ab54d2ea0c2ba5 Mon Sep 17 00:00:00 2001 From: Marcus Robinson Date: Wed, 18 Dec 2024 16:43:12 +0000 Subject: [PATCH 1/4] Enable scheduled shutdown of Guacamole Windows VMs Fixes #4205 Add support for scheduled shutdown of Guacamole Windows VMs. * Add `enable_shutdown_schedule`, `shutdown_time`, and `shutdown_timezone` properties to `template_schema.json`. * Add `enable_shutdown_schedule`, `shutdown_time`, and `shutdown_timezone` parameters to `porter.yaml`. * Add `azurerm_dev_test_global_vm_shutdown_schedule` resource to `windowsvm.tf`. * Add `enable_shutdown_schedule`, `shutdown_time`, and `shutdown_timezone` variables to `variables.tf`. * Update bundle version in `porter.yaml`. --- For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/microsoft/AzureTRE/issues/4205?shareId=XXXX-XXXX-XXXX-XXXX). --- .../guacamole-azure-windowsvm/porter.yaml | 24 ++++++- .../template_schema.json | 71 ++++++++++++++++++- .../terraform/variables.tf | 11 +++ .../terraform/windowsvm.tf | 13 ++++ 4 files changed, 117 insertions(+), 2 deletions(-) diff --git a/templates/workspace_services/guacamole/user_resources/guacamole-azure-windowsvm/porter.yaml b/templates/workspace_services/guacamole/user_resources/guacamole-azure-windowsvm/porter.yaml index 7a1c1d1cf4..3f814c394f 100644 --- a/templates/workspace_services/guacamole/user_resources/guacamole-azure-windowsvm/porter.yaml +++ b/templates/workspace_services/guacamole/user_resources/guacamole-azure-windowsvm/porter.yaml @@ -1,7 +1,7 @@ --- schemaVersion: 1.0.0 name: tre-service-guacamole-windowsvm -version: 1.0.7 +version: 1.0.8 description: "An Azure TRE User Resource Template for Guacamole (Windows 10)" dockerfile: Dockerfile.tmpl registry: azuretre @@ -100,6 +100,19 @@ parameters: default: "vm-shared-storage" - name: arm_environment type: string + - name: enable_shutdown_schedule + type: boolean + default: false + description: "Enable automatic shutdown schedule for the VM" + - name: shutdown_time + default: "" + type: string + description: "Time of day to shutdown the VM (HHmm format)" + pattern: "^([01]?[0-9]|2[0-3])[0-5][0-9]$" + - name: shutdown_timezone + type: string + description: "Timezone for the shutdown schedule" + default: "UTC" outputs: - name: ip @@ -145,6 +158,9 @@ install: shared_storage_access: ${ bundle.parameters.shared_storage_access } shared_storage_name: ${ bundle.parameters.shared_storage_name } image_gallery_id: ${ bundle.parameters.image_gallery_id } + enable_shutdown_schedule: ${ bundle.parameters.enable_shutdown_schedule } + shutdown_time: ${ bundle.parameters.shutdown_time } + shutdown_timezone: ${ bundle.parameters.shutdown_timezone } backendConfig: use_azuread_auth: "true" use_oidc: "true" @@ -171,6 +187,9 @@ upgrade: shared_storage_access: ${ bundle.parameters.shared_storage_access } shared_storage_name: ${ bundle.parameters.shared_storage_name } image_gallery_id: ${ bundle.parameters.image_gallery_id } + enable_shutdown_schedule: ${ bundle.parameters.enable_shutdown_schedule } + shutdown_time: ${ bundle.parameters.shutdown_time } + shutdown_timezone: ${ bundle.parameters.shutdown_timezone } backendConfig: use_azuread_auth: "true" use_oidc: "true" @@ -209,6 +228,9 @@ uninstall: shared_storage_access: ${ bundle.parameters.shared_storage_access } shared_storage_name: ${ bundle.parameters.shared_storage_name } image_gallery_id: ${ bundle.parameters.image_gallery_id } + enable_shutdown_schedule: ${ bundle.parameters.enable_shutdown_schedule } + shutdown_time: ${ bundle.parameters.shutdown_time } + shutdown_timezone: ${ bundle.parameters.shutdown_timezone } backendConfig: use_azuread_auth: "true" use_oidc: "true" diff --git a/templates/workspace_services/guacamole/user_resources/guacamole-azure-windowsvm/template_schema.json b/templates/workspace_services/guacamole/user_resources/guacamole-azure-windowsvm/template_schema.json index 74518f33ee..0b48697ea3 100644 --- a/templates/workspace_services/guacamole/user_resources/guacamole-azure-windowsvm/template_schema.json +++ b/templates/workspace_services/guacamole/user_resources/guacamole-azure-windowsvm/template_schema.json @@ -40,6 +40,75 @@ "title": "Shared storage", "default": true, "description": "Enable access to shared storage" + }, + "enable_shutdown_schedule": { + "$id": "#/properties/enable_shutdown_schedule", + "type": "boolean", + "title": "Enable Shutdown Schedule", + "default": false, + "description": "Enable automatic shutdown schedule for the VM" + } + }, + "allOf": [ + { + "if": { + "properties": { + "enable_shutdown_schedule": { + "const": true + } + }, + "required": [ + "enable_shutdown_schedule" + ] + }, + "then": { + "properties": { + "shutdown_time": { + "type": "string", + "title": "Shutdown Time", + "description": "Time of day to shutdown the VM (HHmm format), e.g. 1800", + "pattern": "^([01]?[0-9]|2[0-3])[0-5][0-9]$", + "default": "1800" + }, + "shutdown_timezone": { + "type": "string", + "title": "Shutdown Timezone", + "description": "Timezone for the shutdown schedule", + "default": "UTC", + "enum": [ + "UTC -12", + "UTC -11", + "UTC -10", + "UTC -9", + "UTC -8", + "UTC -7", + "UTC -6", + "UTC -5", + "UTC -4", + "UTC -3", + "UTC -2", + "UTC -1", + "UTC", + "UTC +1", + "UTC +2", + "UTC +3", + "UTC +4", + "UTC +5", + "UTC +6", + "UTC +7", + "UTC +8", + "UTC +9", + "UTC +10", + "UTC +11", + "UTC +12" + ] + } + }, + "required": [ + "shutdown_time", + "shutdown_timezone" + ] + } } - } + ] } diff --git a/templates/workspace_services/guacamole/user_resources/guacamole-azure-windowsvm/terraform/variables.tf b/templates/workspace_services/guacamole/user_resources/guacamole-azure-windowsvm/terraform/variables.tf index 4908ae52a2..a515e46e30 100644 --- a/templates/workspace_services/guacamole/user_resources/guacamole-azure-windowsvm/terraform/variables.tf +++ b/templates/workspace_services/guacamole/user_resources/guacamole-azure-windowsvm/terraform/variables.tf @@ -26,3 +26,14 @@ variable "image_gallery_id" { type = string default = "" } +variable "enable_shutdown_schedule" { + type = bool + default = false +} +variable "shutdown_time" { + type = string +} +variable "shutdown_timezone" { + type = string + default = "UTC" +} diff --git a/templates/workspace_services/guacamole/user_resources/guacamole-azure-windowsvm/terraform/windowsvm.tf b/templates/workspace_services/guacamole/user_resources/guacamole-azure-windowsvm/terraform/windowsvm.tf index 575f8a7efd..e2df693bc2 100644 --- a/templates/workspace_services/guacamole/user_resources/guacamole-azure-windowsvm/terraform/windowsvm.tf +++ b/templates/workspace_services/guacamole/user_resources/guacamole-azure-windowsvm/terraform/windowsvm.tf @@ -110,3 +110,16 @@ resource "azurerm_key_vault_secret" "windowsvm_password" { lifecycle { ignore_changes = [tags] } } + +resource "azurerm_dev_test_global_vm_shutdown_schedule" "shutdown_schedule" { + count = var.enable_shutdown_schedule ? 1 : 0 + + location = data.azurerm_resource_group.ws.location + virtual_machine_id = azurerm_windows_virtual_machine.windowsvm.id + daily_recurrence_time = var.shutdown_time + timezone = var.shutdown_timezone + enabled = var.enable_shutdown_schedule + notification_settings { + enabled = false + } +} From 23e8a347294bb87f4d99c23d057576eee1662a5d Mon Sep 17 00:00:00 2001 From: Marcus Robinson Date: Mon, 17 Feb 2025 13:47:25 +0000 Subject: [PATCH 2/4] Update changelog --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c596b48c02..b3ae66a5b9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,7 +14,8 @@ ENHANCEMENTS: * Add bundle target to Makefile for handling different bundle types in single command ([#4372](https://github.com/microsoft/AzureTRE/issues/4372)) * Migrate UI to Vite build engine and update dependencies ([#4368](https://github.com/microsoft/AzureTRE/pull/4368)) * Add Windows image field to the Admin VM template ([#4274](https://github.com/microsoft/AzureTRE/pull/4274)) -* Update TLS to the latest version for web apps / function apps (([#4351](https://github.com/microsoft/AzureTRE/issues/4351)) +* Update TLS to the latest version for web apps / function apps ([#4351](https://github.com/microsoft/AzureTRE/issues/4351)) +* Add shutdown schedule to Windows VMs ([#4211](https://github.com/microsoft/AzureTRE/pull/4211/)) BUG FIXES: * Fix upgrade when porter install has failed ([#4338](https://github.com/microsoft/AzureTRE/pull/4338)) From c2429bb1e190ab25f84c5cc66cda7b1adeaba58b Mon Sep 17 00:00:00 2001 From: Marcus Robinson Date: Tue, 1 Apr 2025 14:17:13 +0100 Subject: [PATCH 3/4] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 679b671d7d..8439926a14 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ ENHANCEMENTS: * Enabled Structured Azure Firewall logs for TRE firewall. [#4430](https://github.com/microsoft/AzureTRE/issues/4430) * Deny public access to TRE management storage account, and add private endpoint for TRE core [#4353](https://github.com/microsoft/AzureTRE/issues/4353) * Added anonymous access enablement for Nexus by default issue. [#4387](https://github.com/microsoft/AzureTRE/pull/4387) -* Add shutdown schedule to Windows VMs ([#4211](https://github.com/microsoft/AzureTRE/pull/4211/)) +* Add shutdown schedule to Windows VMs ([#4211](https://github.com/microsoft/AzureTRE/pull/4211)) BUG FIXES: * Fix the management storage access error while executing `make show-core-output` command, and remove redundant error messages from `mgmtstorage_enable_public_access.sh` script ([#4404](https://github.com/microsoft/AzureTRE/issues/4404)) From 86cec145bbe657ad88a8e3c6a63919c93bd49618 Mon Sep 17 00:00:00 2001 From: Marcus Robinson Date: Wed, 30 Apr 2025 09:25:16 +0000 Subject: [PATCH 4/4] Fix time zones --- CHANGELOG.md | 2 +- .../guacamole-azure-linuxvm/porter.yaml | 2 +- .../template_schema.json | 138 ++++++++++++++---- .../template_schema.json | 131 +++++++++++++---- 4 files changed, 218 insertions(+), 55 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 663245b443..6f28d4fc21 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ ENHANCEMENTS: * Add ability to pass values to install stage on pipleine [#4451](https://github.com/microsoft/AzureTRE/pull/4451) * Format the error message in the Operations panel for enhanced readability ([#4493](https://github.com/microsoft/AzureTRE/issues/4493)) * Added ability to assign VMs to other users at creation time ([#1179](https://github.com/microsoft/AzureTRE/issues/1179)) +* Add shutdown schedule to Windows VMs ([#4211](https://github.com/microsoft/AzureTRE/pull/4211)) BUG FIXES: * Letsencrypt.yml fails with "Invalid reference in variable validation" ([#4506](https://github.com/microsoft/AzureTRE/4506)) @@ -19,7 +20,6 @@ ENHANCEMENTS: * Enabled Structured Azure Firewall logs for TRE firewall. [#4430](https://github.com/microsoft/AzureTRE/issues/4430) * Deny public access to TRE management storage account, and add private endpoint for TRE core [#4353](https://github.com/microsoft/AzureTRE/issues/4353) * Added anonymous access enablement for Nexus by default issue. [#4387](https://github.com/microsoft/AzureTRE/pull/4387) -* Add shutdown schedule to Windows VMs ([#4211](https://github.com/microsoft/AzureTRE/pull/4211)) * Update mysql commands in control_tre script. [#4438](https://github.com/microsoft/AzureTRE/pull/4438) * Organize how we pass config.yaml settings to bundles. [#4436](https://github.com/microsoft/AzureTRE/pull/4436) * Add documentation for make commands ([[#4296](https://github.com/microsoft/AzureTRE/issues/4296)]) diff --git a/templates/workspace_services/guacamole/user_resources/guacamole-azure-linuxvm/porter.yaml b/templates/workspace_services/guacamole/user_resources/guacamole-azure-linuxvm/porter.yaml index 3b61bacb92..cc26f793f0 100644 --- a/templates/workspace_services/guacamole/user_resources/guacamole-azure-linuxvm/porter.yaml +++ b/templates/workspace_services/guacamole/user_resources/guacamole-azure-linuxvm/porter.yaml @@ -1,7 +1,7 @@ --- schemaVersion: 1.0.0 name: tre-service-guacamole-linuxvm -version: 1.3.1 +version: 1.3.2 description: "An Azure TRE User Resource Template for Guacamole (Linux)" dockerfile: Dockerfile.tmpl registry: azuretre diff --git a/templates/workspace_services/guacamole/user_resources/guacamole-azure-linuxvm/template_schema.json b/templates/workspace_services/guacamole/user_resources/guacamole-azure-linuxvm/template_schema.json index 4103883af8..c2c2ffc668 100644 --- a/templates/workspace_services/guacamole/user_resources/guacamole-azure-linuxvm/template_schema.json +++ b/templates/workspace_services/guacamole/user_resources/guacamole-azure-linuxvm/template_schema.json @@ -9,7 +9,8 @@ "vm_size" ], "authorizedRoles": [ - "WorkspaceOwner", "WorkspaceResearcher" + "WorkspaceOwner", + "WorkspaceResearcher" ], "properties": { "display_name": { @@ -70,13 +71,13 @@ "default": false, "description": "Enable automatic shutdown schedule for the VM" }, - "assign_to_another_user": { + "assign_to_another_user": { "type": "boolean", "title": "Assign this VM to another user", "description": "Check this box if you want to assign this VM to another user.", "default": false, "updateable": false - } + } }, "allOf": [ { @@ -105,31 +106,112 @@ "description": "Timezone for the shutdown schedule", "default": "UTC", "enum": [ - "UTC -12", - "UTC -11", - "UTC -10", - "UTC -9", - "UTC -8", - "UTC -7", - "UTC -6", - "UTC -5", - "UTC -4", - "UTC -3", - "UTC -2", - "UTC -1", + "Afghanistan Standard Time", + "Alaskan Standard Time", + "Arab Standard Time", + "Arabian Standard Time", + "Arabic Standard Time", + "Argentina Standard Time", + "Atlantic Standard Time", + "AUS Central Standard Time", + "AUS Eastern Standard Time", + "Azerbaijan Standard Time", + "Azores Standard Time", + "Bahia Standard Time", + "Bangladesh Standard Time", + "Belarus Standard Time", + "Canada Central Standard Time", + "Cape Verde Standard Time", + "Caucasus Standard Time", + "Cen. Australia Standard Time", + "Central America Standard Time", + "Central Asia Standard Time", + "Central Brazilian Standard Time", + "Central Europe Standard Time", + "Central European Standard Time", + "Central Pacific Standard Time", + "Central Standard Time (Mexico)", + "Central Standard Time", + "China Standard Time", + "Dateline Standard Time", + "E. Africa Standard Time", + "E. Australia Standard Time", + "E. Europe Standard Time", + "E. South America Standard Time", + "Eastern Standard Time (Mexico)", + "Eastern Standard Time", + "Egypt Standard Time", + "Ekaterinburg Standard Time", + "Fiji Standard Time", + "FLE Standard Time", + "Georgian Standard Time", + "GMT Standard Time", + "Greenland Standard Time", + "Greenwich Standard Time", + "GTB Standard Time", + "Hawaiian Standard Time", + "India Standard Time", + "Iran Standard Time", + "Israel Standard Time", + "Jordan Standard Time", + "Kaliningrad Standard Time", + "Korea Standard Time", + "Libya Standard Time", + "Line Islands Standard Time", + "Magadan Standard Time", + "Mauritius Standard Time", + "Middle East Standard Time", + "Montevideo Standard Time", + "Morocco Standard Time", + "Mountain Standard Time (Mexico)", + "Mountain Standard Time", + "Myanmar Standard Time", + "N. Central Asia Standard Time", + "Namibia Standard Time", + "Nepal Standard Time", + "New Zealand Standard Time", + "Newfoundland Standard Time", + "North Asia East Standard Time", + "North Asia Standard Time", + "Pacific SA Standard Time", + "Pacific Standard Time (Mexico)", + "Pacific Standard Time", + "Pakistan Standard Time", + "Paraguay Standard Time", + "Romance Standard Time", + "Russia Time Zone 10", + "Russia Time Zone 11", + "Russia Time Zone 3", + "Russian Standard Time", + "SA Eastern Standard Time", + "SA Pacific Standard Time", + "SA Western Standard Time", + "Samoa Standard Time", + "SE Asia Standard Time", + "Singapore Standard Time", + "South Africa Standard Time", + "Sri Lanka Standard Time", + "Syria Standard Time", + "Taipei Standard Time", + "Tasmania Standard Time", + "Tokyo Standard Time", + "Tonga Standard Time", + "Turkey Standard Time", + "Ulaanbaatar Standard Time", + "US Eastern Standard Time", + "US Mountain Standard Time", "UTC", - "UTC +1", - "UTC +2", - "UTC +3", - "UTC +4", - "UTC +5", - "UTC +6", - "UTC +7", - "UTC +8", - "UTC +9", - "UTC +10", - "UTC +11", - "UTC +12" + "UTC+12", + "UTC-02", + "UTC-11", + "Venezuela Standard Time", + "Vladivostok Standard Time", + "W. Australia Standard Time", + "W. Central Africa Standard Time", + "W. Europe Standard Time", + "West Asia Standard Time", + "West Pacific Standard Time", + "Yakutsk Standard Time" ] } }, @@ -171,4 +253,4 @@ "classNames": "tre-hidden" } } -} +} \ No newline at end of file diff --git a/templates/workspace_services/guacamole/user_resources/guacamole-azure-windowsvm/template_schema.json b/templates/workspace_services/guacamole/user_resources/guacamole-azure-windowsvm/template_schema.json index e671c11be7..74ca293ae5 100644 --- a/templates/workspace_services/guacamole/user_resources/guacamole-azure-windowsvm/template_schema.json +++ b/templates/workspace_services/guacamole/user_resources/guacamole-azure-windowsvm/template_schema.json @@ -40,7 +40,7 @@ "type": "string", "title": "Admin username", "description": "Overide automatic admin username generation.", - "default": "" + "default": "," }, "vm_size": { "$id": "#/properties/vm_size", @@ -105,31 +105,112 @@ "description": "Timezone for the shutdown schedule", "default": "UTC", "enum": [ - "UTC -12", - "UTC -11", - "UTC -10", - "UTC -9", - "UTC -8", - "UTC -7", - "UTC -6", - "UTC -5", - "UTC -4", - "UTC -3", - "UTC -2", - "UTC -1", + "Afghanistan Standard Time", + "Alaskan Standard Time", + "Arab Standard Time", + "Arabian Standard Time", + "Arabic Standard Time", + "Argentina Standard Time", + "Atlantic Standard Time", + "AUS Central Standard Time", + "AUS Eastern Standard Time", + "Azerbaijan Standard Time", + "Azores Standard Time", + "Bahia Standard Time", + "Bangladesh Standard Time", + "Belarus Standard Time", + "Canada Central Standard Time", + "Cape Verde Standard Time", + "Caucasus Standard Time", + "Cen. Australia Standard Time", + "Central America Standard Time", + "Central Asia Standard Time", + "Central Brazilian Standard Time", + "Central Europe Standard Time", + "Central European Standard Time", + "Central Pacific Standard Time", + "Central Standard Time (Mexico)", + "Central Standard Time", + "China Standard Time", + "Dateline Standard Time", + "E. Africa Standard Time", + "E. Australia Standard Time", + "E. Europe Standard Time", + "E. South America Standard Time", + "Eastern Standard Time (Mexico)", + "Eastern Standard Time", + "Egypt Standard Time", + "Ekaterinburg Standard Time", + "Fiji Standard Time", + "FLE Standard Time", + "Georgian Standard Time", + "GMT Standard Time", + "Greenland Standard Time", + "Greenwich Standard Time", + "GTB Standard Time", + "Hawaiian Standard Time", + "India Standard Time", + "Iran Standard Time", + "Israel Standard Time", + "Jordan Standard Time", + "Kaliningrad Standard Time", + "Korea Standard Time", + "Libya Standard Time", + "Line Islands Standard Time", + "Magadan Standard Time", + "Mauritius Standard Time", + "Middle East Standard Time", + "Montevideo Standard Time", + "Morocco Standard Time", + "Mountain Standard Time (Mexico)", + "Mountain Standard Time", + "Myanmar Standard Time", + "N. Central Asia Standard Time", + "Namibia Standard Time", + "Nepal Standard Time", + "New Zealand Standard Time", + "Newfoundland Standard Time", + "North Asia East Standard Time", + "North Asia Standard Time", + "Pacific SA Standard Time", + "Pacific Standard Time (Mexico)", + "Pacific Standard Time", + "Pakistan Standard Time", + "Paraguay Standard Time", + "Romance Standard Time", + "Russia Time Zone 10", + "Russia Time Zone 11", + "Russia Time Zone 3", + "Russian Standard Time", + "SA Eastern Standard Time", + "SA Pacific Standard Time", + "SA Western Standard Time", + "Samoa Standard Time", + "SE Asia Standard Time", + "Singapore Standard Time", + "South Africa Standard Time", + "Sri Lanka Standard Time", + "Syria Standard Time", + "Taipei Standard Time", + "Tasmania Standard Time", + "Tokyo Standard Time", + "Tonga Standard Time", + "Turkey Standard Time", + "Ulaanbaatar Standard Time", + "US Eastern Standard Time", + "US Mountain Standard Time", "UTC", - "UTC +1", - "UTC +2", - "UTC +3", - "UTC +4", - "UTC +5", - "UTC +6", - "UTC +7", - "UTC +8", - "UTC +9", - "UTC +10", - "UTC +11", - "UTC +12" + "UTC+12", + "UTC-02", + "UTC-11", + "Venezuela Standard Time", + "Vladivostok Standard Time", + "W. Australia Standard Time", + "W. Central Africa Standard Time", + "W. Europe Standard Time", + "West Asia Standard Time", + "West Pacific Standard Time", + "Yakutsk Standard Time" ] } },