Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Register Microsoft Entra ID apps and configure OAuth 2.0 authentication with MSAL integration.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
SKILL.md
1---2name: entra-app-registration3description: "Guides Microsoft Entra ID app registration, OAuth 2.0 authentication, and MSAL integration. USE FOR: create app registration, register Azure AD app, configure OAuth, set up authentication, add API permissions, generate service principal, MSAL example, console app auth, Entra ID setup, Azure AD authentication. DO NOT USE FOR: Azure RBAC or role assignments (use azure-rbac), Key Vault secrets (use azure-keyvault-expiration-audit), general Azure resource security guidance."4license: MIT5metadata:6author: Microsoft7version: "1.1.1"8---910## Overview1112Microsoft Entra ID (formerly Azure Active Directory) is Microsoft's cloud-based identity and access management service. App registrations allow applications to authenticate users and access Azure resources securely.1314### Key Concepts1516| Concept | Description |17|---------|-------------|18| **App Registration** | Configuration that allows an app to use Microsoft identity platform |19| **Application (Client) ID** | Unique identifier for your application |20| **Tenant ID** | Unique identifier for your Azure AD tenant/directory |21| **Client Secret** | Password for the application (confidential clients only) |22| **Redirect URI** | URL where authentication responses are sent |23| **API Permissions** | Access scopes your app requests |24| **Service Principal** | Identity created in your tenant when you register an app |2526### Application Types2728| Type | Use Case |29|------|----------|30| **Web Application** | Server-side apps, APIs |31| **Single Page App (SPA)** | JavaScript/React/Angular apps |32| **Mobile/Native App** | Desktop, mobile apps |33| **Daemon/Service** | Background services, APIs |3435## Core Workflow3637### Step 1: Register the Application3839Create an app registration in the Azure portal or using Azure CLI.4041**Portal Method:**421. Navigate to Azure Portal → Microsoft Entra ID → App registrations432. Click "New registration"443. Provide name, supported account types, and redirect URI454. Click "Register"4647**CLI Method:** See [references/cli-commands.md](references/cli-commands.md)48**IaC Method:** See [references/BICEP-EXAMPLE.bicep](references/BICEP-EXAMPLE.bicep)4950It's highly recommended to use the IaC to manage Entra app registration if you already use IaC in your project, need a scalable solution for managing lots of app registrations or need fine-grained audit history of the configuration changes.5152### Step 2: Configure Authentication5354Set up authentication settings based on your application type.5556- **Web Apps**: Add redirect URIs, enable ID tokens if needed57- **SPAs**: Add redirect URIs, enable implicit grant flow if necessary58- **Mobile/Desktop**: Use `http://localhost` or custom URI scheme59- **Services**: No redirect URI needed for client credentials flow6061### Step 3: Configure API Permissions6263Grant your application permission to access Microsoft APIs or your own APIs.6465**Common Microsoft Graph Permissions:**66- `User.Read` - Read user profile67- `User.ReadWrite.All` - Read and write all users68- `Directory.Read.All` - Read directory data69- `Mail.Send` - Send mail as a user7071**Details:** See [references/api-permissions.md](references/api-permissions.md)7273### Step 4: Create Client Credentials (if needed)7475For confidential client applications (web apps, services), create a client secret, certificate or federated identity credential.7677**Client Secret:**78- Navigate to "Certificates & secrets"79- Create new client secret80- Copy the value immediately (only shown once)81- Store securely (Key Vault recommended)8283**Certificate:** For production environments, use certificates instead of secrets for enhanced security. Upload certificate via "Certificates & secrets" section.8485**Federated Identity Credential:** For dynamically authenticating the confidential client to Entra platform.8687### Step 5: Implement OAuth Flow8889Integrate the OAuth flow into your application code.9091**See:**92- [references/oauth-flows.md](references/oauth-flows.md) - OAuth 2.0 flow details93- [references/console-app-example.md](references/console-app-example.md) - Console app implementation9495## Common Patterns9697### Pattern 1: First-Time App Registration9899Walk user through their first app registration step-by-step.100101**Required Information:**102- Application name103- Application type (web, SPA, mobile, service)104- Redirect URIs (if applicable)105- Required permissions106107**Script:** See [references/first-app-registration.md](references/first-app-registration.md)108109### Pattern 2: Console Application with User Authentication110111Create a .NET/Python/Node.js console app that authenticates users.112113**Required Information:**114- Programming language (C#, Python, JavaScript, etc.)115- Authentication library (MSAL recommended)116- Required permissions117118**Example:** See [references/console-app-example.md](references/console-app-example.md)119120### Pattern 3: Service-to-Service Authentication121122Set up daemon/service authentication without user interaction.123124**Required Information:**125- Service/app name126- Target API/resource127- Whether to use secret or certificate128129**Implementation:** Use Client Credentials flow (see [references/oauth-flows.md#client-credentials-flow](references/oauth-flows.md#client-credentials-flow))130131## MCP Tools and CLI132133### Azure CLI Commands134135| Command | Purpose |136|---------|---------|137| `az ad app create` | Create new app registration |138| `az ad app list` | List app registrations |139| `az ad app show` | Show app details |140| `az ad app permission add` | Add API permission |141| `az ad app credential reset` | Generate new client secret |142| `az ad sp create` | Create service principal |143144**Complete reference:** See [references/cli-commands.md](references/cli-commands.md)145146### Microsoft Authentication Library (MSAL)147148MSAL is the recommended library for integrating Microsoft identity platform.149150**Supported Languages:**151- .NET/C# - `Microsoft.Identity.Client`152- JavaScript/TypeScript - `@azure/msal-browser`, `@azure/msal-node`153- Python - `msal`154155**Examples:** See [references/console-app-example.md](references/console-app-example.md)156157## Security Best Practices158159| Practice | Recommendation |160|----------|---------------|161| **Never hardcode secrets** | Use environment variables, Azure Key Vault, or managed identity |162| **Rotate secrets regularly** | Set expiration, automate rotation |163| **Use certificates over secrets** | More secure for production |164| **Least privilege permissions** | Request only required API permissions |165| **Enable MFA** | Require multi-factor authentication for users |166| **Use managed identity** | For Azure-hosted apps, avoid secrets entirely |167| **Validate tokens** | Always validate issuer, audience, expiration |168| **Use HTTPS only** | All redirect URIs must use HTTPS (except localhost) |169| **Monitor sign-ins** | Use Entra ID sign-in logs for anomaly detection |170171## SDK Quick References172173- **Azure Identity**: [Python](references/sdk/azure-identity-py.md) | [.NET](references/sdk/azure-identity-dotnet.md) | [TypeScript](references/sdk/azure-identity-ts.md) | [Java](references/sdk/azure-identity-java.md) | [Rust](references/sdk/azure-identity-rust.md)174- **Key Vault (secrets)**: [Python](references/sdk/azure-keyvault-py.md) | [TypeScript](references/sdk/azure-keyvault-secrets-ts.md)175- **Auth Events**: [.NET](references/sdk/microsoft-azure-webjobs-extensions-authentication-events-dotnet.md)176177## References178179- [OAuth Flows](references/oauth-flows.md) - Detailed OAuth 2.0 flow explanations180- [CLI Commands](references/cli-commands.md) - Azure CLI reference for app registrations181- [Console App Example](references/console-app-example.md) - Complete working examples182- [First App Registration](references/first-app-registration.md) - Step-by-step guide for beginners183- [API Permissions](references/api-permissions.md) - Understanding and configuring permissions184- [Troubleshooting](references/troubleshooting.md) - Common issues and solutions185186## External Resources187188- [Microsoft Identity Platform Documentation](https://learn.microsoft.com/entra/identity-platform/)189- [OAuth 2.0 and OpenID Connect protocols](https://learn.microsoft.com/entra/identity-platform/v2-protocols)190- [MSAL Documentation](https://learn.microsoft.com/entra/msal/)191- [Microsoft Graph API](https://learn.microsoft.com/graph/)192