Skip to content

Commit be9fb6f

Browse files
authored
Merge pull request microsoft#76 from jensheerin/AVD
Add 101-azure-virtual-desktop
2 parents 48a25a1 + a69ec0b commit be9fb6f

File tree

27 files changed

+1610
-0
lines changed

27 files changed

+1610
-0
lines changed

.gitignore

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
log/
2+
obj/
3+
_site/
4+
.optemp/
5+
_themes*/
6+
_repo.*/
7+
.vs/
8+
.vscode/
9+
.idea
10+
.ionide/
11+
.openpublishing.buildcore.ps1.vscode/
12+
*.DS_Store
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
## Terraform for Azure Virtual Desktop
2+
3+
The purpose of this repository is to demonstrate using Terraform to deploy a simple Azure Virtual Desktop environment. For Classic Azure Virtual Desktop click [here](https://github.com/Azure/RDS-Templates/tree/master/wvd-sh/terraform-azurerm-windowsvirtualdesktop).
4+
5+
## Requirements and limitations
6+
7+
* Ensure that you meet the [requirements for Azure Virtual Desktop](https://docs.microsoft.com/en-us/azure/virtual-desktop/overview#requirements)
8+
* Terraform must be installed and configured as outlined [here](https://docs.microsoft.com/en-us/azure/developer/terraform/get-started-cloud-shell)
9+
* Active Directory already in place in this example, we are using AD in it’s own VNet.
10+
* Users in AAD that will be given access to AVD
11+
* This demo does not support Azure ADDS only deployment
12+
* Destroy could produce errors deleting subnet due to resources associated. Manually delete resources within the subnet before running destroy
13+
14+
## Components
15+
16+
* Azure Virtual Desktop Environment
17+
* Networking Infrastructure
18+
* Session Hosts
19+
* Profile Storage
20+
* Role Based Access Control
21+
22+
## Features
23+
24+
This directory contains the various components for building out Azure Virtual Desktop.
25+
26+
* `main.tf`
27+
deploys a new workspace, hostpool, application group with associations
28+
* `networking.tf`
29+
deploys a new vnet, subnet, nsg and peering to AD vnet
30+
* `host.tf`
31+
deploys new session host from the marketplace build and join to domain
32+
* `rbac.tf`
33+
deploys rbac assignment for the users group
34+
* `variables.tf`
35+
Input variables
36+
* `loganalytics.tf`
37+
deploys log anaylytics workspace
38+
* `sig.tf`
39+
deploys log anaylytics workspace
40+
* `random.tf`
41+
Random provider configuration
42+
* `defaults.tfvars`
43+
declares the actual input values (keep security in mind if you are putting confidential data)
44+
* `provider.tf`
45+
Azure RM and Azure AD provider configuration
46+
* `outputs.tf`
47+
defines the outputs that will be displayed on deployment
48+
* `netappstorage.tf`
49+
as an alternate to Azure Files storage this deploys NetApp Files storage for profiles in a dedicated subnet (access needs to be granted to the ANF service) [Set up Azure NetApp Files](https://docs.microsoft.com/en-us/azure/azure-netapp-files/azure-netapp-files-quickstart-set-up-account-create-volumes?tabs=azure-portal)
50+
51+
## Variable Inputs
52+
53+
[Variable Inputs](USAGE.md#inputs)
54+
55+
## Deploy
56+
57+
If you’ve not previously setup terraform, check out this article to get it installed [Quickstart - Configure Terraform using Azure Cloud Shell](https://docs.microsoft.com/en-us/azure/developer/terraform/get-started-cloud-shell)
58+
59+
You can review our sample configuration video here
60+
61+
Once Terraform is setup and you have created your Terraform templates, the first step is to initialize Terraform. This step ensures that Terraform has all the prerequisites to build your template in Azure.
62+
63+
```
64+
terraform init
65+
```
66+
67+
The next step is to have Terraform review and validate the template. An execution plan is generated and stored in the file specified by the -out parameter.
68+
69+
We also need to pass our variable definitions file during the plan. We can either load it automatically by renaming env.tfvars as terraform.tfvars OR env.auto.tfvars, in which case we will use the following to create the execution plan:
70+
71+
```bash
72+
terraform plan -out terraform_azure.tfplan
73+
```
74+
75+
When you're ready to build the infrastructure in Azure, apply the execution plan:
76+
77+
```bash
78+
terraform apply terraform_azure.tfplan
79+
```
80+
81+
## Final Configuration
82+
83+
You’ll notice we didn’t actually configure the session hosts to use our profile storage at any point. There is an assumption that we are using GPO to manage FSLogix across our host pools as documented here: [Use FSLogix Group Policy Template Files - FSLogix](https://docs.microsoft.com/en-us/fslogix/use-group-policy-templates-ht).
84+
85+
At a minimum you’ll need to configure the registry keys to enable FSLogix and configure the VHD Location to the NetApp Share URI: [Profile Container registry configuration settings - FSLogix](https://docs.microsoft.com/en-us/fslogix/profile-container-configuration-reference#enabled)
86+
87+
## Troubleshooting Terraform deployment
88+
89+
<details>
90+
<summary>Click to expand</summary>
91+
Terraform deployment can fail in two main categories:
92+
93+
Issues with Terraform code
94+
95+
1. [Issues with Desired State Configuration (DSC)](#issues-with-desired-state-configuration-dsc)
96+
2. [Issues with Terraform code](#issues-with-desired-state-configuration-dsc)
97+
98+
While it is rare to have issues with the Terraform code it is still possible, however most often errors are due to bad input in variables.tf.
99+
100+
* If there are errors in the Terraform code, please file a GitHub issue.
101+
* If there are warning in the Terraform code feel free to ignore or address for your own instance of that code.
102+
* Using Terraform error messages it's a good starting point towards identifying issues with input variables
103+
104+
### Issues with Desired State Configuration (DSC)
105+
106+
To troubleshoot this type of issue, navigate to the Azure portal and if needed reset the password on the VM that failed DSC. Once you are able to log in to the VM review the log files in the following two folders:
107+
</details>
108+
109+
## Additional References
110+
111+
<details>
112+
<summary>Click to expand</summary>
113+
114+
* [Terraform Download](https://www.terraform.io/downloads.html)
115+
* [Visual Code Download](https://code.visualstudio.com/Download)
116+
* [Powershell VS Code Extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode.PowerShell)
117+
* [HashiCorp Terraform VS Code Extension](https://marketplace.visualstudio.com/items?itemName=HashiCorp.terraform)
118+
* [Azure Terraform VS Code Extension Name](https://marketplace.visualstudio.com/items?itemName=ms-azuretools.vscode-azureterraform)
119+
* [Azure CLI](https://docs.microsoft.com/en-us/cli/azure/install-azure-cli-windows?tabs=azure-cli)
120+
* [Configure the Azure Terraform Visual Studio Code extension](https://docs.microsoft.com/en-us/azure/developer/terraform/configure-vs-code-extension-for-terraform)
121+
* [Setup video](https://youtu.be/YmbmpGdhI6w)
122+
123+
</details>
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
# Usage
2+
3+
<!--- BEGIN_TF_DOCS --->
4+
## Requirements
5+
6+
| Name | Version |
7+
|------|---------|
8+
| <a name="requirement_azurerm"></a> [azurerm](#requirement\_azurerm) | ~>2.0 |
9+
10+
## Providers
11+
12+
| Name | Version |
13+
|------|---------|
14+
| <a name="provider_azuread"></a> [azuread](#provider\_azuread) | n/a |
15+
| <a name="provider_azurerm"></a> [azurerm](#provider\_azurerm) | ~>2.0 |
16+
| <a name="provider_random"></a> [random](#provider\_random) | n/a |
17+
| <a name="provider_time"></a> [time](#provider\_time) | n/a |
18+
19+
## Modules
20+
21+
No modules.
22+
23+
## Resources
24+
25+
| Name | Type |
26+
|------|------|
27+
| [azuread_group.aad_group](https://registry.terraform.io/providers/hashicorp/azuread/latest/docs/resources/group) | resource |
28+
| [azuread_group_member.aad_group_member](https://registry.terraform.io/providers/hashicorp/azuread/latest/docs/resources/group_member) | resource |
29+
| [azurerm_log_analytics_workspace.law](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/log_analytics_workspace) | resource |
30+
| [azurerm_network_interface.avd_vm_nic](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/network_interface) | resource |
31+
| [azurerm_network_security_group.nsg](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/network_security_group) | resource |
32+
| [azurerm_resource_group.log](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/resource_group) | resource |
33+
| [azurerm_resource_group.rg](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/resource_group) | resource |
34+
| [azurerm_resource_group.rg_storage](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/resource_group) | resource |
35+
| [azurerm_resource_group.sigrg](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/resource_group) | resource |
36+
| [azurerm_role_assignment.af_role](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/role_assignment) | resource |
37+
| [azurerm_role_assignment.role](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/role_assignment) | resource |
38+
| [azurerm_shared_image.example](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/shared_image) | resource |
39+
| [azurerm_shared_image_gallery.sig](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/shared_image_gallery) | resource |
40+
| [azurerm_storage_account.storage](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/storage_account) | resource |
41+
| [azurerm_storage_share.FSShare](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/storage_share) | resource |
42+
| [azurerm_subnet.subnet](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/subnet) | resource |
43+
| [azurerm_subnet_network_security_group_association.nsg_assoc](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/subnet_network_security_group_association) | resource |
44+
| [azurerm_virtual_desktop_application_group.dag](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/virtual_desktop_application_group) | resource |
45+
| [azurerm_virtual_desktop_host_pool.hostpool](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/virtual_desktop_host_pool) | resource |
46+
| [azurerm_virtual_desktop_workspace.workspace](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/virtual_desktop_workspace) | resource |
47+
| [azurerm_virtual_desktop_workspace_application_group_association.ws-dag](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/virtual_desktop_workspace_application_group_association) | resource |
48+
| [azurerm_virtual_machine_extension.domain_join](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/virtual_machine_extension) | resource |
49+
| [azurerm_virtual_machine_extension.vmext_dsc](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/virtual_machine_extension) | resource |
50+
| [azurerm_virtual_network.vnet](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/virtual_network) | resource |
51+
| [azurerm_virtual_network_peering.peer1](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/virtual_network_peering) | resource |
52+
| [azurerm_virtual_network_peering.peer2](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/virtual_network_peering) | resource |
53+
| [azurerm_windows_virtual_machine.avd_vm](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/windows_virtual_machine) | resource |
54+
| [random_string.AVD_local_password](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/string) | resource |
55+
| [random_string.random](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/string) | resource |
56+
| [time_rotating.avd_token](https://registry.terraform.io/providers/hashicorp/time/latest/docs/resources/rotating) | resource |
57+
| [azuread_user.aad_user](https://registry.terraform.io/providers/hashicorp/azuread/latest/docs/data-sources/user) | data source |
58+
| [azurerm_role_definition.role](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/role_definition) | data source |
59+
| [azurerm_role_definition.storage_role](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/role_definition) | data source |
60+
| [azurerm_virtual_network.ad_vnet_data](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/virtual_network) | data source |
61+
62+
## Inputs
63+
64+
| Name | Description | Type | Default | Required |
65+
|------|-------------|------|---------|:--------:|
66+
| <a name="input_aad_group_name"></a> [aad\_group\_name](#input\_aad\_group\_name) | Azure Active Directory Group for AVD users | `string` | n/a | yes |
67+
| <a name="input_ad_rg"></a> [ad\_rg](#input\_ad\_rg) | The resource group for AD VM | `string` | n/a | yes |
68+
| <a name="input_ad_vnet"></a> [ad\_vnet](#input\_ad\_vnet) | Name of domain controller vnet | `string` | n/a | yes |
69+
| <a name="input_avd_users"></a> [avd\_users](#input\_avd\_users) | AVD users | `list` | `[]` | no |
70+
| <a name="input_deploy_location"></a> [deploy\_location](#input\_deploy\_location) | The Azure Region in which all resources in this example should be created. | `string` | n/a | yes |
71+
| <a name="input_dns_servers"></a> [dns\_servers](#input\_dns\_servers) | Custom DNS configuration | `list(string)` | n/a | yes |
72+
| <a name="input_domain_name"></a> [domain\_name](#input\_domain\_name) | Name of the domain to join | `string` | n/a | yes |
73+
| <a name="input_domain_password"></a> [domain\_password](#input\_domain\_password) | Password of the user to authenticate with the domain | `string` | n/a | yes |
74+
| <a name="input_domain_user_upn"></a> [domain\_user\_upn](#input\_domain\_user\_upn) | Username for domain join (do not include domain name as this is appended) | `string` | n/a | yes |
75+
| <a name="input_hostpool"></a> [hostpool](#input\_hostpool) | Name of the Azure Virtual Desktop host pool | `string` | `"AVD-TF-HP"` | no |
76+
| <a name="input_local_admin_password"></a> [local\_admin\_password](#input\_local\_admin\_password) | local admin password | `any` | n/a | yes |
77+
| <a name="input_local_admin_username"></a> [local\_admin\_username](#input\_local\_admin\_username) | local admin username | `string` | n/a | yes |
78+
| <a name="input_ou_path"></a> [ou\_path](#input\_ou\_path) | n/a | `string` | `""` | no |
79+
| <a name="input_prefix"></a> [prefix](#input\_prefix) | Prefix of the name of the AVD machine(s) | `string` | n/a | yes |
80+
| <a name="input_rdsh_count"></a> [rdsh\_count](#input\_rdsh\_count) | Number of AVD machines to deploy | `number` | `2` | no |
81+
| <a name="input_rg_name"></a> [rg\_name](#input\_rg\_name) | Name of the Resource group in which to deploy these resources | `string` | `"AVD-TF"` | no |
82+
| <a name="input_shared"></a> [shared](#input\_shared) | Prefix of the name of the AVD machine(s) | `string` | n/a | yes |
83+
| <a name="input_subnet_range"></a> [subnet\_range](#input\_subnet\_range) | Address range for session host subnet | `list(string)` | n/a | yes |
84+
| <a name="input_vm_size"></a> [vm\_size](#input\_vm\_size) | Size of the machine to deploy | `string` | `"Standard_DS2_v2"` | no |
85+
| <a name="input_vnet_range"></a> [vnet\_range](#input\_vnet\_range) | Address range for deployment VNet | `list(string)` | n/a | yes |
86+
| <a name="input_workspace"></a> [workspace](#input\_workspace) | Name of the Azure Virtual Desktop workspace | `string` | `"AVD TF Workspace"` | no |
87+
88+
## Outputs
89+
90+
| Name | Description |
91+
|------|-------------|
92+
| <a name="output_aadgroupname"></a> [aadgroupname](#output\_aadgroupname) | Azure Active Directory Group for AVD users |
93+
| <a name="output_avdusers"></a> [avdusers](#output\_avdusers) | AVD users |
94+
| <a name="output_dnsservers"></a> [dnsservers](#output\_dnsservers) | Custom DNS configuration |
95+
| <a name="output_location"></a> [location](#output\_location) | The Azure region |
96+
| <a name="output_rdshcount"></a> [rdshcount](#output\_rdshcount) | The number of VMs created |
97+
| <a name="output_resource_group_name"></a> [resource\_group\_name](#output\_resource\_group\_name) | Name of the Resource group created |
98+
| <a name="output_storage_account_share"></a> [storage\_account\_share](#output\_storage\_account\_share) | Name of the Azure File Share created for FSLogix |
99+
| <a name="output_vnetrange"></a> [vnetrange](#output\_vnetrange) | Address range for deployment vnet |
100+
101+
<!--- END_TF_DOCS --->
102+
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Customized the sample values below for your environment and either rename to terraform.tfvars or env.auto.tfvars
2+
3+
deploy_location = "west europe"
4+
rg_name = "avd-resources-rg"
5+
prefix = "avdtf"
6+
local_admin_username = "localadm"
7+
local_admin_password = "ChangeMe123$"
8+
vnet_range = ["10.1.0.0/16"]
9+
subnet_range = ["10.1.0.0/24"]
10+
netapp_address = ["10.1.1.0/24"]
11+
dns_servers = ["10.0.1.4", "168.63.129.16"]
12+
aad_group_name = "AVDUsers"
13+
domain_name = "infra.local"
14+
domain_user_upn = "admin" # do not include domain name as this is appended
15+
domain_password = "ChangeMe123!"
16+
ad_vnet = "infra-network"
17+
ad_rg = "infra-rg"
18+
avd_users = [
19+
"avduser01@infra.local",
20+
"avduser01@infra.local"
21+
]

0 commit comments

Comments
 (0)