Lesson 2 of 3 Permissions, Authentication and Auditing

Passwordless Access with Microsoft Entra ID

This lesson explains Microsoft Entra authentication, managed identities, Entra-only authentication and workload identity federation for pipelines.

Learning outcomes

After completing this lesson, you will be able to:

  • Describe how Microsoft Entra principals become database users.
  • Distinguish between system-assigned and user-assigned managed identities.
  • Explain the connection string settings for passwordless access.

Microsoft Entra authentication

An Azure SQL logical server has a Microsoft Entra admin (a user or, better, a group), who can create database users for Microsoft Entra principals with CREATE USER [name] FROM EXTERNAL PROVIDER. The principal can be a user, a group, a service principal or a managed identity; groups simplify management because membership changes do not require database changes. These are contained database users, authenticated with a token from Microsoft Entra ID, so no password is stored in the database or the application. Microsoft Entra authentication brings multifactor authentication, Conditional Access and central account lifecycle management.

Microsoft Entra-only authentication disables SQL authentication on the server, so even the SQL administrator login cannot sign in, and an Azure Policy can require it for new servers. SQL database in Fabric uses Microsoft Entra authentication only.

True or false

Microsoft Entra authentication

Exam skills 2.1.5

Decide whether each statement about Entra authentication is true.

Log in to try this activity Interactive activities are free with an account.

Managed identities for applications

Applications on Azure, such as App Service, Azure Functions, Container Apps and VMs, use a managed identity: an identity that Azure creates and rotates, so the application never handles a secret. A system-assigned identity is tied to one resource's lifecycle; a user-assigned identity is a separate resource that several applications can share and that survives redeployment. The database user is created with the identity's name, and the application connects with a connection string such as the following.

Server=tcp:sql-contoso.database.windows.net,1433;Database=Inventory;
Authentication=Active Directory Default;Encrypt=True;

Active Directory Default uses DefaultAzureCredential, which tries environment credentials, managed identity, and developer tools such as the Azure CLI or Visual Studio in turn, so the same string works in Azure and on a developer's machine. Active Directory Managed Identity uses only the managed identity (with a client ID for a user-assigned identity).

Scenario questions

Choosing an identity

Exam skills 2.1.5

Choose the identity or connection setting for each case.

Log in to try this activity Interactive activities are free with an account.

Pipelines and other non-Azure workloads

CI/CD pipelines and workloads outside Azure use workload identity federation: a Microsoft Entra app registration or user-assigned managed identity trusts tokens from an external identity provider, such as GitHub Actions' OpenID Connect provider, for a specific repository, branch or environment. The pipeline exchanges its token for a Microsoft Entra token without any stored secret, then connects to the database with that identity. The following steps summarize a passwordless migration.

  1. Set a Microsoft Entra admin

    Assign a Microsoft Entra group as the server's admin.

  2. Create identity-based users

    Create users FROM EXTERNAL PROVIDER for app managed identities, pipeline identities and user groups, and grant roles.

  3. Change connection strings

    Switch applications to Active Directory Default or Managed Identity authentication.

  4. Remove passwords

    Drop SQL logins and contained users with passwords, then enable Microsoft Entra-only authentication.

Put in order

Going passwordless

Exam skills 2.1.5

Put the steps of a passwordless migration in order.

Log in to try this activity Interactive activities are free with an account.
Worked example

Removing a password from an App Service app

An App Service web app connects to Azure SQL Database with a SQL login whose password is in an app setting. Security requires removing all database passwords, and developers must still be able to run the app locally with their own accounts. What should the developer do?

Enable a managed identity on the App Service app, create a database user for it with CREATE USER [app-name] FROM EXTERNAL PROVIDER and grant the needed roles, change the connection string to Authentication=Active Directory Default, and create users for the developers' Microsoft Entra group. DefaultAzureCredential uses the managed identity in Azure and the developer's signed-in account locally. Moving the password to Key Vault protects it better but does not remove it.

Check yourself

Which statement creates a database user for a managed identity?

Show answer

CREATE USER [identity-name] FROM EXTERNAL PROVIDER, run by a Microsoft Entra-authenticated user.

Exam Tips

Remember for the exam

  • Database users for Entra principals: CREATE USER ... FROM EXTERNAL PROVIDER.
  • Disable SQL logins: Microsoft Entra-only authentication.
  • Same connection string locally and in Azure: Authentication=Active Directory Default.
  • Pipelines without secrets: workload identity federation (OIDC).