Lesson 3 of 3 Identity and Access Management for Workspaces

Managed Identities for Workspaces and Compute

This lesson explains system-assigned and user-assigned identities and how the workspace, compute, jobs and endpoints use them to reach other resources.

Learning outcomes

After completing this lesson, you will be able to:

  • Distinguish system-assigned from user-assigned identities.
  • Explain what a user-assigned workspace identity requires.
  • Describe the user_identity and managed job identity types.
  • Identify the roles an endpoint identity needs.

System-assigned and user-assigned identities

A managed identity is an identity in Microsoft Entra ID whose credentials Azure manages. A system-assigned identity is created with a resource and deleted with it, and belongs to that one resource. A user-assigned identity is a separate resource that can be attached to several resources and survives when they are deleted.

System-assigned
LifetimeTied to the resource
SharingOne resource only
Role assignmentsMade after the resource exists
Typical useOne workspace or endpoint with its own rights
Choose when Simplicity for one resource
User-assigned
LifetimeIndependent resource
SharingMany resources
Role assignmentsCan be made before the resource is created
Typical useSeveral clusters or endpoints with the same rights, or infrastructure as code that needs roles in place first
Choose when Shared or pre-authorized identities

User-assigned identities suit infrastructure as code well, because the identity and its role assignments can be deployed before the workspace or endpoint that uses them, which avoids failures while role assignments propagate.

The workspace identity

The workspace uses its managed identity to reach its dependent resources: the storage account, key vault and container registry. With a system-assigned identity, Azure grants the needed roles automatically when the workspace is created. With a user-assigned identity, you must grant the identity roles on those resources yourself, which gives more control, for example when the resources are shared or governed by another team.

The workspace identity is also used for some operations on behalf of users, such as accessing the default datastores when they use credential-based access. Changing the identity type of an existing workspace is possible in some cases but requires the new identity to have every role the old one had, so the choice is best made when the workspace is designed.

Compute and job identities

Compute instances and clusters can have their own managed identity, set at creation with --identity-type or in YAML. A job's identity setting decides which identity it uses to access data: user_identity runs with the identity of the user who submitted it, and managed runs with the managed identity of the compute (or, for serverless compute, a user-assigned identity of the workspace).

$schema: https://azuremlschemas.azureedge.net/latest/commandJob.schema.json
command: python prep.py --raw ${{inputs.raw}} --out ${{outputs.clean}}
code: ./src
environment: azureml:prep-env:4
compute: azureml:cpu-cluster
identity:
  type: managed
inputs:
  raw:
    type: uri_folder
    path: azureml://datastores/sales_lake/paths/raw/
outputs:
  clean:
    type: uri_folder

user_identity keeps data access personal, which suits interactive development and data that each user may see differently. managed suits scheduled and automated jobs, which should not depend on any one person's permissions or continued employment.

Endpoint identities

A managed online endpoint has a managed identity that its deployments use to pull the environment image from the container registry and download the model from storage. With the default system-assigned identity, Azure grants these roles automatically. With a user-assigned identity, you grant AcrPull on the registry and Storage Blob Data Reader on the storage yourself, before creating the deployment.

The scoring script can use the same identity to call other services, such as a feature store, a database or Azure Key Vault, through DefaultAzureCredential. Clients that call the endpoint authenticate separately: with a key, an Azure Machine Learning token or a Microsoft Entra token, depending on the endpoint's auth_mode; Microsoft Entra authentication (aad_token) lets callers use their own managed identities and Azure roles.

Worked example

Identities for a scheduled pipeline

A nightly pipeline prepares data from a data lake, trains a model and writes predictions to a second container. It currently runs with the identity of the data scientist who created the schedule, and it failed last week after that person left the company. The team wants the pipeline to keep running regardless of staffing changes, with access to only the two containers.

Create a user-assigned managed identity, grant it Storage Blob Data Reader on the source container and Storage Blob Data Contributor on the output container, attach it to the compute cluster, and set the pipeline's jobs to identity: type: managed. The pipeline then runs with an identity that does not belong to any person and has only the access it needs.

Running the schedule under another data scientist's account repeats the original problem. Granting the cluster's identity Contributor on the storage account would not provide data access through Microsoft Entra ID and exceeds the need. Switching the datastores to account keys removes the dependency on a person by adding a stored secret.

Check yourself

Why might a team choose a user-assigned managed identity for its workspace instead of the system-assigned one?

Show answer

A user-assigned identity exists independently, so its role assignments can be granted in advance, by a separate team, and survive recreating the workspace. The team must then grant the roles on dependent resources itself.

Exam Tips

Remember for the exam

  • System-assigned identities live and die with the resource; user-assigned identities are shared and independent.
  • With a user-assigned workspace identity, you grant the roles on dependent resources yourself.
  • A job's identity type is user_identity or managed.
  • A user-assigned endpoint identity needs AcrPull and Storage Blob Data Reader granted in advance.