Not able to Provision Azure Virtual Desktop using Rest APIs

siddalinga 0 Reputation points

Dear Microsoft Community,

I am trying to build a POC for AVD(Azure Virtual Desktop) Provisioning using REST APIs.

I learned, for Provisioning a AVD, we need to complete few steps.

  1. Create Security Group (for Users, Administrators)
  2. Create Resource Group
  3. Create Virtual Network
  4. Create Sub Network
  5. Create Network Interface
  6. Create HostPool
  7. Create Session Host (Virtual Machine) in the Hostpool
  8. Create Hostpool Application Group
  9. Create Hostpool Work Space
  10. Add Security Groups to HostPool Application Group
  11. Add Resource Group IAM Roles (user, admin) to Security Group

Using Microsoft Azure RestAPIs I am able to complete 1st to 6th step.

When I am running the 7th step (For Create Session Host (Virtual Machine) in the Hostpool) the API status is Success but Session Host (VM) is not creating in the HostPool

Did any one worked on this kind of POC ?

I have followed below links to find the right API for Session Host (VM) creation in the Hostpool but could not get success.

https://learn.microsoft.com/en-us/rest/api/desktopvirtualization/session-host-managements/create-or-update?view=rest-desktopvirtualization-2024-08-08-preview&tabs=HTTP

https://learn.microsoft.com/en-us/rest/api/desktopvirtualization/host-pools/create-or-update?view=rest-desktopvirtualization-2024-04-03&tabs=HTTP

https://learn.microsoft.com/en-us/rest/api/desktopvirtualization/session-host-configurations/create-or-update?view=rest-desktopvirtualization-2024-08-08-preview&tabs=HTTP

I appreciate your response.

0 comments No comments

Sign in to comment

1 answer

  1. Anonymous

    Hi siddalinga,

    Welcome to the Microsoft Q&A Platform! Thank you for asking your question here.

    It sounds like you’re encountering an issue with creating a Session Host (Virtual Machine) in the HostPool using Azure Virtual Desktop (AVD) REST APIs. To troubleshoot this issue, there are a few steps:

    Make sure that the API permissions are correctly set up. The service principal or managed identity you’re using must have the necessary permissions to create resources in the specified resource group and subscription.

    Double-check the API request payload for any missing or incorrect parameters. Ensure that all required fields are correctly populated.

    Verify that you have not exceeded any quotas or limits for your subscription, such as the number of virtual machines or cores.

    If an answer has been helpful, please consider accept the answer and "Upvote" to help increase visibility of this question for other members of the Microsoft Q&A community. 

    πŸ‘ User's image

    1. Anonymous

      Hi siddalinga,

      Just checking in to see if you had a chance to review my comment on your question. Please let us know if it was helpful and feel free to reach out if you have any further queries.

      If you found the information useful, please click "Accept Answer" and "Upvote" on the post to let us know.

      Thank You.

    2. Anonymous

      Hi siddalinga,

      I wanted to check if you had the opportunity to review the information which was provided in my previous posted comment.

      If it was helpful, please click "Accept Answer" and "Upvote" on his post to let us know.

      Thank You.

    3. siddalinga 0 Reputation points

      Hi Sai Krishna, thank you very much for responding me.

      API is able to create the Resource group, Virtual Network, Sub Network and HostPool but not Host session in the Hostpool.

      I have tried running the below API. I am getting 201 as response code.

      Here are the API details.

      PUT:

      https://management.azure.com/subscriptions/c8acbda6-91cb-4d19-a9eb-e7b49dc3502c/resourceGroups/AVD_RG/providers/Microsoft.DesktopVirtualization/hostPools/AVD_HP/sessionHostConfigurations/default?api-version=2024-08-08-preview

      Payload Body:

      {

      "properties": {

      "friendlyName": "InitialConfiguration",
      
      "vmTags": {
      
       "Department": "myDepartment",
      
       "Team": "myTeam"
      
      },
      
      "vmLocation": "centralindia",
      
      "vmResourceGroup": "AVD_RG",
      
      "vmNamePrefix": "westus2-vm",
      
      "availabilityZones": [
      
       1,
      
       3
      
      ],
      
      "networkInfo": {
      
       "subnetId": "/subscriptions/c8acbda6-91cb-4d19-a9eb-e7b49dc3502c/resourceGroups/AVD_RG/providers/Microsoft.Network/virtualNetworks/AVD_VNet/subnets/AVD_SNet"
      
      },
      
      "vmSizeId": "Standard_D2s_v3",
      
      "diskInfo": {
      
       "type": "Standard_LRS"
      
      },
      
      "customConfigurationScriptUrl": "https://storageaccountname.blob.core.windows.net/blobcontainer/file",
      
      "imageInfo": {
      
       "type": "Marketplace",
      
       "marketplaceInfo": {
      
       "offer": "Windows-10",
      
       "publisher": "MicrosoftWindowsDesktop",
      
       "sku": "19h2-ent",
      
       "exactVersion": "2019.0.20190115"
      
       },
      
       "customInfo": {
      
       "resourceId": "/subscriptions/c8acbda6-91cb-4d19-a9eb-e7b49dc3502c/resourceGroups/AVD_RG/providers/Microsoft.Compute/images/imageName"
      
       }
      
      },
      
      "domainInfo": {
      
       "joinType": "AzureActiveDirectory",
      
       "activeDirectoryInfo": {
      
       "domainCredentials": {
      
       "usernameKeyVaultSecretUri": "https://avdvault29thoct.vault.azure.net/secrets/itadminuser/afd48f655d324161b3588df659d795ab",
      
       "passwordKeyVaultSecretUri": "https://avdvault29thoct.vault.azure.net/secrets/itadmin/21fd17bced6a44e6b383d1a09d5a7f50"
      
       },
      
       "ouPath": "OU=testOU,DC=domain,DC=Domain,DC=com",
      
       "domainName": "wvdarmtest1.net"
      
       },
      
       "azureActiveDirectoryInfo": {
      
       "mdmProviderGuid": "bdefabc0-95b4-48b3-b645-8a753a63c4fa"
      
       }
      
      },
      
      "securityInfo": {
      
       "type": "TrustedLaunch",
      
       "secureBootEnabled": true,
      
       "vTpmEnabled": true
      
      },
      
      "vmAdminCredentials": {
      
       "usernameKeyVaultSecretUri": "https://avdvault29thoct.vault.azure.net/secrets/itadminuser/afd48f655d324161b3588df659d795ab",
      
       "passwordKeyVaultSecretUri": "https://avdvault29thoct.vault.azure.net/secrets/itadmin/21fd17bced6a44e6b383d1a09d5a7f50"
      
      },
      
      "bootDiagnosticsInfo": {
      
       "enabled": true,
      
       "storageUri": "https://myStorageAccountName.blob.core.windows.net"
      
      }
      

      }

      }

      --

      I have attached the Response screenshot.

      Please let me know where I am doing wrong.





    4. Anonymous

      Hi siddalinga,

      It looks like your request to create the session host was accepted, indicated by the 201 Created status code. The presence of the azure-asyncoperation URL in the response header means the operation is asynchronous, so you’ll need to monitor this URL to track the status of the session host creation.

      To check the status, send a GET request to the azure-asyncoperation URL. The response will show whether the operation is InProgress, Succeeded, or Failed. Keep polling until you see a Succeeded status. If it’s Failed, review the error details provided in the response to understand the issue.

      For further reference, here are relevant Microsoft documents:
      Session Host Configurations - Create Or Update
      Track asynchronous Azure operations

      If an answer has been helpful, please consider accept the answer and "Upvote" to help increase visibility of this question for other members of the Microsoft Q&A community. 


    Sign in to comment
Sign in to answer

Your answer