Sub topic 18
Permissions and the run-as identity
This chapter assumes you can create a job, schedule it, and read a job definition in JSON or YAML. It covers two separate questions. Who may see or control a job? And whose identity does the job use when it reads data and starts compute?
Two different questions
Job permissions control what people can do to the job object. The run-as identity controls what the running tasks can do. A user with permission to start a job does not lend their own data access to it. The tasks use the run-as identity's access.
Job permission levels
| Level | What it allows |
|---|---|
| CAN VIEW | See the job and its run results |
| CAN MANAGE RUN | Everything in CAN VIEW, plus Run now and canceling runs |
| CAN MANAGE | Everything in CAN MANAGE RUN, plus editing settings and permissions, and deleting the job |
| IS OWNER | Same as CAN MANAGE. Each job has exactly one owner, and the owner must be a user or service principal, not a group |
Grant levels to groups where you can. That way you manage membership in one place instead of editing every job.
The run-as identity
By default a job runs as the user who created it. That causes two problems. If the creator leaves or loses access, the schedule starts failing. And the job runs with that person's broad permissions instead of the minimum it needs.
A common fix is to set run-as to a service principal. A service principal is an identity for automation that is not tied to a person. Give it only the access the pipeline needs: the catalogs and tables it reads and writes, the notebooks, and the compute policy.
To set run-as to a service principal, you need the Service Principal User role on it. You can also set run-as to another user, but only to yourself unless you are a workspace admin.
Setting both in a bundle
Declare permissions and run-as next to the job so a code review covers them. The application ID below is a placeholder, so replace it with your service principal's.
resources:
jobs:
daily_sales:
name: daily-sales-pipeline
run_as:
service_principal_name: "12345678-aaaa-bbbb-cccc-1234567890ab"
permissions:
- group_name: data-team
level: CAN_MANAGE
- group_name: analysts
level: CAN_VIEW
tasks:
- task_key: ingest
notebook_task:
notebook_path: ../src/ingest.ipynbCompute settings are omitted, as in the earlier bundle example.
Common errors
- A run fails with a permission error on a table, even though you can query it. Your own access is irrelevant. Grant the run-as identity access.
- The run-as service principal cannot open the notebook. Give it at least CAN READ on the notebook or its folder.
- You cannot set run-as to a service principal. You are probably missing the Service Principal User role on it.
- A teammate sees the job but has no Run now button. They have CAN VIEW and need CAN MANAGE RUN.
Exercise
An analyst has CAN MANAGE RUN on a job that runs as a service principal. The analyst cannot read the table the job writes. Can the analyst still start the job, and whose access decides whether the write succeeds?
Show answer
Yes. CAN MANAGE RUN allows Run now. The write succeeds or fails based on the run-as service principal's access to the table, not the analyst's.