# AVD Templates

## Overview

Using this feature you can define a set (aka template) of applications. This set of applications can then be applied to a computer in a headless / unattended fashion using RealmJoin Client.

This is intended for creating golden images for Azure Virtual Desktop multi-session pooled hosts.

{% hint style="info" %}
Creating and managing Azure Virtual Desktop (AVD) templates is a complex task that requires expert knowledge, thorough planning, and precise configuration. While we fully support all RealmJoin-related topics described on this page, our ability to assist with broader AVD templating topics is limited. This includes—but is not limited to—general guidance on creating, customizing, deploying, and troubleshooting AVD templates.
{% endhint %}

## Permissions

To enable the feature, you must define a [custom role](https://docs.realmjoin.com/realmjoin-settings/permission/custom-roles) and assign the role to a group or user.

Copy the following definition and make sure to change the GroupID accordingly.

```json
{
  "Rules": [
    {
      "Name": "Allow admins to access the templating feature",
      "Groups": [
        "<Group ID of Admin Group>"
      ],
      "Permissions": [
        "CanReadTemplateTable",
        "CanReadTemplateDetails",
        "CanEditTemplate",
        "CanDeleteTemplate",
        "CanChangeTemplatePackages",
        "CanChangeTemplateTokens"
      ]
    }
  ]
}
```

## Managing templates

### Creating a template

1. Click on the "templates" icon or open the Templates section by entering the url: <https://portal.realmjoin.com/templates>

<figure><img src="https://2868468309-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MkrcM7cKOpXKri1kVrh%2Fuploads%2FxXuRmmsPeWTAz5UJG5Mm%2Fimage.png?alt=media&#x26;token=8b474fea-95ba-4b94-9b29-596d2d61192b" alt=""><figcaption><p>Templates List</p></figcaption></figure>

2. Select the <img src="https://2868468309-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MkrcM7cKOpXKri1kVrh%2Fuploads%2FHmyI4SpDdXwH2CwGu7yt%2Fimage.png?alt=media&#x26;token=4778665b-3ac9-4752-96ed-53ece4633280" alt="" data-size="line"> icon (1), enter a meaningful name (2) and Click "Save" (3).&#x20;

<figure><img src="https://2868468309-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MkrcM7cKOpXKri1kVrh%2Fuploads%2FuQUkRsaiVgISctj4Zb8S%2Fimage-1.png?alt=media&#x26;token=5cc20b3b-0f47-4d1b-bb7e-fb693e4f6498" alt=""><figcaption><p>Create a template</p></figcaption></figure>

### Add Applications to a Template

1. Open the template by clicking on its name.
2. To add packages to the template, click the <img src="https://2868468309-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MkrcM7cKOpXKri1kVrh%2Fuploads%2FHvBdWctDPfuVmTP12ZRK%2Fimage.png?alt=media&#x26;token=d520017f-4e10-4236-87ca-809154e79403" alt="" data-size="line"> icon.&#x20;

<figure><img src="https://2868468309-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MkrcM7cKOpXKri1kVrh%2Fuploads%2Fe2WNicG057XlC2Zjw2TX%2Fimage-2.png?alt=media&#x26;token=dc4c9bee-a032-4c7f-831b-86f6506737d6" alt=""><figcaption><p>Add packages to a template - 1</p></figcaption></figure>

3. Search for a package and hit the ![](https://2868468309-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MkrcM7cKOpXKri1kVrh%2Fuploads%2FBdRIwooSznEKFEutEiNJ%2Fimage.png?alt=media\&token=67b30b07-0391-4252-a3c9-108e425452f8) icon to add it to your template. The list represents all RealmJoin packages you have subscribed to in your environment.
4. Once you are done, click the **Close** button.

<figure><img src="https://2868468309-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MkrcM7cKOpXKri1kVrh%2Fuploads%2FcaiKnyWcTB03y2fsTYfw%2Fimage-3.png?alt=media&#x26;token=cb1c1ddd-a678-4f92-be44-49d46fe95db2" alt=""><figcaption><p>Add packages to a template - 2</p></figcaption></figure>

{% hint style="info" %}
Intune Packages can not be assigned using AVD templates.
{% endhint %}

### Remove Applications from a Template

1. Open the template by clicking on its name.
2. If you want to remove applications, click on **Unassign**. If you want to define arguments overwriting those set on the package level, you can do so by clicking on **Settings**.&#x20;

<figure><img src="https://2868468309-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MkrcM7cKOpXKri1kVrh%2Fuploads%2FBIajMVAI5JNGAdsznMZ9%2Fimage-4.png?alt=media&#x26;token=29c19b9e-0b05-4d71-be2c-70e35750ab25" alt=""><figcaption><p>Remote packages from a template</p></figcaption></figure>

### Create a Token

To use the template via RealmJoin Client, you also need a token.&#x20;

{% hint style="warning" %}
Please handle the token with care. If you think the token might have been leaked, revoke it by hitting the **Revoke** button next to the token.&#x20;
{% endhint %}

1. Create a token, click on the **Tokens** tab.
2. Click the <img src="https://2868468309-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MkrcM7cKOpXKri1kVrh%2Fuploads%2FHmyI4SpDdXwH2CwGu7yt%2Fimage.png?alt=media&#x26;token=4778665b-3ac9-4752-96ed-53ece4633280" alt="" data-size="line"> icon (1), enter a meaningful name (2) and click **Save** (3).&#x20;

<figure><img src="https://2868468309-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MkrcM7cKOpXKri1kVrh%2Fuploads%2FgPVq1LS6wTVvp5iI2iJa%2Fimage-6.png?alt=media&#x26;token=39640bf1-7dfb-4433-aa00-6b0e6e1892dd" alt=""><figcaption><p>Create a token</p></figcaption></figure>

## Using a Template&#x20;

### AVD / Headless Provisioning

Collect the template ID and the token you want to use for deployment.

<figure><img src="https://2868468309-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MkrcM7cKOpXKri1kVrh%2Fuploads%2FVW0SRqoDYrJkVNXMF8Co%2Fimage.png?alt=media&#x26;token=56d936a7-b26e-44f0-91a0-7ffb7556ffc9" alt=""><figcaption><p>Find template ID and token</p></figcaption></figure>

Run the following command from inside your system/VM you want to prepare as golden image:

1. Download RealmJoin: `Invoke-WebRequest -Uri "https://gkrealmjoin.s3.amazonaws.com/win-release/RealmJoin.exe" -OutFile "C:\temp\RealmJoin.exe"`
2. Install RealmJoin: `Start-Process -FilePath "C:\temp\RealmJoin.exe" -ArgumentList "-install" -Wait`
3. Run headless deployment. Make sure to enter your individual template ID and token: `Start-Process -FilePath "C:\Program Files\RealmJoin\RealmJoinService.exe" -ArgumentList " -avdprovision <Template ID> <Template Token>"`

### Logging and Traces

For both, RealmJoin installation and headless deployment, you can add an additional argument `-trace` to extend logging. To check the status/logs during headless deployment, open and periodically refresh realmjoin.log which can be found under `C:\Windows\Logs\`


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.realmjoin.com/app-management/avd-templates.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
