nicoloverflow
nicoloverflow

Reputation: 121

WVD - az cli sample for creating host pool, workspace and application pool

for an azure WVD deployment, I’d like to automate via az cli the creation of the following elements:

The only available documentation I have found is in https://learn.microsoft.com/en-us/cli/azure/desktopvirtualization?view=azure-cli-latest where there is just a list of available parameters without a detailed how to guide and some E2E sample.

Any advice?

Upvotes: 1

Views: 657

Answers (1)

Ked Mardemootoo
Ked Mardemootoo

Reputation: 1605

You can refer to this documentation which explains how to do it using PowerShell. It's a pain it's just for one resource but still gives you an idea.

I'd also recommend your first step be to create what you need using the Azure Portal. This article explains how do to it from the portal.

Make sure to note down every field you're filling in, including the fields with default values.

Once you have created all the resources, you can now export an ARM template of the resources you have created, all customisation included. Look under the Automation menu of the resource, and click on Export template. You can use this template to automate your deployment.

Secondly, if you want to consider a different approach using another Infrastructure as Code tool, Terraform supports creating WVD objects. If you are familiar with Terraform, you can check this article which explains how to do it.

Let's assume you still want to proceed with Az Cli. I had a look at the az desktopvirtualization hostpool create help command in my CloudShell, I can see a disclaimer as follows:

Command group 'desktopvirtualization hostpool' is experimental and under development. Reference and support levels: https://aka.ms/CLI_refstatus

Here's a picture for root commands:

enter image description here

You have to bear in mind you will get limited functionality and limited support from Microsoft support/Azure team and possibly other members of the community, until the product at least in Preview. I gave it a try on my end and providing you the code here just to get you going.

Considering your requirements, I've tried to create some commands you can use. Some parameters (the IDs) were a bit vague and I had to look at the ARM template to find out what value I should put. The steps to deploy should be in this sequence.

  1. Create a host pool of virtual machines.
az desktopvirtualization hostpool create  --resource-group "myrg"
                                          --host-pool-type "Pooled" 
                                          --load-balancer-type "BreadthFirst" 
                                          --location westus //only available in certain regions
                                          --name "myhostpool" 
                                          --personal-desktop-assignment-type "automatic" 
  1. Create application groups.
az desktopvirtualization applicationgroup create --application-group-type "Desktop"  
                                                 --resource-group "myrg" 
                                                 --host-pool-arm-path "/subscriptions/<provide_subscriptionID_here>/resourceGroups/myrg/providers/Microsoft.DesktopVirtualization/hostpools/myhostpool"  
                                                 --location westus 
                                                 --name "appgroup"
  1. Create workspaces.
az desktopvirtualization workspace create --location westus 
                                          --name "myworkspace"
                                          --resource-group "myrg"
                                          --application-group-references "/subscriptions/<provide_subscriptionID_here>/resourcegroups/myrg/providers/Microsoft.DesktopVirtualization/applicationgroups/appgroup"

To conclude, I've probably not spent enough time to really look into how much more it can be automated but I feel like, with the exception of ARM templates, other options will still require a fair bit of manual work.

Upvotes: 1

Related Questions