[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6FVME1GCG7BA0C2A1MQ3A7C":3,"skill-same:01M6FVME1GCG7BA0C2A1MQ3A7C":49},{"skillNo":4,"name":5,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":22,"linkOnly":23,"markdownContent":24,"markdownBody":25,"frontMatter":26,"refName":27,"commitSha":28,"skillDirectory":29,"forksCount":13,"repositoryHtmlUrl":30,"repositoryHomepageUrl":6,"ownerHtmlUrl":31,"ownerBlogUrl":32,"ownerDescription":33,"updatedAt":34,"install":35,"resources":48},"01M6FVME1GCG7BA0C2A1MQ3A7C","microsoft-azure-webjobs-extensions-authentication-",null,"reikiplanet\u002Fdaoskills","reikiplanet","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F96377599?v=4","01M6CVWCMD740YHQDK7E9QYBW4","Reiki Planet","01M6CVWCS4KXVA2CWFVJ43EAXK",0,"MIT","https:\u002F\u002Fgithub.com\u002Freikiplanet\u002Fdaoskills\u002Fblob\u002Fmaster\u002Fdevelopment\u002Fmicrosoft-azure-webjobs-extensions-authentication-\u002FSKILL.md",[],[18,19,20,21],"microsoft","azure","authentication","microsoft azure webjobs extensions authentication","2026-11-10 10:12:30",false,"---\nname: microsoft-azure-webjobs-extensions-authentication-events-dotnet\ndescription: \"|\"\n  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\".\nrisk: unknown\nsource: community\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\n## When to Use\nThis skill is applicable to execute the workflow or actions described in the overview.\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\n## When to Use\nThis skill is applicable to execute the workflow or actions described in the overview.\n",{},"master","dff58085da947e81e8418c922055644bf0082b1b","development\u002Fmicrosoft-azure-webjobs-extensions-authentication-","https:\u002F\u002Fgithub.com\u002Freikiplanet\u002Fdaoskills","https:\u002F\u002Fgithub.com\u002Freikiplanet","https:\u002F\u002Fwww.reiki-planet.com","Reiki Planet Game","2026-03-29 06:02:29",{"source":7,"skillName":5,"commands":36,"prompt":46,"zipAvailable":47},[37,40,43],{"tool":38,"command":39},"npx","npx skills add reikiplanet\u002Fdaoskills --skill microsoft-azure-webjobs-extensions-authentication-",{"tool":41,"command":42},"bunx","bunx skills add reikiplanet\u002Fdaoskills --skill microsoft-azure-webjobs-extensions-authentication-",{"tool":44,"command":45},"pnpm","pnpm dlx skills add reikiplanet\u002Fdaoskills --skill microsoft-azure-webjobs-extensions-authentication-","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Freikiplanet\u002Fdaoskills\u002Fblob\u002Fmaster\u002Fdevelopment\u002Fmicrosoft-azure-webjobs-extensions-authentication-\u002FSKILL.md",true,[],[50,77,89,104,124,147],{"skillNo":51,"name":52,"nameZh":6,"description":53,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":54,"categories":55,"keywords":56,"publishedAt":22},"01M6G614JTEQJHPT8AKK3YQ18S","web-games","Web browser game development principles. Framework selection, WebGPU, optimization, PWA.","https:\u002F\u002Fgithub.com\u002Freikiplanet\u002Fdaoskills\u002Fblob\u002Fmaster\u002Fweb-games\u002FSKILL.md",[],[57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76],"games","web games","web","grep","principles","selection","community","framework selection","edit","write","read","pwa","game","web browser","game development","Optimization","framework","browser","development","webgpu",{"skillNo":78,"name":79,"nameZh":6,"description":80,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":81,"categories":82,"keywords":83,"publishedAt":22},"01M6G611H2YGV0GZFP90D38ZMJ","vr-ar","VR\u002FAR development principles. Comfort, interaction, performance requirements.","https:\u002F\u002Fgithub.com\u002Freikiplanet\u002Fdaoskills\u002Fblob\u002Fmaster\u002Fvr-ar\u002FSKILL.md",[],[84,85,75,86,87,63,65,66,67,60,88,61],"ar","vr ar","interaction","requirements","performance",{"skillNo":90,"name":91,"nameZh":6,"description":92,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":93,"categories":94,"keywords":95,"publishedAt":22},"01M6G60XNMHAMV1SV0EJ1CX0AY","templates","Project scaffolding templates for new applications. Use when creating new projects from scratch. Contains 12 templates for various tech stacks.","https:\u002F\u002Fgithub.com\u002Freikiplanet\u002Fdaoskills\u002Fblob\u002Fmaster\u002Ftemplates\u002FSKILL.md",[],[91,96,97,98,99,100,63,101,67,102,103,60],"project scaffolding","From Scratch","tech","project","scaffolding","use","projects","applications",{"skillNo":105,"name":106,"nameZh":6,"description":107,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":108,"categories":109,"keywords":110,"publishedAt":22},"01M6G60T0GATMK3Q5H8GDC1Z8S","wcag-audit-patterns","Conduct WCAG 2.2 accessibility audits with automated testing, manual verification, and remediation guidance. Use when auditing websites for accessibility, fixing WCAG violations, or implementing ac...","https:\u002F\u002Fgithub.com\u002Freikiplanet\u002Fdaoskills\u002Fblob\u002Fmaster\u002Fskills\u002Fsecurity\u002Fwcag-audit-patterns\u002FSKILL.md",[],[111,112,113,114,115,63,116,117,118,119,101,120,121,122,123],"wcag audit patterns","wcag audit","patterns","WCAG","audit","manual","with","automated testing","guidance","remediation","verification","accessibility","testing",{"skillNo":125,"name":126,"nameZh":6,"description":127,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":128,"categories":129,"keywords":130,"publishedAt":22},"01M6G60PMCHW1FRZ63F931QK3R","vulnerability-scanner","Advanced vulnerability analysis principles. OWASP 2025, Supply Chain Security, attack surface mapping, risk prioritization.","https:\u002F\u002Fgithub.com\u002Freikiplanet\u002Fdaoskills\u002Fblob\u002Fmaster\u002Fskills\u002Fsecurity\u002Fvulnerability-scanner\u002FSKILL.md",[],[131,132,133,134,135,136,137,138,63,67,60,139,61,140,141,142,143,144,145,146],"scanner","vulnerability scanner","vulnerability","prioritization","2025","mapping","chain","supply chain","Bash","analysis","risk","owasp","supply chain security","security","supply","advanced",{"skillNo":148,"name":149,"nameZh":6,"description":150,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":151,"categories":152,"keywords":153,"publishedAt":22},"01M6G60JZBB8DK0W3DSG1WNMZK","threat-modeling-expert","Expert in threat modeling methodologies, security architecture review, and risk assessment. Masters STRIDE, PASTA, attack trees, and security requirement extraction. Use for security architecture r...","https:\u002F\u002Fgithub.com\u002Freikiplanet\u002Fdaoskills\u002Fblob\u002Fmaster\u002Fskills\u002Fsecurity\u002Fthreat-modeling-expert\u002FSKILL.md",[],[154,155,156,157,158,159,160,161,144,101,162,163,164,63,165,166,167,141,168,169],"modeling","threat modeling expert","threat modeling","expert","threat","risk assessment","architecture review","architecture","security architecture review","trees","security architecture","security requirement extraction","assessment","extraction","review","stride"]