> ## Documentation Index
> Fetch the complete documentation index at: https://docs.e6data.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Run e6data with least privilege

> Scope every e6data role on Azure to named resources, with nothing above resource-group scope.

How-to guideApplies to: CloudPrem on Azure

You can run e6data with every role scoped to named resources and nothing above resource-group scope. This setup has been verified end to end: cluster resume, a query, and the query in Query History.

The full permission lists live in [Permissions reference](https://docs.e6data.com/platform/deploy/azure-cloudprem/permissions-reference.md). This page covers how to narrow them.

## Requirements

* Your identity team creates every e6data role or identity itself. e6data never creates, changes or passes roles.
* Every role assignment is on a resource group or below (resource group, VNet, subnet, storage account). No Contributor, Network Contributor or other broad built-in role is held by an e6data identity.
* Wait a few minutes after assigning roles before you start the first cluster.

## What you can switch off or narrow

| Item | Azure | Can remove? | Effect |
| - | - | - | - |
| Subscription-level health-check role | Custom compute reader on the subscription | Yes | None seen. Health checks never block a cluster start |
| Network Contributor for the cluster | AKS cluster identity on the subnet | Yes. Replace with subnet read + join | None seen. New nodes joined the subnet |
| Broad roles for the node scaler | Karpenter identity: VM Contributor, Network Contributor, Managed Identity Operator, Reader | Yes. Replace with two custom roles (see [Permissions reference](https://docs.e6data.com/platform/deploy/azure-cloudprem/permissions-reference.md)) | None seen. Create, query and delete worked |
| Node scaler identity entirely | Use NAP. AKS node pools with the cluster autoscaler: not supported today | Yes, with NAP | No e6data Karpenter role |
| App role | Federated credentials for `-copilot`, `-metriq` | Yes, if you don't use them | Those features are off |
| Write access to the e6data metadata store | Storage Blob Data Contributor | No | e6data writes query history, results and metadata there |
| Contributor on the AKS node resource group | AKS cluster identity | No | AKS adds it itself; it is not an e6data role |

## Steps

**1. Create the resource group**

Create the resource group yourself and give e6data its name. e6data needs no subscription rights to create it.

**2. Create the custom role definitions**

Create the custom role definitions with your resource group (or node resource group) as the assignable scope, so nothing is defined on the subscription:

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "Name": "e6data-network-reader",
  "Actions": ["Microsoft.Network/virtualNetworks/read", "Microsoft.Network/virtualNetworks/subnets/read"],
  "AssignableScopes": ["/subscriptions/<SUB>/resourceGroups/<RG>"]
}
```

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "Name": "aks-subnet-access",
  "Actions": [
    "Microsoft.Network/virtualNetworks/read",
    "Microsoft.Network/virtualNetworks/subnets/read",
    "Microsoft.Network/virtualNetworks/subnets/join/action"
  ],
  "AssignableScopes": ["/subscriptions/<SUB>/resourceGroups/<RG>"]
}
```

If the VNet is in another resource group, add that resource group to `AssignableScopes` of `e6data-network-reader` and `aks-subnet-access`.

With e6data's Karpenter, also create `e6data-karpenter-node-rg` with the 24 actions in [Permissions reference](https://docs.e6data.com/platform/deploy/azure-cloudprem/permissions-reference.md), assignable at `<NODE_RG>`.

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
az role definition create --role-definition @e6data-network-reader.json
az role definition create --role-definition @aks-subnet-access.json
az role definition create --role-definition @e6data-karpenter-node-rg.json   # only with e6data's Karpenter
```

**3. Assign roles to the workspace identity**

Assign Storage Blob Data Contributor on the e6data storage account, Storage Blob Data Reader on each data storage account, and `e6data-network-reader` on the VNet. Don't assign the compute reader on the subscription.

**4. Narrow the AKS cluster identity**

Assign `aks-subnet-access` on the subnet, then remove Network Contributor at the scope it was granted: the VNet with e6data's install, or the subnet only when `az aks create` added it for your own subnet. Check with `az role assignment list` first:

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
CLUSTER_PRINCIPAL=$(az aks show -g <RG> -n <CLUSTER> --query identity.principalId -o tsv)
az role assignment create --assignee-object-id $CLUSTER_PRINCIPAL --assignee-principal-type ServicePrincipal \
  --role aks-subnet-access --scope <SUBNET_ID>
az role assignment list --assignee $CLUSTER_PRINCIPAL --role "Network Contributor" --all -o table
az role assignment delete --assignee $CLUSTER_PRINCIPAL --role "Network Contributor" --scope <SCOPE_FROM_LIST>
```

Leave the Contributor on the node resource group that AKS gave its own identity.

**5. Set up node scaling**

With NAP, do nothing more. With e6data's Karpenter, assign only `e6data-karpenter-node-rg` (node resource group) and `aks-subnet-access` (subnet) to the Karpenter identity.

**6. Wait before the first cluster start**

Wait a few minutes before starting the first cluster.

> [!WARNING]
>
> Azure role assignments take a few minutes to apply. A cluster started 29 seconds after a role change can fail with `E6_CLUSTER_CLOUD_PERMISSION_DENIED`. The same start a few minutes later works.

## Preflight check

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
for p in <workspace-principal-id> <cluster-principal-id> <karpenter-principal-id>; do
  az role assignment list --assignee $p --all --include-inherited -o table
done
```

Expected: no scope at subscription level, and no Contributor, Network Contributor, Virtual Machine Contributor or Managed Identity Operator on an e6data identity. Contributor on the node resource group for the AKS cluster identity is expected.

## Verify

1. Resume a cluster from the e6data console. It reaches **Running**.
2. Run a query in the SQL Editor, then check it appears in **Query History**.

## Troubleshooting

| Symptom | Cause | Fix |
| - | - | - |
| `E6_CLUSTER_CLOUD_PERMISSION_DENIED` on cluster start | New assignment not applied yet | Wait a few minutes and start again |

## Limitations

* Container-scoped roles (instead of storage-account scope): the metadata service runs with Storage Blob Data Contributor on its own container, and Storage Blob Data Reader on one lake container can read files over a private endpoint. Storage-account scope is the standard setup.

## See also

* [Permissions reference](https://docs.e6data.com/platform/deploy/azure-cloudprem/permissions-reference.md)
* [Organization policies](https://docs.e6data.com/platform/deploy/azure-cloudprem/organization-policies.md)
* [Node provisioning](https://docs.e6data.com/platform/deploy/azure-cloudprem/node-provisioning.md)
* [What e6data can access](https://docs.e6data.com/platform/trust/what-e6data-can-access.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.