terraform/quickstart/101-azure-virtual-desktop-anf
github-actions[bot] 2bfc5cfbf2 Update TestRecord 2024-11-17 03:48:00 +00:00
..
environments new folder for anf option, edits to variables 2022-02-06 23:51:32 -05:00
README.md fix broken link 2022-02-07 09:36:11 -05:00
TestRecord.md Update TestRecord 2024-11-17 03:48:00 +00:00
USAGE.md new folder for anf option, edits to variables 2022-02-06 23:51:32 -05:00
host.tf fmt 2022-03-28 22:05:53 -04:00
loganalytics.tf fmt 2022-03-28 22:05:53 -04:00
main.tf fmt 2022-03-28 22:05:53 -04:00
netappstorage.tf fmt 2022-03-28 22:05:53 -04:00
networking.tf new folder for anf option, edits to variables 2022-02-06 23:51:32 -05:00
outputs.tf fmt 2022-03-28 22:05:53 -04:00
provider.tf new folder for anf option, edits to variables 2022-02-06 23:51:32 -05:00
rbac.tf fmt 2022-03-28 22:05:53 -04:00
sig.tf GitHub Issue #1125 - azure-dev-docs 2023-05-09 10:38:30 -07:00
variables.tf fmt 2022-03-28 22:05:53 -04:00

README.md

Terraform for Azure Virtual Desktop

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.

Requirements and limitations

  • Ensure that you meet the requirements for Azure Virtual Desktop
  • Terraform must be installed and configured as outlined here
  • Active Directory already in place in this example, we are using AD in its own VNet.
  • Users in AAD that will be given access to AVD
  • This demo does not support Azure ADDS only deployment
  • Destroy could produce errors deleting subnet due to resources associated. Manually delete resources within the subnet before running destroy

Components

  • Azure Virtual Desktop Environment
  • Networking Infrastructure
  • Session Hosts
  • Profile Storage
  • Role Based Access Control

Features

This directory contains the various components for building out Azure Virtual Desktop.

  • main.tf
    deploys a new workspace, hostpool, application group with associations
  • networking.tf
    deploys a new vnet, subnet, nsg and peering to AD vnet
  • host.tf
    deploys new session host from the marketplace build and join to domain
  • rbac.tf
    deploys rbac assignment for the users group
  • variables.tf
    Input variables
  • loganalytics.tf
    deploys log anaylytics workspace
  • sig.tf deploys log anaylytics workspace
  • random.tf Random provider configuration
  • defaults.tfvars
    declares the actual input values (keep security in mind if you are putting confidential data)
  • provider.tf
    Azure RM and Azure AD provider configuration
  • outputs.tf defines the outputs that will be displayed on deployment
  • netappstorage.tf
    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

Variable Inputs

Variable Inputs

Deploy

If youve not previously setup terraform, check out this article to get it installed Quickstart - Configure Terraform using Azure Cloud Shell

You can review our sample configuration video here

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.

terraform init

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.

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:

terraform plan -out terraform_azure.tfplan

When you're ready to build the infrastructure in Azure, apply the execution plan:

terraform apply terraform_azure.tfplan

Final Configuration

Youll notice we didnt 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.

At a minimum youll 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

Troubleshooting Terraform deployment

Click to expand Terraform deployment can fail in two main categories:

Issues with Terraform code

  1. Issues with Desired State Configuration (DSC)
  2. Issues with Terraform code

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.

  • If there are errors in the Terraform code, please file a GitHub issue.
  • If there are warning in the Terraform code feel free to ignore or address for your own instance of that code.
  • Using Terraform error messages it's a good starting point towards identifying issues with input variables

Issues with Desired State Configuration (DSC)

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:

Additional References

Click to expand