Managed identity in Azure, explained with Data Factory

What a managed identity is, system-assigned or user-assigned, and how Azure Data Factory signs in to storage, Azure SQL and Key Vault with no password.

Short answer: a managed identity is an identity in Microsoft Entra ID that Azure creates and looks after for a resource, such as a data factory. The resource signs in as itself, so there is no password or key to store, rotate or leak. You give the identity a role on the storage account, a user in the database or access to Key Vault, and the linked service uses it.

Every key in a connection string is a secret someone can copy. A managed identity removes the secret: Azure hands the factory a short-lived token whenever it needs one.

System-assigned or user-assigned?

System-assigned
  • created with the resource and deleted with it
  • one per resource
  • a data factory has one, named like the factory
User-assigned
  • a resource of its own
  • several services can share it
  • survives when a service is deleted
Two kinds of managed identity

For one data factory, the system-assigned identity is simplest. A user-assigned identity helps when several services need the same access, or when the access must be granted before the service exists.

How does the factory get access?

  1. 1
    Data factorysigns in as its managed identity
  2. 2
    Storagea role such as Storage Blob Data Contributor
  3. 3
    Azure SQLa database user made from the identity
  4. 4
    Key Vaulta role such as Key Vault Secrets User
One identity, three kinds of access

In Azure SQL Database, an Entra admin creates a user for the factory and gives it roles:

CREATE USER [adf-sales-prod] FROM EXTERNAL PROVIDER;
ALTER ROLE db_datareader ADD MEMBER [adf-sales-prod];
ALTER ROLE db_datawriter ADD MEMBER [adf-sales-prod];

The linked service then names no password: its authentication type is System-assigned managed identity.

What goes wrong?

  • The role is granted on the wrong level. Owner or Contributor on a storage account manages the account but does not read the data. Data access needs a Storage Blob Data role.
  • The role takes a while. A new role assignment can take a few minutes to apply. A test right after granting can fail and then pass.
  • Too much access. Give the identity the narrowest role on the narrowest scope: a container, not the subscription.
  • Development and production share one identity. Each factory has its own; grant each one only its own environment.

Where can you check this?

Where do you start?

Release Data Factory pipelines like code keeps the remaining secrets in Key Vault, and the open course Upserts into Azure SQL loads a database the factory can sign in to this way.

Keep reading

More from the blog.

Every post

Next

Building this? Say hello.

A question about this post, a pattern you would build differently, or the next thing you want written out: Behnia reads every message.