# Microsoft Azure permissions and resources

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


> What Azure onboarding creates in your Entra tenant and resource group, what Ringleader may do with it, and the values you hand back.


Azure onboarding creates an identity for Ringleader in your Entra tenant, and a custom role and
its assignment in one of your resource groups. This page lists what onboarding creates, what the
role allows, what Entra checks when Ringleader signs in, and the values you hand back. The steps
are in [Onboard Microsoft Azure](https://docs-stg.ringleader.dev/guides/onboard-azure/).

## Resources onboarding creates

*Diagram: Ringleader signs a short-lived OIDC token whose issuer and subject name your organization and presents it as the client assertion for your Entra application. A federated identity credential on that application trusts only that issuer, subject and audience, and issues a token for a service principal holding a custom role, whose base actions are narrower than built-in Contributor's. That principal creates, manages and deletes workstation VMs in one resource group.*

```mermaid
flowchart TB
  CP["<b>Ringleader control plane</b><br/>signs a short-lived OIDC token<br/>iss = &lt;issuer&gt;/org/&lt;your-org-id&gt;<br/>sub = org:&lt;your-org-id&gt;<br/>and presents it as the client assertion"]

  subgraph tenant["Your Entra tenant"]
    direction TB
    FIC["<b>Federated identity credential</b><br/>on your Entra app<br/>trusts only that issuer, subject and audience"]
    SP["<b>Service principal</b><br/>holding a <i>custom</i> role whose base actions<br/>are narrower than built-in Contributor's"]
    VMs["<b>Workstation VMs</b><br/>created, managed and deleted<br/>in ONE resource group"]
  end

  CP -- "presents the client assertion" --> FIC
  FIC -- "issues a token for" --> SP
  SP --> VMs
```


Onboarding creates two things in your Entra tenant:

- An **app registration** called `ringleader-workstations`, with its service
  principal. This is the identity Ringleader signs in as.
- A **federated credential** on that application. This is how Entra confirms that a sign-in
  really comes from Ringleader and is meant for your organization, without a client
  secret.

It creates two or three more in your resource group, all visible in the Azure portal
afterwards:

- A **custom role** called `Ringleader Workstation Operator`. It lets the holder
  create, start, stop and delete VMs and their disks and network interfaces, and
  nothing else. [Custom role actions](#custom-role-actions) lists them.
- A **role assignment** giving that role to the application, on this resource group only.
- Optionally, a **network** for the workstations: a virtual network, a subnet, a NAT
  gateway with its public IP, and a network security group (NSG). Both paths create it
  unless you turn it off (`create_network = false` or `CREATE_NETWORK=false`).

## Rights and limits in your resource group

Ringleader can manage VMs in this one resource group. Built-in Contributor can touch every kind
of resource in a group, and the custom role lists only what running workstations takes. The role
is assigned only within your resource group, and onboarding grants Ringleader nothing outside it.
[Cloud accounts](https://docs-stg.ringleader.dev/cloud-accounts/) says what Ringleader gets and what it
never gets.

Three features are on by default and add to it:
[Cloud runtime identities](https://docs-stg.ringleader.dev/cloud-accounts/cloud-identities/runtime-identities/),
[Egress control permissions](#egress-control-permissions) and
[Storage buckets](https://docs-stg.ringleader.dev/cloud-accounts/storage-buckets/).
[Setup switches](#setup-switches) lists how to turn each off.

## Custom role actions

The custom role allows these actions in your resource group:

- `Microsoft.Compute/virtualMachines/*`: read/write/delete and power operations
- `Microsoft.Compute/disks/*`: the OS-disk lifecycle
- `Microsoft.Network/networkInterfaces/*` and `publicIPAddresses/*`: the per-VM NIC and optional public IP
- `Microsoft.Network/virtualNetworks/subnets/{read,join/action}`: place a NIC on the workstation subnet (never modify the vnet)
- `Microsoft.Resources/tags/write`: keep VM tags up to date
- read-only size / usage / resource-group introspection

<div class="callout callout-note">
  <p class="callout-title">If you write your own role: keep the tags action</p>
  <div class="callout-body">
    Azure updates a VM&rsquo;s tags through a separate action from <code>virtualMachines/write</code>.
Leave out <code>Microsoft.Resources/tags/write</code> and workstations start fine, and then
every later tag update fails with a permission error, possibly weeks afterwards.
Built-in Contributor happens to include it; a narrower role must list it.
  </div>
</div>


## Checks Entra makes

When Ringleader signs in as your application, Entra checks three things about the token it
presents. The first two are built from the two values Ringleader gave you; the third is
a fixed value Microsoft documents. The module and the script configure all three, so
you never type them yourself unless you use the portal.

| What Entra checks | Value | Where it is configured |
|---|---|---|
| Who signed the token | `<issuer-url>/org/<org-id>` | the federated credential's **Issuer** |
| Which organization it speaks for | `org:<org-id>` | the federated credential's **Subject identifier** |
| What the token may be used for | `api://AzureADTokenExchange` | the federated credential's **Audience** |

[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 do when a value does not match, and the
[Troubleshoot](https://docs-stg.ringleader.dev/guides/onboard-azure/#troubleshoot) section of the guide shows
the error that a mismatch causes.

## Egress control permissions

Egress control narrows where a workstation may connect to a list you choose per workstation, so a
workstation can reach GitHub and your package registry and nothing else.
[Outbound restrictions](https://docs-stg.ringleader.dev/security/outbound/outbound-restrictions/) explains it.
Network security groups that Ringleader creates enforce it, and keep them in step with the
workstation's configuration.

It is **on by default**. It also lets Ringleader write the rule that admits SSH to your
workstations, and the NSG on the network interface of each workstation with no egress policy.
[Enforcement points](https://docs-stg.ringleader.dev/security/outbound/enforcement/) explains the two NSGs and
which one is yours. With egress control turned off, your workstations are reachable only through a
rule of your own. A workstation with no egress policy still has no limit on where it connects. Turn
it off with `enable_egress_control = false` (Terraform) or `EGRESS_CONTROL=0` (ARM).

It adds twenty-three actions to the custom role, still scoped to your one resource group.
A resource group onboarded with an earlier version of the module or template lacks the five
application security group actions: apply the current version again to add them.

| Action | For |
|---|---|
| `Microsoft.Network/networkSecurityGroups/{read,write,delete}` | one NSG per distinct egress policy, and the one NSG shared by workstations with no policy |
| `.../networkSecurityGroups/securityRules/{read,write,delete}` | keep a policy NSG's rules in step with the workstation's configuration, and write the SSH rule in your subnet's NSG |
| `Microsoft.Network/networkSecurityGroups/join/action` | attach the NSG to a workstation's network interface |
| `Microsoft.Network/routeTables/*` (with `routes/*` and `join/action`) | route traffic to the edge instance, for a policy that names hostnames |
| `Microsoft.Network/virtualNetworks/subnets/{write,delete}` | attach the route table to a subnet and detach it again, which in Azure is a write of the whole subnet. A route table attaches per subnet, so routing is per subnet rather than per workstation. Ringleader never creates or deletes a subnet |
| `Microsoft.Resources/subscriptions/resourcegroups/resources/read` | list the resource group's contents, so Ringleader can find and remove an edge instance's VM and its public IP that outlived their Edge; without it you keep paying for both |
| `Microsoft.Network/natGateways/read` | see whether a subnet already has an outbound path, before giving an edge instance's VM a public address of its own |
| `Microsoft.Network/applicationSecurityGroups/{read,write,delete}`, `.../joinIpConfiguration/action` and `.../joinNetworkSecurityRule/action` | create the group Ringleader puts each workstation's network interface in, which the SSH rule it writes in your subnet's security group names |

Each distinct policy becomes **one** NSG shared by every workstation on that policy,
rather than one per workstation. Azure caps an NSG at 1,000 rules and will not raise
it, so one per workstation would not scale to a fleet.

Routing by subnet asks two things of your network, and the reserved subnets that
`create_governed_subnet` and `create_gateway_subnet` create are part of that.
[Edge management](https://docs-stg.ringleader.dev/security/outbound/edge-management/) explains them.

## VM sizes

When a person creates a workstation, Ringleader shows the VM sizes your subscription may use in the
workstation's region, so they pick a size the subscription allows. A listed size can still fail to
create when the region is out of capacity or you are over quota.

### A role on your subscription

An earlier version of onboarding also created a custom role on your subscription, named
`Ringleader Workstation Operator Machine Types`, or your own role name followed by `Machine Types`.
It only let Ringleader read the list of VM sizes. Ringleader reads the list without it, so you can
remove the role. Leaving it in place is harmless. Removing it takes **Owner** or **User Access
Administrator** on the subscription.

- **Terraform:** delete `enable_machine_type_list` and move to the current version of the module,
  then run `terraform apply`. The apply deletes the role and its assignment. The module no longer
  has that setting, so Terraform stops with an error while your `module` block sets it, even to
  `false`.
  - If you run `examples/standalone` from a clone of
    [github.com/ringleader-dev/cloud-onboarding](https://github.com/ringleader-dev/cloud-onboarding),
    `git pull` does both. If your `terraform.tfvars` sets it, delete that line too.
  - If your module's `source` is that repository's URL, delete the argument, change the `?ref=` if
    the URL has one, and run `terraform get -update`.
- **`deploy.sh`, or the ARM template by itself:** the current version leaves the role in place, so
  delete it yourself. If you set `ROLE_NAME`, put your role name followed by `Machine Types` in
  `ROLE`. Run the last three commands once for each `ROLE_NAME` you onboarded with.

  ```bash
  SUBSCRIPTION="/subscriptions/$(az account show --query id -o tsv)"
  ROLE="Ringleader Workstation Operator Machine Types"
  az role assignment delete --role "$ROLE" --scope "$SUBSCRIPTION"
  az role definition delete --name "$ROLE" --scope "$SUBSCRIPTION"
  ```

## Setup switches

Each of the three features is on until you turn it off when you apply the setup. Nothing
else changes when you do.

| Default | Terraform | ARM |
|---|---|---|
| Runtime identities | `enable_workstation_identities = false` | `WORKSTATION_IDENTITIES=0 ./deploy.sh` |
| Egress control | `enable_egress_control = false` | `EGRESS_CONTROL=0` |
| Artifact storage | `enable_artifact_storage = false` | the `enableArtifactStorage` template parameter set to false, which `deploy.sh` passes through |

With runtime identities off, a workstation that asks for its own identity fails with a
`403` error rather than silently getting nothing.
[Turn off runtime identities](https://docs-stg.ringleader.dev/cloud-accounts/cloud-identities/runtime-identities/#turn-off-runtime-identities)
says more.

## Values you hand back

| Value | How to get it | Where it lands |
|---|---|---|
| **application client id** | printed by `deploy.sh` / `terraform output` | [CloudAccount](https://docs-stg.ringleader.dev/reference/resources/cloudaccount/) `spec.azure.targetAppClientId` |
| **tenant id** | `az account show --query tenantId -o tsv` | `spec.azure.tenant` |
| **subscription id** | `az account show --query id -o tsv` | [CloudIdentity](https://docs-stg.ringleader.dev/reference/resources/cloudidentity/) `providerConfig.azure.subscriptionId` |
| **resource group**, **location** | the ones you used | `providerConfig.azure.resourceGroup`, `.location` |
| **subnet id** (only if you created the network) | printed by `deploy.sh` / `terraform output handoff` | `providerConfig.azure.subnetId` |

[Send the values to your organization administrator](https://docs-stg.ringleader.dev/guides/onboard-azure/#send-the-values-to-your-organization-administrator)
says who receives them.

## Next steps

- [Onboard Microsoft Azure](https://docs-stg.ringleader.dev/guides/onboard-azure/): set up the identity, the role and
  the credential, and check them.
- [Cloud accounts](https://docs-stg.ringleader.dev/cloud-accounts/): how onboarding fits the rest of your cloud
  setup.

