[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M69AP9RW5751W3W92AS132RA":3,"skill-same:01M69AP9RW5751W3W92AS132RA":70},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":39,"linkOnly":40,"markdownContent":41,"markdownBody":42,"frontMatter":43,"refName":46,"commitSha":47,"skillDirectory":48,"forksCount":49,"repositoryHtmlUrl":50,"repositoryHomepageUrl":51,"ownerHtmlUrl":52,"ownerBlogUrl":53,"ownerDescription":54,"updatedAt":55,"install":56,"resources":69},"01M69AP9RW5751W3W92AS132RA","microsoft-azure-webjobs-extensions-authentication-events-dotnet",null,"Microsoft Entra Authentication Events SDK for .NET. Azure Functions triggers for custom authentication extensions. Use for token enrichment, custom claims, attribute collection, and OTP customization in Entra ID. Triggers: \"Authentication Events\", \"WebJobsAuthenticationEventsTrigger\", \"OnTokenIssuanceStart\", \"OnAttributeCollectionStart\", \"custom claims\", \"token enrichment\", \"Entra custom extension\", \"authentication extension\".","microsoft\u002Fskills","microsoft","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F6154722?v=4","01M698VYDXZ6JW5WH3CRV650R8","Microsoft","01M69AJYYW4E1RMSYCQDJ4FJSH",3202,"MIT","https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Fskills\u002Fblob\u002Fmain\u002F.github\u002Fplugins\u002Fazure-sdk-dotnet\u002Fskills\u002Fmicrosoft-azure-webjobs-extensions-authentication-events-dotnet\u002FSKILL.md",[],[9,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38],"dotnet","azure","microsoft azure webjobs extensions authentication events dotnet","authentication","extensions","microsoft azure webjobs extensions authentication","events","custom claims","sdk","custom","for","claims","otp","id","triggers","token","functions","use","collection","entra id","2026-11-10 10:12:30",false,"---\nname: microsoft-azure-webjobs-extensions-authentication-events-dotnet\ndescription: 'Microsoft Entra Authentication Events SDK for .NET. Azure Functions triggers for custom authentication extensions. Use for token enrichment, custom claims, attribute collection, and OTP customization in Entra ID. Triggers: \"Authentication Events\", \"WebJobsAuthenticationEventsTrigger\", \"OnTokenIssuanceStart\", \"OnAttributeCollectionStart\", \"custom claims\", \"token enrichment\", \"Entra custom extension\", \"authentication extension\".'\nlicense: MIT\nmetadata:\n  author: Microsoft\n  version: \"1.0.0\"\n---\n\n# Microsoft.Azure.WebJobs.Extensions.AuthenticationEvents (.NET)\n\nAzure Functions extension for handling Microsoft Entra ID custom authentication events.\n\n## Installation\n\n```bash\ndotnet add package Microsoft.Azure.WebJobs.Extensions.AuthenticationEvents\n```\n\n**Current Version**: v1.1.0 (stable)\n\n## Supported Events\n\n| Event | Purpose |\n|-------|---------|\n| `OnTokenIssuanceStart` | Add custom claims to tokens during issuance |\n| `OnAttributeCollectionStart` | Customize attribute collection UI before display |\n| `OnAttributeCollectionSubmit` | Validate\u002Fmodify attributes after user submission |\n| `OnOtpSend` | Custom OTP delivery (SMS, email, etc.) |\n\n## Core Workflows\n\n### 1. Token Enrichment (Add Custom Claims)\n\nAdd custom claims to access or ID tokens during sign-in.\n\n```csharp\nusing Microsoft.Azure.WebJobs;\nusing Microsoft.Azure.WebJobs.Extensions.AuthenticationEvents;\nusing Microsoft.Azure.WebJobs.Extensions.AuthenticationEvents.TokenIssuanceStart;\nusing Microsoft.Extensions.Logging;\n\npublic static class TokenEnrichmentFunction\n{\n    [FunctionName(\"OnTokenIssuanceStart\")]\n    public static WebJobsAuthenticationEventResponse Run(\n        [WebJobsAuthenticationEventsTrigger] WebJobsTokenIssuanceStartRequest request,\n        ILogger log)\n    {\n        log.LogInformation(\"Token issuance event for user: {UserId}\", \n            request.Data?.AuthenticationContext?.User?.Id);\n\n        \u002F\u002F Create response with custom claims\n        var response = new WebJobsTokenIssuanceStartResponse();\n        \n        \u002F\u002F Add claims to the token\n        response.Actions.Add(new WebJobsProvideClaimsForToken\n        {\n            Claims = new Dictionary\u003Cstring, string>\n            {\n                { \"customClaim1\", \"customValue1\" },\n                { \"department\", \"Engineering\" },\n                { \"costCenter\", \"CC-12345\" },\n                { \"apiVersion\", \"v2\" }\n            }\n        });\n\n        return response;\n    }\n}\n```\n\n### 2. Token Enrichment with External Data\n\nFetch claims from external systems (databases, APIs).\n\n```csharp\nusing Microsoft.Azure.WebJobs;\nusing Microsoft.Azure.WebJobs.Extensions.AuthenticationEvents;\nusing Microsoft.Azure.WebJobs.Extensions.AuthenticationEvents.TokenIssuanceStart;\nusing Microsoft.Extensions.Logging;\nusing System.Net.Http;\nusing System.Text.Json;\n\npublic static class TokenEnrichmentWithExternalData\n{\n    private static readonly HttpClient _httpClient = new();\n\n    [FunctionName(\"OnTokenIssuanceStartExternal\")]\n    public static async Task\u003CWebJobsAuthenticationEventResponse> Run(\n        [WebJobsAuthenticationEventsTrigger] WebJobsTokenIssuanceStartRequest request,\n        ILogger log)\n    {\n        string? userId = request.Data?.AuthenticationContext?.User?.Id;\n        \n        if (string.IsNullOrEmpty(userId))\n        {\n            log.LogWarning(\"No user ID in request\");\n            return new WebJobsTokenIssuanceStartResponse();\n        }\n\n        \u002F\u002F Fetch user data from external API\n        var userProfile = await GetUserProfileAsync(userId);\n        \n        var response = new WebJobsTokenIssuanceStartResponse();\n        response.Actions.Add(new WebJobsProvideClaimsForToken\n        {\n            Claims = new Dictionary\u003Cstring, string>\n            {\n                { \"employeeId\", userProfile.EmployeeId },\n                { \"department\", userProfile.Department },\n                { \"roles\", string.Join(\",\", userProfile.Roles) }\n            }\n        });\n\n        return response;\n    }\n\n    private static async Task\u003CUserProfile> GetUserProfileAsync(string userId)\n    {\n        var response = await _httpClient.GetAsync($\"https:\u002F\u002Fapi.example.com\u002Fusers\u002F{userId}\");\n        response.EnsureSuccessStatusCode();\n        var json = await response.Content.ReadAsStringAsync();\n        return JsonSerializer.Deserialize\u003CUserProfile>(json)!;\n    }\n}\n\npublic record UserProfile(string EmployeeId, string Department, string[] Roles);\n```\n\n### 3. Attribute Collection - Customize UI (Start Event)\n\nCustomize the attribute collection page before it's displayed.\n\n```csharp\nusing Microsoft.Azure.WebJobs;\nusing Microsoft.Azure.WebJobs.Extensions.AuthenticationEvents;\nusing Microsoft.Azure.WebJobs.Extensions.AuthenticationEvents.Framework;\nusing Microsoft.Extensions.Logging;\n\npublic static class AttributeCollectionStartFunction\n{\n    [FunctionName(\"OnAttributeCollectionStart\")]\n    public static WebJobsAuthenticationEventResponse Run(\n        [WebJobsAuthenticationEventsTrigger] WebJobsAttributeCollectionStartRequest request,\n        ILogger log)\n    {\n        log.LogInformation(\"Attribute collection start for correlation: {CorrelationId}\",\n            request.Data?.AuthenticationContext?.CorrelationId);\n\n        var response = new WebJobsAttributeCollectionStartResponse();\n\n        \u002F\u002F Option 1: Continue with default behavior\n        response.Actions.Add(new WebJobsContinueWithDefaultBehavior());\n\n        \u002F\u002F Option 2: Prefill attributes\n        \u002F\u002F response.Actions.Add(new WebJobsSetPrefillValues\n        \u002F\u002F {\n        \u002F\u002F     Attributes = new Dictionary\u003Cstring, string>\n        \u002F\u002F     {\n        \u002F\u002F         { \"city\", \"Seattle\" },\n        \u002F\u002F         { \"country\", \"USA\" }\n        \u002F\u002F     }\n        \u002F\u002F });\n\n        \u002F\u002F Option 3: Show blocking page (prevent sign-up)\n        \u002F\u002F response.Actions.Add(new WebJobsShowBlockPage\n        \u002F\u002F {\n        \u002F\u002F     Message = \"Sign-up is currently disabled.\"\n        \u002F\u002F });\n\n        return response;\n    }\n}\n```\n\n### 4. Attribute Collection - Validate Submission (Submit Event)\n\nValidate and modify attributes after user submission.\n\n```csharp\nusing Microsoft.Azure.WebJobs;\nusing Microsoft.Azure.WebJobs.Extensions.AuthenticationEvents;\nusing Microsoft.Azure.WebJobs.Extensions.AuthenticationEvents.Framework;\nusing Microsoft.Extensions.Logging;\n\npublic static class AttributeCollectionSubmitFunction\n{\n    [FunctionName(\"OnAttributeCollectionSubmit\")]\n    public static WebJobsAuthenticationEventResponse Run(\n        [WebJobsAuthenticationEventsTrigger] WebJobsAttributeCollectionSubmitRequest request,\n        ILogger log)\n    {\n        var response = new WebJobsAttributeCollectionSubmitResponse();\n\n        \u002F\u002F Access submitted attributes\n        var attributes = request.Data?.UserSignUpInfo?.Attributes;\n        \n        string? email = attributes?[\"email\"]?.ToString();\n        string? displayName = attributes?[\"displayName\"]?.ToString();\n\n        \u002F\u002F Validation example: block certain email domains\n        if (email?.EndsWith(\"@blocked.com\") == true)\n        {\n            response.Actions.Add(new WebJobsShowBlockPage\n            {\n                Message = \"Sign-up from this email domain is not allowed.\"\n            });\n            return response;\n        }\n\n        \u002F\u002F Validation example: show validation error\n        if (string.IsNullOrEmpty(displayName) || displayName.Length \u003C 3)\n        {\n            response.Actions.Add(new WebJobsShowValidationError\n            {\n                Message = \"Display name must be at least 3 characters.\",\n                AttributeErrors = new Dictionary\u003Cstring, string>\n                {\n                    { \"displayName\", \"Name is too short\" }\n                }\n            });\n            return response;\n        }\n\n        \u002F\u002F Modify attributes before saving\n        response.Actions.Add(new WebJobsModifyAttributeValues\n        {\n            Attributes = new Dictionary\u003Cstring, string>\n            {\n                { \"displayName\", displayName.Trim() },\n                { \"city\", attributes?[\"city\"]?.ToString()?.ToUpperInvariant() ?? \"\" }\n            }\n        });\n\n        return response;\n    }\n}\n```\n\n### 5. Custom OTP Delivery\n\nSend one-time passwords via custom channels (SMS, email, push notification).\n\n```csharp\nusing Microsoft.Azure.WebJobs;\nusing Microsoft.Azure.WebJobs.Extensions.AuthenticationEvents;\nusing Microsoft.Azure.WebJobs.Extensions.AuthenticationEvents.Framework;\nusing Microsoft.Extensions.Logging;\n\npublic static class CustomOtpFunction\n{\n    [FunctionName(\"OnOtpSend\")]\n    public static async Task\u003CWebJobsAuthenticationEventResponse> Run(\n        [WebJobsAuthenticationEventsTrigger] WebJobsOnOtpSendRequest request,\n        ILogger log)\n    {\n        var response = new WebJobsOnOtpSendResponse();\n\n        string? phoneNumber = request.Data?.OtpContext?.Identifier;\n        string? otp = request.Data?.OtpContext?.OneTimeCode;\n\n        if (string.IsNullOrEmpty(phoneNumber) || string.IsNullOrEmpty(otp))\n        {\n            log.LogError(\"Missing phone number or OTP\");\n            response.Actions.Add(new WebJobsOnOtpSendFailed\n            {\n                Error = \"Missing required data\"\n            });\n            return response;\n        }\n\n        try\n        {\n            \u002F\u002F Send OTP via your SMS provider\n            await SendSmsAsync(phoneNumber, $\"Your verification code is: {otp}\");\n            \n            response.Actions.Add(new WebJobsOnOtpSendSuccess());\n            log.LogInformation(\"OTP sent successfully to {PhoneNumber}\", phoneNumber);\n        }\n        catch (Exception ex)\n        {\n            log.LogError(ex, \"Failed to send OTP\");\n            response.Actions.Add(new WebJobsOnOtpSendFailed\n            {\n                Error = \"Failed to send verification code\"\n            });\n        }\n\n        return response;\n    }\n\n    private static async Task SendSmsAsync(string phoneNumber, string message)\n    {\n        \u002F\u002F Implement your SMS provider integration (Twilio, Azure Communication Services, etc.)\n        await Task.CompletedTask;\n    }\n}\n```\n\n### 6. Function App Configuration\n\nConfigure the Function App for authentication events.\n\n```csharp\n\u002F\u002F Program.cs (Isolated worker model)\nusing Microsoft.Extensions.Hosting;\n\nvar host = new HostBuilder()\n    .ConfigureFunctionsWorkerDefaults()\n    .Build();\n\nhost.Run();\n```\n\n```json\n\u002F\u002F host.json\n{\n  \"version\": \"2.0\",\n  \"logging\": {\n    \"applicationInsights\": {\n      \"samplingSettings\": {\n        \"isEnabled\": true\n      }\n    }\n  },\n  \"extensions\": {\n    \"http\": {\n      \"routePrefix\": \"\"\n    }\n  }\n}\n```\n\n```json\n\u002F\u002F local.settings.json\n{\n  \"IsEncrypted\": false,\n  \"Values\": {\n    \"AzureWebJobsStorage\": \"UseDevelopmentStorage=true\",\n    \"FUNCTIONS_WORKER_RUNTIME\": \"dotnet\"\n  }\n}\n```\n\n## Key Types Reference\n\n| Type | Purpose |\n|------|---------|\n| `WebJobsAuthenticationEventsTriggerAttribute` | Function trigger attribute |\n| `WebJobsTokenIssuanceStartRequest` | Token issuance event request |\n| `WebJobsTokenIssuanceStartResponse` | Token issuance event response |\n| `WebJobsProvideClaimsForToken` | Action to add claims |\n| `WebJobsAttributeCollectionStartRequest` | Attribute collection start request |\n| `WebJobsAttributeCollectionStartResponse` | Attribute collection start response |\n| `WebJobsAttributeCollectionSubmitRequest` | Attribute submission request |\n| `WebJobsAttributeCollectionSubmitResponse` | Attribute submission response |\n| `WebJobsSetPrefillValues` | Prefill form values |\n| `WebJobsShowBlockPage` | Block user with message |\n| `WebJobsShowValidationError` | Show validation errors |\n| `WebJobsModifyAttributeValues` | Modify submitted values |\n| `WebJobsOnOtpSendRequest` | OTP send event request |\n| `WebJobsOnOtpSendResponse` | OTP send event response |\n| `WebJobsOnOtpSendSuccess` | OTP sent successfully |\n| `WebJobsOnOtpSendFailed` | OTP send failed |\n| `WebJobsContinueWithDefaultBehavior` | Continue with default flow |\n\n## Entra ID Configuration\n\nAfter deploying your Function App, configure the custom extension in Entra ID:\n\n1. **Register the API** in Entra ID → App registrations\n2. **Create Custom Authentication Extension** in Entra ID → External Identities → Custom authentication extensions\n3. **Link to User Flow** in Entra ID → External Identities → User flows\n\n### Required App Registration Settings\n\n```\nExpose an API:\n  - Application ID URI: api:\u002F\u002F\u003Cyour-function-app-name>.azurewebsites.net\n  - Scope: CustomAuthenticationExtension.Receive.Payload\n\nAPI Permissions:\n  - Microsoft Graph: User.Read (delegated)\n```\n\n## Best Practices\n\n1. **Validate all inputs** — Never trust request data; validate before processing\n2. **Handle errors gracefully** — Return appropriate error responses\n3. **Log correlation IDs** — Use `CorrelationId` for troubleshooting\n4. **Keep functions fast** — Authentication events have timeout limits\n5. **Use managed identity** — Access Azure resources securely\n6. **Cache external data** — Avoid slow lookups on every request\n7. **Test locally** — Use Azure Functions Core Tools with sample payloads\n8. **Monitor with App Insights** — Track function execution and errors\n\n## Error Handling\n\n```csharp\n[FunctionName(\"OnTokenIssuanceStart\")]\npublic static WebJobsAuthenticationEventResponse Run(\n    [WebJobsAuthenticationEventsTrigger] WebJobsTokenIssuanceStartRequest request,\n    ILogger log)\n{\n    try\n    {\n        \u002F\u002F Your logic here\n        var response = new WebJobsTokenIssuanceStartResponse();\n        response.Actions.Add(new WebJobsProvideClaimsForToken\n        {\n            Claims = new Dictionary\u003Cstring, string> { { \"claim\", \"value\" } }\n        });\n        return response;\n    }\n    catch (Exception ex)\n    {\n        log.LogError(ex, \"Error processing token issuance event\");\n        \n        \u002F\u002F Return empty response - authentication continues without custom claims\n        \u002F\u002F Do NOT throw - this would fail the authentication\n        return new WebJobsTokenIssuanceStartResponse();\n    }\n}\n```\n\n## Related SDKs\n\n| SDK | Purpose | Install |\n|-----|---------|---------|\n| `Microsoft.Azure.WebJobs.Extensions.AuthenticationEvents` | Auth events (this SDK) | `dotnet add package Microsoft.Azure.WebJobs.Extensions.AuthenticationEvents` |\n| `Microsoft.Identity.Web` | Web app authentication | `dotnet add package Microsoft.Identity.Web` |\n| `Azure.Identity` | Azure authentication | `dotnet add package Azure.Identity` |\n\n## Reference Links\n\n| Resource | URL |\n|----------|-----|\n| NuGet Package | https:\u002F\u002Fwww.nuget.org\u002Fpackages\u002FMicrosoft.Azure.WebJobs.Extensions.AuthenticationEvents |\n| Custom Extensions Overview | https:\u002F\u002Flearn.microsoft.com\u002Fentra\u002Fidentity-platform\u002Fcustom-extension-overview |\n| Token Issuance Events | https:\u002F\u002Flearn.microsoft.com\u002Fentra\u002Fidentity-platform\u002Fcustom-extension-tokenissuancestart-setup |\n| Attribute Collection Events | https:\u002F\u002Flearn.microsoft.com\u002Fentra\u002Fidentity-platform\u002Fcustom-extension-attribute-collection |\n| GitHub Source | https:\u002F\u002Fgithub.com\u002FAzure\u002Fazure-sdk-for-net\u002Ftree\u002Fmain\u002Fsdk\u002Fentra\u002FMicrosoft.Azure.WebJobs.Extensions.AuthenticationEvents |\n","# Microsoft.Azure.WebJobs.Extensions.AuthenticationEvents (.NET)\n\nAzure Functions extension for handling Microsoft Entra ID custom authentication events.\n\n## Installation\n\n```bash\ndotnet add package Microsoft.Azure.WebJobs.Extensions.AuthenticationEvents\n```\n\n**Current Version**: v1.1.0 (stable)\n\n## Supported Events\n\n| Event | Purpose |\n|-------|---------|\n| `OnTokenIssuanceStart` | Add custom claims to tokens during issuance |\n| `OnAttributeCollectionStart` | Customize attribute collection UI before display |\n| `OnAttributeCollectionSubmit` | Validate\u002Fmodify attributes after user submission |\n| `OnOtpSend` | Custom OTP delivery (SMS, email, etc.) |\n\n## Core Workflows\n\n### 1. Token Enrichment (Add Custom Claims)\n\nAdd custom claims to access or ID tokens during sign-in.\n\n```csharp\nusing Microsoft.Azure.WebJobs;\nusing Microsoft.Azure.WebJobs.Extensions.AuthenticationEvents;\nusing Microsoft.Azure.WebJobs.Extensions.AuthenticationEvents.TokenIssuanceStart;\nusing Microsoft.Extensions.Logging;\n\npublic static class TokenEnrichmentFunction\n{\n    [FunctionName(\"OnTokenIssuanceStart\")]\n    public static WebJobsAuthenticationEventResponse Run(\n        [WebJobsAuthenticationEventsTrigger] WebJobsTokenIssuanceStartRequest request,\n        ILogger log)\n    {\n        log.LogInformation(\"Token issuance event for user: {UserId}\", \n            request.Data?.AuthenticationContext?.User?.Id);\n\n        \u002F\u002F Create response with custom claims\n        var response = new WebJobsTokenIssuanceStartResponse();\n        \n        \u002F\u002F Add claims to the token\n        response.Actions.Add(new WebJobsProvideClaimsForToken\n        {\n            Claims = new Dictionary\u003Cstring, string>\n            {\n                { \"customClaim1\", \"customValue1\" },\n                { \"department\", \"Engineering\" },\n                { \"costCenter\", \"CC-12345\" },\n                { \"apiVersion\", \"v2\" }\n            }\n        });\n\n        return response;\n    }\n}\n```\n\n### 2. Token Enrichment with External Data\n\nFetch claims from external systems (databases, APIs).\n\n```csharp\nusing Microsoft.Azure.WebJobs;\nusing Microsoft.Azure.WebJobs.Extensions.AuthenticationEvents;\nusing Microsoft.Azure.WebJobs.Extensions.AuthenticationEvents.TokenIssuanceStart;\nusing Microsoft.Extensions.Logging;\nusing System.Net.Http;\nusing System.Text.Json;\n\npublic static class TokenEnrichmentWithExternalData\n{\n    private static readonly HttpClient _httpClient = new();\n\n    [FunctionName(\"OnTokenIssuanceStartExternal\")]\n    public static async Task\u003CWebJobsAuthenticationEventResponse> Run(\n        [WebJobsAuthenticationEventsTrigger] WebJobsTokenIssuanceStartRequest request,\n        ILogger log)\n    {\n        string? userId = request.Data?.AuthenticationContext?.User?.Id;\n        \n        if (string.IsNullOrEmpty(userId))\n        {\n            log.LogWarning(\"No user ID in request\");\n            return new WebJobsTokenIssuanceStartResponse();\n        }\n\n        \u002F\u002F Fetch user data from external API\n        var userProfile = await GetUserProfileAsync(userId);\n        \n        var response = new WebJobsTokenIssuanceStartResponse();\n        response.Actions.Add(new WebJobsProvideClaimsForToken\n        {\n            Claims = new Dictionary\u003Cstring, string>\n            {\n                { \"employeeId\", userProfile.EmployeeId },\n                { \"department\", userProfile.Department },\n                { \"roles\", string.Join(\",\", userProfile.Roles) }\n            }\n        });\n\n        return response;\n    }\n\n    private static async Task\u003CUserProfile> GetUserProfileAsync(string userId)\n    {\n        var response = await _httpClient.GetAsync($\"https:\u002F\u002Fapi.example.com\u002Fusers\u002F{userId}\");\n        response.EnsureSuccessStatusCode();\n        var json = await response.Content.ReadAsStringAsync();\n        return JsonSerializer.Deserialize\u003CUserProfile>(json)!;\n    }\n}\n\npublic record UserProfile(string EmployeeId, string Department, string[] Roles);\n```\n\n### 3. Attribute Collection - Customize UI (Start Event)\n\nCustomize the attribute collection page before it's displayed.\n\n```csharp\nusing Microsoft.Azure.WebJobs;\nusing Microsoft.Azure.WebJobs.Extensions.AuthenticationEvents;\nusing Microsoft.Azure.WebJobs.Extensions.AuthenticationEvents.Framework;\nusing Microsoft.Extensions.Logging;\n\npublic static class AttributeCollectionStartFunction\n{\n    [FunctionName(\"OnAttributeCollectionStart\")]\n    public static WebJobsAuthenticationEventResponse Run(\n        [WebJobsAuthenticationEventsTrigger] WebJobsAttributeCollectionStartRequest request,\n        ILogger log)\n    {\n        log.LogInformation(\"Attribute collection start for correlation: {CorrelationId}\",\n            request.Data?.AuthenticationContext?.CorrelationId);\n\n        var response = new WebJobsAttributeCollectionStartResponse();\n\n        \u002F\u002F Option 1: Continue with default behavior\n        response.Actions.Add(new WebJobsContinueWithDefaultBehavior());\n\n        \u002F\u002F Option 2: Prefill attributes\n        \u002F\u002F response.Actions.Add(new WebJobsSetPrefillValues\n        \u002F\u002F {\n        \u002F\u002F     Attributes = new Dictionary\u003Cstring, string>\n        \u002F\u002F     {\n        \u002F\u002F         { \"city\", \"Seattle\" },\n        \u002F\u002F         { \"country\", \"USA\" }\n        \u002F\u002F     }\n        \u002F\u002F });\n\n        \u002F\u002F Option 3: Show blocking page (prevent sign-up)\n        \u002F\u002F response.Actions.Add(new WebJobsShowBlockPage\n        \u002F\u002F {\n        \u002F\u002F     Message = \"Sign-up is currently disabled.\"\n        \u002F\u002F });\n\n        return response;\n    }\n}\n```\n\n### 4. Attribute Collection - Validate Submission (Submit Event)\n\nValidate and modify attributes after user submission.\n\n```csharp\nusing Microsoft.Azure.WebJobs;\nusing Microsoft.Azure.WebJobs.Extensions.AuthenticationEvents;\nusing Microsoft.Azure.WebJobs.Extensions.AuthenticationEvents.Framework;\nusing Microsoft.Extensions.Logging;\n\npublic static class AttributeCollectionSubmitFunction\n{\n    [FunctionName(\"OnAttributeCollectionSubmit\")]\n    public static WebJobsAuthenticationEventResponse Run(\n        [WebJobsAuthenticationEventsTrigger] WebJobsAttributeCollectionSubmitRequest request,\n        ILogger log)\n    {\n        var response = new WebJobsAttributeCollectionSubmitResponse();\n\n        \u002F\u002F Access submitted attributes\n        var attributes = request.Data?.UserSignUpInfo?.Attributes;\n        \n        string? email = attributes?[\"email\"]?.ToString();\n        string? displayName = attributes?[\"displayName\"]?.ToString();\n\n        \u002F\u002F Validation example: block certain email domains\n        if (email?.EndsWith(\"@blocked.com\") == true)\n        {\n            response.Actions.Add(new WebJobsShowBlockPage\n            {\n                Message = \"Sign-up from this email domain is not allowed.\"\n            });\n            return response;\n        }\n\n        \u002F\u002F Validation example: show validation error\n        if (string.IsNullOrEmpty(displayName) || displayName.Length \u003C 3)\n        {\n            response.Actions.Add(new WebJobsShowValidationError\n            {\n                Message = \"Display name must be at least 3 characters.\",\n                AttributeErrors = new Dictionary\u003Cstring, string>\n                {\n                    { \"displayName\", \"Name is too short\" }\n                }\n            });\n            return response;\n        }\n\n        \u002F\u002F Modify attributes before saving\n        response.Actions.Add(new WebJobsModifyAttributeValues\n        {\n            Attributes = new Dictionary\u003Cstring, string>\n            {\n                { \"displayName\", displayName.Trim() },\n                { \"city\", attributes?[\"city\"]?.ToString()?.ToUpperInvariant() ?? \"\" }\n            }\n        });\n\n        return response;\n    }\n}\n```\n\n### 5. Custom OTP Delivery\n\nSend one-time passwords via custom channels (SMS, email, push notification).\n\n```csharp\nusing Microsoft.Azure.WebJobs;\nusing Microsoft.Azure.WebJobs.Extensions.AuthenticationEvents;\nusing Microsoft.Azure.WebJobs.Extensions.AuthenticationEvents.Framework;\nusing Microsoft.Extensions.Logging;\n\npublic static class CustomOtpFunction\n{\n    [FunctionName(\"OnOtpSend\")]\n    public static async Task\u003CWebJobsAuthenticationEventResponse> Run(\n        [WebJobsAuthenticationEventsTrigger] WebJobsOnOtpSendRequest request,\n        ILogger log)\n    {\n        var response = new WebJobsOnOtpSendResponse();\n\n        string? phoneNumber = request.Data?.OtpContext?.Identifier;\n        string? otp = request.Data?.OtpContext?.OneTimeCode;\n\n        if (string.IsNullOrEmpty(phoneNumber) || string.IsNullOrEmpty(otp))\n        {\n            log.LogError(\"Missing phone number or OTP\");\n            response.Actions.Add(new WebJobsOnOtpSendFailed\n            {\n                Error = \"Missing required data\"\n            });\n            return response;\n        }\n\n        try\n        {\n            \u002F\u002F Send OTP via your SMS provider\n            await SendSmsAsync(phoneNumber, $\"Your verification code is: {otp}\");\n            \n            response.Actions.Add(new WebJobsOnOtpSendSuccess());\n            log.LogInformation(\"OTP sent successfully to {PhoneNumber}\", phoneNumber);\n        }\n        catch (Exception ex)\n        {\n            log.LogError(ex, \"Failed to send OTP\");\n            response.Actions.Add(new WebJobsOnOtpSendFailed\n            {\n                Error = \"Failed to send verification code\"\n            });\n        }\n\n        return response;\n    }\n\n    private static async Task SendSmsAsync(string phoneNumber, string message)\n    {\n        \u002F\u002F Implement your SMS provider integration (Twilio, Azure Communication Services, etc.)\n        await Task.CompletedTask;\n    }\n}\n```\n\n### 6. Function App Configuration\n\nConfigure the Function App for authentication events.\n\n```csharp\n\u002F\u002F Program.cs (Isolated worker model)\nusing Microsoft.Extensions.Hosting;\n\nvar host = new HostBuilder()\n    .ConfigureFunctionsWorkerDefaults()\n    .Build();\n\nhost.Run();\n```\n\n```json\n\u002F\u002F host.json\n{\n  \"version\": \"2.0\",\n  \"logging\": {\n    \"applicationInsights\": {\n      \"samplingSettings\": {\n        \"isEnabled\": true\n      }\n    }\n  },\n  \"extensions\": {\n    \"http\": {\n      \"routePrefix\": \"\"\n    }\n  }\n}\n```\n\n```json\n\u002F\u002F local.settings.json\n{\n  \"IsEncrypted\": false,\n  \"Values\": {\n    \"AzureWebJobsStorage\": \"UseDevelopmentStorage=true\",\n    \"FUNCTIONS_WORKER_RUNTIME\": \"dotnet\"\n  }\n}\n```\n\n## Key Types Reference\n\n| Type | Purpose |\n|------|---------|\n| `WebJobsAuthenticationEventsTriggerAttribute` | Function trigger attribute |\n| `WebJobsTokenIssuanceStartRequest` | Token issuance event request |\n| `WebJobsTokenIssuanceStartResponse` | Token issuance event response |\n| `WebJobsProvideClaimsForToken` | Action to add claims |\n| `WebJobsAttributeCollectionStartRequest` | Attribute collection start request |\n| `WebJobsAttributeCollectionStartResponse` | Attribute collection start response |\n| `WebJobsAttributeCollectionSubmitRequest` | Attribute submission request |\n| `WebJobsAttributeCollectionSubmitResponse` | Attribute submission response |\n| `WebJobsSetPrefillValues` | Prefill form values |\n| `WebJobsShowBlockPage` | Block user with message |\n| `WebJobsShowValidationError` | Show validation errors |\n| `WebJobsModifyAttributeValues` | Modify submitted values |\n| `WebJobsOnOtpSendRequest` | OTP send event request |\n| `WebJobsOnOtpSendResponse` | OTP send event response |\n| `WebJobsOnOtpSendSuccess` | OTP sent successfully |\n| `WebJobsOnOtpSendFailed` | OTP send failed |\n| `WebJobsContinueWithDefaultBehavior` | Continue with default flow |\n\n## Entra ID Configuration\n\nAfter deploying your Function App, configure the custom extension in Entra ID:\n\n1. **Register the API** in Entra ID → App registrations\n2. **Create Custom Authentication Extension** in Entra ID → External Identities → Custom authentication extensions\n3. **Link to User Flow** in Entra ID → External Identities → User flows\n\n### Required App Registration Settings\n\n```\nExpose an API:\n  - Application ID URI: api:\u002F\u002F\u003Cyour-function-app-name>.azurewebsites.net\n  - Scope: CustomAuthenticationExtension.Receive.Payload\n\nAPI Permissions:\n  - Microsoft Graph: User.Read (delegated)\n```\n\n## Best Practices\n\n1. **Validate all inputs** — Never trust request data; validate before processing\n2. **Handle errors gracefully** — Return appropriate error responses\n3. **Log correlation IDs** — Use `CorrelationId` for troubleshooting\n4. **Keep functions fast** — Authentication events have timeout limits\n5. **Use managed identity** — Access Azure resources securely\n6. **Cache external data** — Avoid slow lookups on every request\n7. **Test locally** — Use Azure Functions Core Tools with sample payloads\n8. **Monitor with App Insights** — Track function execution and errors\n\n## Error Handling\n\n```csharp\n[FunctionName(\"OnTokenIssuanceStart\")]\npublic static WebJobsAuthenticationEventResponse Run(\n    [WebJobsAuthenticationEventsTrigger] WebJobsTokenIssuanceStartRequest request,\n    ILogger log)\n{\n    try\n    {\n        \u002F\u002F Your logic here\n        var response = new WebJobsTokenIssuanceStartResponse();\n        response.Actions.Add(new WebJobsProvideClaimsForToken\n        {\n            Claims = new Dictionary\u003Cstring, string> { { \"claim\", \"value\" } }\n        });\n        return response;\n    }\n    catch (Exception ex)\n    {\n        log.LogError(ex, \"Error processing token issuance event\");\n        \n        \u002F\u002F Return empty response - authentication continues without custom claims\n        \u002F\u002F Do NOT throw - this would fail the authentication\n        return new WebJobsTokenIssuanceStartResponse();\n    }\n}\n```\n\n## Related SDKs\n\n| SDK | Purpose | Install |\n|-----|---------|---------|\n| `Microsoft.Azure.WebJobs.Extensions.AuthenticationEvents` | Auth events (this SDK) | `dotnet add package Microsoft.Azure.WebJobs.Extensions.AuthenticationEvents` |\n| `Microsoft.Identity.Web` | Web app authentication | `dotnet add package Microsoft.Identity.Web` |\n| `Azure.Identity` | Azure authentication | `dotnet add package Azure.Identity` |\n\n## Reference Links\n\n| Resource | URL |\n|----------|-----|\n| NuGet Package | https:\u002F\u002Fwww.nuget.org\u002Fpackages\u002FMicrosoft.Azure.WebJobs.Extensions.AuthenticationEvents |\n| Custom Extensions Overview | https:\u002F\u002Flearn.microsoft.com\u002Fentra\u002Fidentity-platform\u002Fcustom-extension-overview |\n| Token Issuance Events | https:\u002F\u002Flearn.microsoft.com\u002Fentra\u002Fidentity-platform\u002Fcustom-extension-tokenissuancestart-setup |\n| Attribute Collection Events | https:\u002F\u002Flearn.microsoft.com\u002Fentra\u002Fidentity-platform\u002Fcustom-extension-attribute-collection |\n| GitHub Source | https:\u002F\u002Fgithub.com\u002FAzure\u002Fazure-sdk-for-net\u002Ftree\u002Fmain\u002Fsdk\u002Fentra\u002FMicrosoft.Azure.WebJobs.Extensions.AuthenticationEvents |\n",{"name":5,"license":15,"metadata":44,"description":7},{"author":12,"version":45},"1.0.0","main","3f5b461b2314e01c400564051e92469114c5b68f",".github\u002Fplugins\u002Fazure-sdk-dotnet\u002Fskills\u002Fmicrosoft-azure-webjobs-extensions-authentication-events-dotnet",368,"https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Fskills","https:\u002F\u002Fmicrosoft.github.io\u002Fskills\u002F","https:\u002F\u002Fgithub.com\u002Fmicrosoft","https:\u002F\u002Fopensource.microsoft.com","Open source projects and samples from Microsoft","2026-11-14 02:08:41",{"source":8,"skillName":5,"commands":57,"prompt":67,"zipAvailable":68},[58,61,64],{"tool":59,"command":60},"npx","npx skills add microsoft\u002Fskills --skill microsoft-azure-webjobs-extensions-authentication-events-dotnet",{"tool":62,"command":63},"bunx","bunx skills add microsoft\u002Fskills --skill microsoft-azure-webjobs-extensions-authentication-events-dotnet",{"tool":65,"command":66},"pnpm","pnpm dlx skills add microsoft\u002Fskills --skill microsoft-azure-webjobs-extensions-authentication-events-dotnet","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Fskills\u002Fblob\u002Fmain\u002F.github\u002Fplugins\u002Fazure-sdk-dotnet\u002Fskills\u002Fmicrosoft-azure-webjobs-extensions-authentication-events-dotnet\u002FSKILL.md",true,[],[71,98,136,163,183,221],{"skillNo":72,"name":73,"nameZh":6,"description":74,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":75,"categories":76,"keywords":82,"publishedAt":39},"01M69B4JCRQV5SPXAFCKXQRV0H","skill-creator","Guide for creating effective skills for AI coding agents working with Azure SDKs and Microsoft Foundry services. Use when creating new skills or updating existing skills.","https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Fskills\u002Fblob\u002Fmain\u002F.github\u002Fskills\u002Fskill-creator\u002FSKILL.md",[77],{"categoryNo":78,"categoryName":79,"taxonomyType":80,"taxonomyTypeDesc":81},"01JBSEEDCAT000000000000023","Skill与智能体开发","SCENARIO","使用场景",[83,84,85,9,86,87,88,20,89,90,91,36,92,93,94,29,95,96,97],"skill creator","creator","coding agents","foundry","microsoft foundry","ai coding agents","services","coding","guide","ai coding","with","sdks","Existing","when","new",{"skillNo":99,"name":100,"nameZh":6,"description":101,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":102,"categories":103,"keywords":114,"publishedAt":39},"01M69B4FD57V1MYKRWAJJECTZ7","podcast-generation","Generate AI-powered podcast-style audio narratives using Azure OpenAI's GPT Realtime Mini model via WebSocket. Use when building text-to-speech features, audio narrative generation, podcast creation from content, or integrating with Azure OpenAI Realtime API for real audio output. Covers full-stack implementation from React frontend to Python FastAPI backend with WebSocket streaming.","https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Fskills\u002Fblob\u002Fmain\u002F.github\u002Fskills\u002Fpodcast-generation\u002FSKILL.md",[104,107,110,113],{"categoryNo":105,"categoryName":106,"taxonomyType":80,"taxonomyTypeDesc":81},"01JBSEEDCAT000000000000009","前端开发",{"categoryNo":108,"categoryName":109,"taxonomyType":80,"taxonomyTypeDesc":81},"01JBSEEDCAT000000000000010","后端与接口",{"categoryNo":111,"categoryName":112,"taxonomyType":80,"taxonomyTypeDesc":81},"01JBSEEDCAT000000000000016","图像与多媒体",{"categoryNo":78,"categoryName":79,"taxonomyType":80,"taxonomyTypeDesc":81},[115,116,117,118,119,120,121,20,122,123,124,125,126,127,128,129,130,131,132,133,134,96,135],"podcast generation","podcast","generation","frontend","python","react","realtime","azure openai","generate","streaming","api","Audio","stack","text","model","fastapi","creation","python fastapi","narrative","features","fastapi backend",{"skillNo":137,"name":138,"nameZh":6,"description":139,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":140,"categories":141,"keywords":143,"publishedAt":39},"01M69B4CYPM5SESY5ZWEFDXEQZ","microsoft-docs","Understand Microsoft technologies by querying official documentation. Use whenever the user asks how something works, wants tutorials, needs configuration options, limits, quotas, or best practices for any Microsoft technology (Azure, .NET, M365, Windows, Power Platform, etc.)—even if they don't mention \"docs.\" If the question is about understanding a concept rather than writing code, this is the right skill.","https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Fskills\u002Fblob\u002Fmain\u002F.github\u002Fskills\u002Fmicrosoft-docs\u002FSKILL.md",[142],{"categoryNo":78,"categoryName":79,"taxonomyType":80,"taxonomyTypeDesc":81},[144,9,145,146,147,148,149,150,151,152,153,20,154,155,156,36,157,59,158,159,160,161,162,29],"docs","microsoft docs","MCP","writing","cli","mcp server","windows","power platform","official","documentation","learn","best practices","question","power","back","technology","platform","learn mcp","concept",{"skillNo":164,"name":165,"nameZh":6,"description":166,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":167,"categories":168,"keywords":170,"publishedAt":39},"01M69B49C3YPD1ZJ3NC0HPCY58","mcp-builder","Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP), Node\u002FTypeScript (MCP SDK), or C#\u002F.NET (Microsoft MCP SDK).","https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Fskills\u002Fblob\u002Fmain\u002F.github\u002Fskills\u002Fmcp-builder\u002FSKILL.md",[169],{"categoryNo":78,"categoryName":79,"taxonomyType":80,"taxonomyTypeDesc":81},[146,171,172,173,119,174,27,175,9,176,177,129,178,179,91,36,180,181,182,93,29,96],"mcp builder","builder","typescript","llms","model context protocol","fastmcp","Tools","node","context","integrate","mcp sdk","building mcp servers",{"skillNo":184,"name":185,"nameZh":6,"description":186,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":187,"categories":188,"keywords":201,"publishedAt":39},"01M69B467A7CDMFQ0T6Q0ZA12Q","kql","KQL language expertise for writing correct, efficient Kusto Query Language queries. Covers syntax gotchas, join patterns, dynamic types, datetime pitfalls, regex patterns, serialization, memory management, result-size discipline, and advanced functions (geo, vector, graph). USE THIS SKILL whenever writing, debugging, or reviewing KQL queries — even simple ones — because the gotchas section prevents the most common errors that waste tool calls and cause expensive retry cascades. Trigger on: KQL, Kusto, ADX, Azure Data Explorer, Fabric Real-Time Intelligence, EventHouse, Log Analytics, log analysis, data exploration, time series, anomaly detection, summarize, where clause, join, extend, project, let statement, parse operator, extract function, any mention of pipe-forward query syntax.","https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Fskills\u002Fblob\u002Fmain\u002F.github\u002Fskills\u002Fkql\u002FSKILL.md",[189,192,193,198],{"categoryNo":190,"categoryName":191,"taxonomyType":80,"taxonomyTypeDesc":81},"01JBSEEDCAT000000000000018","写作与文案",{"categoryNo":78,"categoryName":79,"taxonomyType":80,"taxonomyTypeDesc":81},{"categoryNo":194,"categoryName":195,"taxonomyType":196,"taxonomyTypeDesc":197},"01JBSEEDCAT000000000000033","数据分析师","PROFESSION","适用职业",{"categoryNo":199,"categoryName":200,"taxonomyType":196,"taxonomyTypeDesc":197},"01JBSEEDCAT000000000000036","内容创作者",[185,147,202,203,204,20,205,206,207,208,209,210,211,212,213,214,215,216,217,29,218,219,220],"summarize","memory","analytics","vector","time series","tool","discipline","log","geo","exploration","pipe","time","project","regex","join","datetime","section","anomaly","parse",{"skillNo":222,"name":223,"nameZh":6,"description":224,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":225,"categories":226,"keywords":227,"publishedAt":39},"01M69B44HJQ7897EZ7NE7DWQX3","github-issue-creator","Convert raw notes, error logs, voice dictation, or screenshots into crisp GitHub-flavored markdown issue reports. Use when the user pastes bug info, error messages, or informal descriptions and wants a structured GitHub issue. Supports images\u002FGIFs for visual evidence.","https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Fskills\u002Fblob\u002Fmain\u002F.github\u002Fskills\u002Fgithub-issue-creator\u002FSKILL.md",[],[228,229,230,231,84,232,233,234,235,236,237,238,36,239,240,241,242,243,244,29,96],"github","github issue creator","github issue","issue","issue creator","screenshots","notes","logs","error messages","messages","convert","evidence","reports","images","info","visual","error"]