# Onboard Microsoft Azure

> For the complete documentation index, see [llms.txt](https://docs-stg.ringleader.dev/llms.txt).


> Let Ringleader run workstation VMs in one of your Azure resource groups, with a custom role and no client secret.


Let Ringleader run workstation VMs in one of your Azure resource groups, with a custom
role and no client secret. Use this when you want
[workstations](https://docs-stg.ringleader.dev/reference/resources/workstation/) on your bill and inside your network.

## Prerequisites

- [Ringleader installed](https://docs-stg.ringleader.dev/install/), for the `rl` commands in the last two tasks.
- Two values from Ringleader, which you receive when your organization is set up: the issuer
  URL, written with no trailing slash, and your [organization](https://docs-stg.ringleader.dev/reference/resources/organization/)'s
  id, a UUID and never its name. If you do not have them, ask us.
  [Fix a sign-in that your cloud refuses](https://docs-stg.ringleader.dev/cloud-accounts/keyless-access/#fix-a-sign-in-that-your-cloud-refuses)
  says what to check if Entra rejects them.
- A resource group for the workstations, which you create first. The module and the script do not.
  Use a new, empty one that holds nothing else. Workstations are billed to it, and everything
  Ringleader may do is limited to it. A dedicated resource group keeps the bill and the risk in one
  place.
- Permission to create an app registration in your Entra tenant, for this setup only.
- The subscription feature `Microsoft.Compute/UseStandardSecurityType`, registered on the
  subscription. Someone with Contributor or Owner on the subscription registers it once.
  [Register the subscription feature](#register-the-subscription-feature) shows how.
- The examples use the resource group `ringleader-workstations` and the CloudAccount
  `my-azure-account`. Replace them with yours.

## Register the subscription feature

Ringleader creates VMs with `securityType=Standard`, because the Trusted Launch default does not
allow the nested virtualization that workstations rely on. Without this feature, every VM create
fails: everything else looks right, and no workstation ever starts. Register it once per
subscription.

1. Register the feature:

   ```bash
   az feature register --namespace Microsoft.Compute --name UseStandardSecurityType
   ```

2. Poll until the state is `Registered`. This can take several minutes.

   ```bash
   az feature show --namespace Microsoft.Compute --name UseStandardSecurityType \
     --query properties.state -o tsv
   ```

3. Propagate the registration:

   ```bash
   az provider register --namespace Microsoft.Compute
   ```

4. Confirm that your chosen region has capacity for the VM size you intend to use. Without it,
   every create returns `SkuNotAvailable`.

## Set up keyless access

Onboarding creates the identity Ringleader signs in as, a custom role and its assignment on your
resource group, and the federated credential that lets Entra accept Ringleader's tokens. It can also
create a network. The
[Microsoft Azure permissions and resources](https://docs-stg.ringleader.dev/reference/providers/azure-permissions/) page lists
everything it creates and why it is safe.

Choose the tool your team already runs. All three do the same thing, and the ARM and Terraform
paths live in
[github.com/ringleader-dev/cloud-onboarding](https://github.com/ringleader-dev/cloud-onboarding).
Both finish by printing the values you send back in the next task.


### ARM


An ARM template cannot create an app registration or a federated credential, because they live in
Entra and not in a resource group. A script creates them with `az`, then deploys the role, its
assignment and the network as templates.

1. Clone the repository and change into the ARM folder:

   ```bash
   git clone https://github.com/ringleader-dev/cloud-onboarding
   cd cloud-onboarding/azure/arm
   ```

2. Set the variables. `SSH_SOURCE_CIDR` adds an SSH rule of your own for the addresses your
   engineers connect from. [Cloud accounts and reachability](https://docs-stg.ringleader.dev/cloud-accounts/accounts-reachability/)
   says who can connect without it.

   ```bash
   export RG=ringleader-workstations                      # the resource group you created
   export ISSUER_URL='https://oidc-app.ringleader.dev'
   export ORG_UID='0192f5bf-af83-7178-8d0a-f1c7aea06bde'
   export SSH_SOURCE_CIDR=203.0.113.0/24                   # where your engineers connect from
   ```

3. Sign in to Azure:

   ```bash
   az login
   ```

4. Run the script. It prints the values to send back. It is safe to run again if something goes
   wrong partway.

   ```bash
   ./deploy.sh
   ```

<div class="callout callout-note">
  <p class="callout-title">Names for a second resource group in the same tenant</p>
  <div class="callout-body">
    <p><code>deploy.sh</code> takes two more optional variables, and both matter as soon as a second
resource group in the <strong>same Entra tenant</strong> is onboarded (a second team, a second
environment, prod alongside dev). Left at their defaults, one fails loudly and the
other fails <strong>silently</strong>:</p>
<div class="code-wrap" data-lang="bash">
  <button class="code-copy" type="button" aria-label="Copy to clipboard" data-copy-label="Copy" data-copied-label="Copied">Copy</button>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl"><span class="nb">export</span> <span class="nv">APP_NAME</span><span class="o">=</span><span class="s1">&#39;Ringleader Admin (team-b)&#39;</span>                  <span class="c1"># default: ringleader-workstations</span>
</span></span><span class="line"><span class="cl"><span class="nb">export</span> <span class="nv">ROLE_NAME</span><span class="o">=</span><span class="s1">&#39;Ringleader Workstation Operator (team-b)&#39;</span>  <span class="c1"># default: Ringleader Workstation Operator</span></span></span></code></pre></div>
</div>
<ul>
<li><strong><code>ROLE_NAME</code>.</strong> Azure requires a custom role&rsquo;s display name to be unique across
the whole tenant, even when the roles are scoped to different resource groups.
Re-using the default for a second onboarding fails the deployment with
<code>RoleDefinitionWithSameNameExists</code>.</li>
<li><strong><code>APP_NAME</code>.</strong> <code>deploy.sh</code> finds its app registration by display name and reuses
the first match, which is what makes re-runs safe. Left at the default, a second
onboarding silently adopts the first onboarding&rsquo;s application and adds the new federated
credential to it, so two boundaries end up sharing one identity. Name the application per
team or per environment and the lookup stays honest.</li>
</ul>
<p>One resource group in a tenant needs neither variable.</p>

  </div>
</div>




### Terraform


Terraform creates everything, end to end.

1. Clone the repository and change into the example folder:

   ```bash
   git clone https://github.com/ringleader-dev/cloud-onboarding
   cd cloud-onboarding/azure/terraform/examples/standalone
   ```

2. Copy the example variables file:

   ```bash
   cp terraform.tfvars.example terraform.tfvars
   ```

3. In `terraform.tfvars`, set your subscription id, the resource group you created and the two
   values from Ringleader. Uncomment `ssh_source_ranges` and list the addresses your engineers
   connect from.

4. Sign in to Azure:

   ```bash
   az login
   ```

5. Apply the module:

   ```bash
   terraform init && terraform apply
   ```

6. Print the values to send back:

   ```bash
   terraform output handoff
   ```



### The portal


The portal gives the same result without `deploy.sh`. The app registration and its federated
credential live in Entra, so you create them in the Entra portal. The role and its assignment are
one template, which you deploy to the resource group.

1. Clone the repository, which holds the template you deploy in step 5:

   ```bash
   git clone https://github.com/ringleader-dev/cloud-onboarding
   ```

2. Create the application. In *Microsoft Entra ID*, go to *App registrations* and choose *New
   registration*. Give it a name, choose **Accounts in this organizational directory only**, and
   register. Copy the **Application (client) ID**, which is the application client id you send
   back.
3. Add the federated credential. On that application, go to *Certificates & secrets*, then
   *Federated credentials*, choose *Add credential* and pick the scenario **Other issuer**. Enter
   these values, with no trailing slash on the issuer:

   | Field | Value |
   |---|---|
   | Issuer | `<issuer-url>/org/<org-id>` |
   | Subject identifier | `org:<org-id>` |
   | Name | `ringleader-oidc` |
   | Audience | `api://AzureADTokenExchange` |

   All three of issuer, subject and audience must match exactly.
4. Find the service principal's object id. In *Microsoft Entra ID*, go to *Enterprise
   applications*, open your application and copy its **Object ID**. This is **not** the client id,
   and it is the value the template wants.
5. Deploy the role. In the portal search, choose *Deploy a custom template*, then *Build your own
   template in the editor*, load `azure/arm/azuredeploy.json` from the repository you cloned and choose *Save*. Choose your
   **resource group**, because the template is resource-group scoped, and set `principalId` to the
   object id from step 4. The template defaults `enableWorkstationIdentities` to **true**, so set it
   to false unless you use
   [Cloud runtime identities](https://docs-stg.ringleader.dev/cloud-accounts/cloud-identities/runtime-identities/).

If you are onboarding a second resource group in this tenant, give `roleName` a distinct value in
step 5, as the note under [ARM](#arm) explains.






## Send the values to your organization administrator

Send the values that [Values you hand back](https://docs-stg.ringleader.dev/reference/providers/azure-permissions/#values-you-hand-back)
lists to whoever administers Ringleader for your organization, which may be you. They are public
identifiers, and no secret is among them. How Ringleader uses them is in
[Keyless cloud access](https://docs-stg.ringleader.dev/cloud-accounts/keyless-access/).

## Create the CloudAccount

An organization administrator records which application Ringleader signs in as by creating a
[CloudAccount](https://docs-stg.ringleader.dev/reference/resources/cloudaccount/). The
[Spec fields](https://docs-stg.ringleader.dev/reference/resources/cloudaccount/#spec-fields) table lists every field.

1. Save this as `my-azure-account.yaml`, with your organization, application client id and tenant
   id:

   ```yaml
   apiVersion: core.ringleader.dev/v1
   kind: CloudAccount
   metadata:
     name: my-azure-account
   spec:
     org: acme
     provider: azure
     azure:
       # The Entra application (client) id that holds the workstation permissions on
       # your resource group, and whose federated identity credential trusts
       # Ringleader's per-organization issuer.
       targetAppClientId: ec6d0a82-536f-463e-baa5-a10221befa86
       # Your Azure AD tenant.
       tenant: bb90f2d3-842d-41ea-8c0c-0e6671775ef7
   ```

2. Apply it. Apply it before the CloudIdentity that references it. A multi-document `apply` orders
   them for you.

   ```bash
   rl apply -f my-azure-account.yaml
   ```

3. List the account to confirm it exists. The alias is `rl ca get`.

   ```bash
   rl cloudaccount get
   ```

Create the CloudIdentity from the remaining values, as
[CloudIdentity](https://docs-stg.ringleader.dev/reference/resources/cloudidentity/) describes.

## Check the setup

Check the Azure side first, then Ringleader's use of it. Replace `<client-id>` with the application
client id.

1. Confirm that the federated credential accepts only Ringleader's tokens, for your organization:

   ```bash
   az ad app federated-credential list --id <client-id> \
     --query "[].{name:name, issuer:issuer, subject:subject, audiences:audiences}"
   ```

2. Confirm that the custom role has exactly the actions that
   [Microsoft Azure permissions and resources](https://docs-stg.ringleader.dev/reference/providers/azure-permissions/) lists.
   If you set a custom `ROLE_NAME`, pass that name instead of the default.

   ```bash
   az role definition list --name "Ringleader Workstation Operator" \
     --query "[0].permissions[0].actions" -o tsv
   ```

3. Confirm that the application holds that role on your resource group, and nothing else:

   ```bash
   az role assignment list --assignee <client-id> \
     --resource-group ringleader-workstations \
     --query "[].roleDefinitionName" -o tsv
   ```

4. After an administrator has created the CloudAccount and the CloudIdentity from the values you
   sent, wait for the CloudIdentity to be ready. Do this **before** anyone creates a workstation.
   Replace `azure` and `dev` with the CloudIdentity's name and namespace:

   ```bash
   rl cloudidentity wait azure -n dev --for Ready --timeout 2m
   ```

5. Read its status:

   ```bash
   rl cloudidentity get azure -n dev -o yaml
   ```

   `status.valid: true` means Ringleader can use the identity.

## Optional: Revoke Ringleader's access

Revoking removes Ringleader's ability to act in your resource group.
Skipping it keeps the access in place. Once you delete the federated credential or the application,
Ringleader can get no new Azure token. A token it already holds can work until it expires, usually
within 90 minutes.

To remove Ringleader's access but keep the application:

```bash
az ad app federated-credential delete --id <client-id> \
  --federated-credential-id ringleader-oidc
```

To remove the application entirely:

```bash
az ad app delete --id <client-id>
```

Both of these leave the custom role and its assignment behind. Delete them with
`az role assignment delete` and then `az role definition delete`, using your role name and the scope
`/subscriptions/<subscription-id>/resourceGroups/<resource-group>`. If your subscription also has a
role from an earlier setup,
[A role on your subscription](https://docs-stg.ringleader.dev/reference/providers/azure-permissions/#a-role-on-your-subscription)
shows how to delete it.

If you set up with Terraform, run `terraform destroy`, which removes everything it created.

<div class="callout callout-note">
  <p class="callout-title">There is no client-secret alternative</p>
  <div class="callout-body">
    Azure onboarding was once also possible with a <strong>client secret</strong> you created and
handed over. That path is <strong>retired</strong>: Ringleader stores no cloud credential, and a
<code>CloudIdentity</code> naming one is refused at apply. The keyless setup on this page is the
only one.
  </div>
</div>


## Troubleshoot

**If a workstation fails to create with `AADSTS700211: No matching federated identity record found`
on its status,** one of the three values Entra checks does not match. Compare them against what was
created, starting with the trailing slash. Entra compares the issuer character for character.
[Checks Entra makes](https://docs-stg.ringleader.dev/reference/providers/azure-permissions/#checks-entra-makes) lists the three
values.

**If every workstation fails to create,** and everything else looks right, the subscription feature is
probably not registered. Follow [Register the subscription feature](#register-the-subscription-feature).

**If a create returns `SkuNotAvailable`,** your region has no capacity for the VM size. Choose a
region that has it.

**If the deployment fails with `RoleDefinitionWithSameNameExists`,** a second onboarding in the same
tenant reused the default role name. Set `ROLE_NAME`, as the note under [ARM](#arm) shows.

**If Terraform stops with `Unsupported argument` on `enable_machine_type_list`,** your configuration
sets a switch the module no longer has. Delete it as
[A role on your subscription](https://docs-stg.ringleader.dev/reference/providers/azure-permissions/#a-role-on-your-subscription)
shows, then apply again.

**If `status.valid` is `false`,** Ringleader cannot use the identity. Run
`rl cloudidentity describe azure -n dev` to see why, replacing `azure` and `dev` with the
CloudIdentity's name and namespace. The usual causes are a wrong application client id or a mismatch
in one of the three values Entra checks.

## Next steps

- [Microsoft Azure permissions and resources](https://docs-stg.ringleader.dev/reference/providers/azure-permissions/) explains what onboarding created, what the role allows and what you handed back.
- [Cloud accounts and reachability](https://docs-stg.ringleader.dev/cloud-accounts/accounts-reachability/) explains who can reach your workstations, and how public addresses work.
- [Cloud runtime identities](https://docs-stg.ringleader.dev/cloud-accounts/cloud-identities/runtime-identities/) explains how to give workstations an Azure identity of their own.
- [Storage buckets](https://docs-stg.ringleader.dev/cloud-accounts/storage-buckets/) explains how to keep session transcripts and uploaded files in your resource group.

