From c5f9d16d67ceb21b62f60115e9a05c947569c306 Mon Sep 17 00:00:00 2001 From: Roger Doherty Date: Thu, 23 Jul 2020 22:21:24 -0400 Subject: [PATCH] v1.4.1 checkin --- terraform-azurerm-bench-windows/10-common.tf | 2 +- terraform-azurerm-bench-windows/20-compute.tf | 39 ++++++++-------- terraform-azurerm-bench-windows/README.md | 37 +++++++++------- .../gen-tfvarsfile.sh | 4 +- .../run-gen-tfvarsfile.sh | 2 +- .../virtual-machine-03-post-deploy.ps1 | 44 +++++++++++++++++++ terraform-azurerm-vm-linux/10-common.tf | 2 +- terraform-azurerm-vm-windows/10-common.tf | 2 +- terraform-azurerm-vnet-hub/10-common.tf | 2 +- terraform-azurerm-vnet-spoke/10-common.tf | 2 +- terraform-azurerm-vwan/10-common.tf | 2 +- 11 files changed, 94 insertions(+), 44 deletions(-) diff --git a/terraform-azurerm-bench-windows/10-common.tf b/terraform-azurerm-bench-windows/10-common.tf index 9a2b9a0..f6044e4 100644 --- a/terraform-azurerm-bench-windows/10-common.tf +++ b/terraform-azurerm-bench-windows/10-common.tf @@ -1,5 +1,5 @@ provider "azurerm" { - version = "~> 2.19" + version = "~> 2.20" features {} # subscription_id = "REPLACE-WITH-YOUR-SUBSCRIPTION-ID" # client_id = "REPLACE-WITH-YOUR-CLIENT-ID" diff --git a/terraform-azurerm-bench-windows/20-compute.tf b/terraform-azurerm-bench-windows/20-compute.tf index dbf777d..3f11df5 100644 --- a/terraform-azurerm-bench-windows/20-compute.tf +++ b/terraform-azurerm-bench-windows/20-compute.tf @@ -20,7 +20,7 @@ data "azurerm_key_vault_secret" "storage_account_key" { key_vault_id = var.key_vault_id } -# Windows Server virtual machine with SQL Server +# Database server virtual machine resource "azurerm_windows_virtual_machine" "virtual_machine_03" { name = var.vm_db_name @@ -53,22 +53,6 @@ output "virtual_machine_03_name" { value = azurerm_windows_virtual_machine.virtual_machine_03.name } -resource "azurerm_mssql_virtual_machine" "virtual_machine_03_sql" { - virtual_machine_id = azurerm_windows_virtual_machine.virtual_machine_03.id - sql_license_type = "PAYG" - r_services_enabled = true - sql_connectivity_port = 1433 - sql_connectivity_type = "PRIVATE" - sql_connectivity_update_username = data.azurerm_key_vault_secret.adminuser.value - sql_connectivity_update_password = data.azurerm_key_vault_secret.adminpassword.value - - auto_patching { - day_of_week = "Sunday" - maintenance_window_duration_in_minutes = 60 - maintenance_window_starting_hour = 2 - } -} - # Nics resource "azurerm_network_interface" "virtual_machine_03_nic_01" { @@ -186,7 +170,26 @@ resource "azurerm_virtual_machine_extension" "virtual_machine_03_postdeploy_scri PROTECTED_SETTINGS } -# Windows Server virtual machine with IIS +# Register with Microsoft.SqlVirtualMachine resource provider + +resource "azurerm_mssql_virtual_machine" "virtual_machine_03_sql" { + virtual_machine_id = azurerm_windows_virtual_machine.virtual_machine_03.id + sql_license_type = "PAYG" + r_services_enabled = true + sql_connectivity_port = 1433 + sql_connectivity_type = "PRIVATE" + sql_connectivity_update_username = data.azurerm_key_vault_secret.adminuser.value + sql_connectivity_update_password = data.azurerm_key_vault_secret.adminpassword.value + depends_on = [ azurerm_virtual_machine_extension.virtual_machine_03_postdeploy_script ] + + auto_patching { + day_of_week = "Sunday" + maintenance_window_duration_in_minutes = 60 + maintenance_window_starting_hour = 2 + } +} + +# Web server virtual machine resource "azurerm_windows_virtual_machine" "virtual_machine_04" { name = var.vm_web_name diff --git a/terraform-azurerm-bench-windows/README.md b/terraform-azurerm-bench-windows/README.md index 4dbc33a..b25b449 100644 --- a/terraform-azurerm-bench-windows/README.md +++ b/terraform-azurerm-bench-windows/README.md @@ -2,9 +2,10 @@ ## Overview -This quick start implements a dedicated Windows Server / SQL Server database server virtual machine and a dedicated Windows Server web server virtual machine connected to the dedicated spoke virtual network for use as a pre-configured environment for running benchmarks like [HammerDB](https://www.hammerdb.com/) and testing web applications. The following quick starts must be deployed first before starting: +This quick start implements a collection of services for testing Windows based web applications and running database benchmarks like [HammerDB](https://www.hammerdb.com/) using an [IaaS](https://azure.microsoft.com/en-us/overview/what-is-azure/iaas/) approach. The following quick starts must be deployed first before starting: * [terraform-azurerm-vnet-hub](../terraform-azurerm-vnet-hub) +* [terraform-azurerm-vm-windows](../terraofrm-azurerm-vm-windows) * [terraform-azurerm-vnet-spoke](../terraform-azurerm-vnet-spoke) Activity | Estimated time required @@ -59,13 +60,13 @@ This section provides an index of the ~7 resources included in this quick start. --- -Dedicated Windows Server / SQL Server database server [virtual machine](https://docs.microsoft.com/en-us/azure/azure-glossary-cloud-terminology#vm) connected to the dedicated spoke virtual network with a configurable number of data disks, pre-configured administrator credentials using key vault, and pre-configured virtual machine extensions. +Database Server [virtual machine](https://docs.microsoft.com/en-us/azure/azure-glossary-cloud-terminology#vm) based on the [SQL Server on Azure Virtual Machine \(Windows\)](https://docs.microsoft.com/en-us/azure/azure-sql/virtual-machines/windows/sql-server-on-azure-vm-iaas-what-is-overview) offering which is connected to the dedicated spoke virtual network, supports a configurable number of data disks, pre-configured administrator credentials using key vault and pre-configured virtual machine extensions. Variable | In/Out | Type | Scope | Sample --- | --- | --- | --- | --- vm_db_name | Input | string | Local | winbenchdb01 -vm_db_size | Input | string | Local | Standard_B2ms -vm_db_storage_replication_type | Input | string | Local | Standard_LRS +vm_db_size | Input | string | Local | Standard_B4ms +vm_db_storage_replication_type | Input | string | Local | StandardSSD_LRS vm_db_image_publisher | Input | string | Local | MicrosoftSQLServer vm_db_image_offer | Input | string | Local | sql2019-ws2019 vm_db_image_sku | Input | string | Local | sqldev @@ -74,16 +75,6 @@ tags | Input | string | Local | { costcenter = \"MyCostCenter\", division = \"My virtual_machine_03_id | Output | string | Local | /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg-vdc-nonprod-001/providers/Microsoft.Compute/virtualMachines/winbenchdb01 virtual_machine_03_name | Output | string | Local | winbenchdb01 -#### SQL Server virtual machine configuration - -The default instance of SQL Server is pre-configured using the following settings: - -* *sa* username and password credentials set using key vault -* sql_license_type = "PAYG" -* r_services_enabled = true -* sql_connectivity_port = 1433 -* sql_connectivity_type = "PRIVATE" - #### Database server network interface Dedicated [network interface](https://docs.microsoft.com/en-us/azure/virtual-network/virtual-network-network-interface) (NIC) with a dynamic private ip address attached to the virtual machine. @@ -104,6 +95,16 @@ vm_data_disk_count | Input | string | Local | 2 vm_storage_replication_type | Input | string | Local | Standard_LRS vm_data_disk_size_gb | Input | string | Local | 32 (Gb) +#### SQL Server virtual machine resource provider configuration + +The database virtual machine is registered with the [Microsoft.SqlVirtualMachine](https://docs.microsoft.com/en-us/azure/azure-sql/virtual-machines/windows/sql-vm-resource-provider-register) resource provider using the following defaults: + +* *sa* username and password credentials set using key vault +* sql_license_type = "PAYG" +* r_services_enabled = true +* sql_connectivity_port = 1433 +* sql_connectivity_type = "PRIVATE" + #### Database server virtual machine extensions Pre-configured [virtual machine extensions](https://docs.microsoft.com/en-us/azure/virtual-machines/extensions/overview) attached to the virtual machine including: @@ -111,6 +112,7 @@ Pre-configured [virtual machine extensions](https://docs.microsoft.com/en-us/azu * [Log Analytics virtual machine extension](https://docs.microsoft.com/en-us/azure/azure-monitor/platform/agent-windows) also known as the *Microsoft Monitoring Agent* (MMA) version 1.0 with automatic minor version upgrades enabled and automatically connected to the shared log analytics workspace. * [Dependency virtual machine extension](https://docs.microsoft.com/en-us/azure/virtual-machines/extensions/agent-dependency-windows) version 9.0 with automatic minor version upgrades enabled and automatically connected to the shared log analytics workspace. * [Custom script extension](https://docs.microsoft.com/en-us/azure/virtual-machines/extensions/custom-script-windows) version 1.10 with automatic minor version upgrades enabled and configured to run a post-deployment script which partitions and formats new data disks. +* [SQL Server IaaS agent extension](https://docs.microsoft.com/en-us/azure/azure-sql/virtual-machines/windows/sql-server-iaas-agent-extension-automate-management) is automatically installed when the virtual machine is registered with the SQL Server virtual machine resource provider. Variable | In/Out | Type | Scope | Sample --- | --- | --- | --- | --- @@ -123,7 +125,7 @@ vm_db_post_deploy_script_uri | Input | string | Local | *stxxxxxxxxxxxxxxxx001* > *file service* > *file shares* > *fs-xxxxxxxxxxxxxxxx-001* > *Connect* > *Windows* * Copy the PowerShell script in the right-hand pane for use in the next smoke testing exercise. -* Connect to the dedicated virtual machine in the Azure portal using bastion and log in with the *adminuser* and *adminpassword* defined previously. +* Connect to the database server virtual machine in the Azure portal using bastion and log in with the *adminuser* and *adminpassword* defined previously. * Confirm access to shared file share private endpoint. * Run Windows PowerShell ISE, create a new script, and paste in the script generated previously. * Copy the fqdn for the file endpoint from line 4, for example *stxxxxxxxxxxxxxxxx001.file.core.windows.net* @@ -180,7 +183,7 @@ storage_account_name | Input | String | Local | st8e644ec51c5be098001 * Execute the PowerShell script copied from the Azure Portal to establish a drive mapping to the shared file share using the private endpoint. * Create some directories and sample files on the drive mapped to the shared file share to test functionality. * Review the log file created during execution of the post-deployment script in C:/Packages/Plugins/Microsoft.Compute.CustomScriptExtension/1.10.X/Downloads/0. - * Launch SQL Server Management Studio and create a test database. Place the data file and the log file on different data disks. + * Launch SQL Server Management Studio and create a test database. ## Next steps diff --git a/terraform-azurerm-bench-windows/gen-tfvarsfile.sh b/terraform-azurerm-bench-windows/gen-tfvarsfile.sh index b25bb88..f7acbec 100755 --- a/terraform-azurerm-bench-windows/gen-tfvarsfile.sh +++ b/terraform-azurerm-bench-windows/gen-tfvarsfile.sh @@ -6,7 +6,7 @@ VM_ADMIN_USERNAME_SECRET="adminuser" VM_DB_IMAGE_OFFER="sql2019-ws2019" VM_DB_IMAGE_PUBLISHER="MicrosoftSQLServer" VM_DB_POST_DEPLOY_SCRIPT_NAME="virtual-machine-03-post-deploy.ps1" -VM_DB_STORAGE_REPLICATION_TYPE="Standard_LRS" +VM_DB_STORAGE_REPLICATION_TYPE="StandardSSD_LRS" VM_WEB_IMAGE_OFFER="WindowsServer" VM_WEB_IMAGE_PUBLISHER="MicrosoftWindowsServer" VM_WEB_POST_DEPLOY_SCRIPT_NAME="virtual-machine-04-post-deploy.ps1" @@ -27,7 +27,7 @@ BLOB_STORAGE_ENDPOINT="" BLOB_STORAGE_CONTAINER_NAME="" KEY_VAULT_ID="" KEY_VAULT_NAME="" -LOCATION="" +LOCATION="" LOG_ANALYTICS_WORKSPACE_ID="" RESOURCE_GROUP_NAME="" STORAGE_ACCOUNT_KEY="" diff --git a/terraform-azurerm-bench-windows/run-gen-tfvarsfile.sh b/terraform-azurerm-bench-windows/run-gen-tfvarsfile.sh index 9066bd3..830c8ce 100755 --- a/terraform-azurerm-bench-windows/run-gen-tfvarsfile.sh +++ b/terraform-azurerm-bench-windows/run-gen-tfvarsfile.sh @@ -13,7 +13,7 @@ ./gen-tfvarsfile.sh \ -n "winbench" \ -s "sqldev" \ - -z "Standard_B2ms" \ + -z "Standard_B4ms" \ -c "2" \ -d "32" \ -S "2019-Datacenter-smalldisk" \ diff --git a/terraform-azurerm-bench-windows/virtual-machine-03-post-deploy.ps1 b/terraform-azurerm-bench-windows/virtual-machine-03-post-deploy.ps1 index 36fc0c9..b4704f8 100644 --- a/terraform-azurerm-bench-windows/virtual-machine-03-post-deploy.ps1 +++ b/terraform-azurerm-bench-windows/virtual-machine-03-post-deploy.ps1 @@ -52,4 +52,48 @@ foreach ($disk in $disks) $count++ } +# Install PowerShell prerequisites for using the SQL Server IaaS agent extension + +Write-Log "Install NuGet provider..." + +try +{ + Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force +} +catch +{ + $ErrorMessage = $_ + Write-Log "There was an exception during the process, please review" + Write-Log "$ErrorMessage" + Exit 2 +} + +Write-Log "Set PSGallery as a trusted repository..." + +try +{ + Set-PSRepository -Name PSGallery -InstallationPolicy Trusted +} +catch +{ + $ErrorMessage = $_ + Write-Log "There was an exception during the process, please review" + Write-Log "$ErrorMessage" + Exit 2 +} + +Write-Log "Installing Azure PowerShell module..." + +try +{ + Install-Module -Name Az -AllowClobber -Scope AllUsers +} +catch +{ + $ErrorMessage = $_ + Write-Log "There was an exception during the process, please review" + Write-Log "$ErrorMessage" + Exit 2 +} + Write-Log "Exiting normally..." diff --git a/terraform-azurerm-vm-linux/10-common.tf b/terraform-azurerm-vm-linux/10-common.tf index 9a2b9a0..f6044e4 100644 --- a/terraform-azurerm-vm-linux/10-common.tf +++ b/terraform-azurerm-vm-linux/10-common.tf @@ -1,5 +1,5 @@ provider "azurerm" { - version = "~> 2.19" + version = "~> 2.20" features {} # subscription_id = "REPLACE-WITH-YOUR-SUBSCRIPTION-ID" # client_id = "REPLACE-WITH-YOUR-CLIENT-ID" diff --git a/terraform-azurerm-vm-windows/10-common.tf b/terraform-azurerm-vm-windows/10-common.tf index 9a2b9a0..f6044e4 100644 --- a/terraform-azurerm-vm-windows/10-common.tf +++ b/terraform-azurerm-vm-windows/10-common.tf @@ -1,5 +1,5 @@ provider "azurerm" { - version = "~> 2.19" + version = "~> 2.20" features {} # subscription_id = "REPLACE-WITH-YOUR-SUBSCRIPTION-ID" # client_id = "REPLACE-WITH-YOUR-CLIENT-ID" diff --git a/terraform-azurerm-vnet-hub/10-common.tf b/terraform-azurerm-vnet-hub/10-common.tf index 1d34a9b..a288175 100644 --- a/terraform-azurerm-vnet-hub/10-common.tf +++ b/terraform-azurerm-vnet-hub/10-common.tf @@ -1,5 +1,5 @@ provider "azurerm" { - version = "~> 2.19" + version = "~> 2.20" features {} # subscription_id = "REPLACE-WITH-YOUR-SUBSCRIPTION-ID" # client_id = "REPLACE-WITH-YOUR-CLIENT-ID" diff --git a/terraform-azurerm-vnet-spoke/10-common.tf b/terraform-azurerm-vnet-spoke/10-common.tf index ffee561..e9b0192 100644 --- a/terraform-azurerm-vnet-spoke/10-common.tf +++ b/terraform-azurerm-vnet-spoke/10-common.tf @@ -1,5 +1,5 @@ provider "azurerm" { - version = "~> 2.19" + version = "~> 2.20" features {} # subscription_id = "REPLACE-WITH-YOUR-SUBSCRIPTION-ID" # client_id = "REPLACE-WITH-YOUR-CLIENT-ID" diff --git a/terraform-azurerm-vwan/10-common.tf b/terraform-azurerm-vwan/10-common.tf index ffee561..e9b0192 100755 --- a/terraform-azurerm-vwan/10-common.tf +++ b/terraform-azurerm-vwan/10-common.tf @@ -1,5 +1,5 @@ provider "azurerm" { - version = "~> 2.19" + version = "~> 2.20" features {} # subscription_id = "REPLACE-WITH-YOUR-SUBSCRIPTION-ID" # client_id = "REPLACE-WITH-YOUR-CLIENT-ID"