Skip to content
This repository has been archived by the owner on Jan 20, 2023. It is now read-only.

Commit

Permalink
v1.4.1 checkin
Browse files Browse the repository at this point in the history
  • Loading branch information
doherty100 committed Jul 24, 2020
1 parent 7b25fe1 commit c5f9d16
Show file tree
Hide file tree
Showing 11 changed files with 94 additions and 44 deletions.
2 changes: 1 addition & 1 deletion terraform-azurerm-bench-windows/10-common.tf
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
39 changes: 21 additions & 18 deletions terraform-azurerm-bench-windows/20-compute.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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" {
Expand Down Expand Up @@ -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
Expand Down
37 changes: 20 additions & 17 deletions terraform-azurerm-bench-windows/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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.
Expand All @@ -104,13 +95,24 @@ 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:

* [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
--- | --- | --- | --- | ---
Expand All @@ -123,7 +125,7 @@ vm_db_post_deploy_script_uri | Input | string | Local | <https://st8e644ec51c5be

---

Dedicated Windows Server web server [virtual machine](https://docs.microsoft.com/en-us/azure/azure-glossary-cloud-terminology#vm) connected to the dedicated spoke virtual network with pre-configured administrator credentials using key vault, and pre-configured virtual machine extensions.
Web server [virtual machine](https://docs.microsoft.com/en-us/azure/azure-glossary-cloud-terminology#vm) based on the [Windows virtual machines in Azure](https://docs.microsoft.com/en-us/azure/virtual-machines/windows/) offering which is connected to the dedicated spoke virtual network with pre-configured administrator credentials using key vault, and pre-configured virtual machine extensions.

Variable | In/Out | Type | Scope | Sample
--- | --- | --- | --- | ---
Expand Down Expand Up @@ -167,11 +169,12 @@ storage_account_name | Input | String | Local | st8e644ec51c5be098001

* Explore newly provisioned resources using the Azure portal.
* Review the 4 secrets that were created in the shared key vault.
* Review the database server virtual machine configuration using both the *Virtual machine* UI and the *SQL virtual machine* UI.
* Generate a script for mapping drives to the shared file share.
* Mapping a drive to an Azure Files file share requires automation due to the use of a complex shared key to authenticate.
* In the Azure Portal navigate to *storage accounts* > *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*
Expand All @@ -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

Expand Down
4 changes: 2 additions & 2 deletions terraform-azurerm-bench-windows/gen-tfvarsfile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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=""
Expand Down
2 changes: 1 addition & 1 deletion terraform-azurerm-bench-windows/run-gen-tfvarsfile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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" \
Expand Down
44 changes: 44 additions & 0 deletions terraform-azurerm-bench-windows/virtual-machine-03-post-deploy.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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..."
2 changes: 1 addition & 1 deletion terraform-azurerm-vm-linux/10-common.tf
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
2 changes: 1 addition & 1 deletion terraform-azurerm-vm-windows/10-common.tf
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
2 changes: 1 addition & 1 deletion terraform-azurerm-vnet-hub/10-common.tf
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
2 changes: 1 addition & 1 deletion terraform-azurerm-vnet-spoke/10-common.tf
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
2 changes: 1 addition & 1 deletion terraform-azurerm-vwan/10-common.tf
Original file line number Diff line number Diff line change
@@ -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"
Expand Down

0 comments on commit c5f9d16

Please sign in to comment.