Skip to main content Inicio Creadores anhvu1107 all-agent-skill microsoft-azure-webjobs-extensions-authentication-events-dotnet
microsoft-azure-webjobs-extensions-authentication-events-dotnet ALWAYS use this when the request matches Microsoft Azure Webjobs Extensions Authentication Events Dotnet: Microsoft Entra Authentication Events SDK for .NET.
Ir a la instalación Skills Marketplace Descubre y explora habilidades de IA creadas por la comunidad.
Instalar con Codex o Claude Copia este prompt, pégalo en Codex, Claude u otro asistente, y deja que revise la página de la skill y la instale por ti.
Copiar promptMostrar detalles del prompt Un comando directo omite el prompt de revisión. Revisa el origen antes de ejecutarlo.
npx skills add https://github.com/Anhvu1107/all-agent-skill --skill microsoft-azure-webjobs-extensions-authentication-events-dotnetEl comando permanece en una sola línea. Desplázate horizontalmente para revisarlo antes de copiarlo.
¿Prefieres una copia local? Descarga los archivos que SkillsMP tiene disponibles ahora.
Descargar Zip Descargando... ALWAYS use this when the user mentions 10 Andruia Skill Smith, asks to build, debug, review, document, automate, test, configure, migrate, or make decisions in this domain, or the task clearly depends on 10 Andruia Skill Smith; scope: Ingeniero de Sistemas de Andru.ia. Apply the bundled workflow, references, scripts, Senior Master standard, and Codex strict review gate before final output.
Ocupaciones relacionadas SOC
Basado en la clasificación ocupacional SOC
Explorador de archivos
6 archivos name microsoft-azure-webjobs-extensions-authentication-events-dotnet description ALWAYS use this when the request matches Microsoft Azure Webjobs Extensions Authentication Events Dotnet: Microsoft Entra Authentication Events SDK for .NET.
Microsoft.Azure.WebJobs.Extensions.AuthenticationEvents (.NET)
Selective Reading Rule
Start with:
references/senior-master-standard.md
references/usage-routing.md
references/quality-checklist.md
Then load only the inherited docs, scripts, assets, or examples that match the user's actual task.
Azure Functions extension for handling Microsoft Entra ID custom authentication events.
Installation
dotnet add package Microsoft.Azure.WebJobs.Extensions.AuthenticationEvents
Current Version : v1.1.0 (stable)
Supported Events
Event Purpose OnTokenIssuanceStartAdd custom claims to tokens during issuance OnAttributeCollectionStartCustomize attribute collection UI before display OnAttributeCollectionSubmitValidate/modify attributes after user submission OnOtpSendCustom OTP delivery (SMS, email, etc.)
Core Workflows
1. Token Enrichment (Add Custom Claims)
Add custom claims to access or ID tokens during sign-in.
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.AuthenticationEvents;
Microsoft.Azure.WebJobs.Extensions.AuthenticationEvents.TokenIssuanceStart;
Microsoft.Extensions.Logging;
{
[ ]
{
log.LogInformation( ,
request.Data?.AuthenticationContext?.User?.Id);
response = WebJobsTokenIssuanceStartResponse();
response.Actions.Add( WebJobsProvideClaimsForToken
{
Claims = Dictionary< , >
{
{ , },
{ , },
{ , },
{ , }
}
});
response;
}
}
using
using
public
static
class
TokenEnrichmentFunction
FunctionName("OnTokenIssuanceStart" )
public static WebJobsAuthenticationEventResponse Run (
[WebJobsAuthenticationEventsTrigger] WebJobsTokenIssuanceStartRequest request,
ILogger log )
"Token issuance event for user: {UserId}"
var
new
new
new
string
string
"customClaim1"
"customValue1"
"department"
"Engineering"
"costCenter"
"CC-12345"
"apiVersion"
"v2"
return
2. Token Enrichment with External Data Fetch claims from external systems (databases, APIs).
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.AuthenticationEvents;
using Microsoft.Azure.WebJobs.Extensions.AuthenticationEvents.TokenIssuanceStart;
using Microsoft.Extensions.Logging;
using System.Net.Http;
using System.Text.Json;
public static class TokenEnrichmentWithExternalData
{
private static readonly HttpClient _httpClient = new ();
[FunctionName("OnTokenIssuanceStartExternal" ) ]
public static async Task<WebJobsAuthenticationEventResponse> Run (
[WebJobsAuthenticationEventsTrigger] WebJobsTokenIssuanceStartRequest request,
ILogger log )
{
string ? userId = request.Data?.AuthenticationContext?.User?.Id;
if (string .IsNullOrEmpty(userId))
{
log.LogWarning("No user ID in request" );
return new WebJobsTokenIssuanceStartResponse();
}
var userProfile = await GetUserProfileAsync(userId);
var response = new WebJobsTokenIssuanceStartResponse();
response.Actions.Add(new WebJobsProvideClaimsForToken
{
Claims = new Dictionary<string , string >
{
{ "employeeId" , userProfile.EmployeeId },
{ "department" , userProfile.Department },
{ "roles" , string .Join("," , userProfile.Roles) }
}
});
return response;
}
private static async Task<UserProfile> GetUserProfileAsync (string userId )
{
var response = await _httpClient.GetAsync($"https://api.example.com/users/{userId} " );
response.EnsureSuccessStatusCode();
var json = await response.Content.ReadAsStringAsync();
return JsonSerializer.Deserialize<UserProfile>(json)!;
}
}
public record UserProfile (string EmployeeId, string Department, string [] Roles ) ;
3. Attribute Collection - Customize UI (Start Event) Customize the attribute collection page before it's displayed.
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.AuthenticationEvents;
using Microsoft.Azure.WebJobs.Extensions.AuthenticationEvents.Framework;
using Microsoft.Extensions.Logging;
public static class AttributeCollectionStartFunction
{
[FunctionName("OnAttributeCollectionStart" ) ]
public static WebJobsAuthenticationEventResponse Run (
[WebJobsAuthenticationEventsTrigger] WebJobsAttributeCollectionStartRequest request,
ILogger log )
{
log.LogInformation("Attribute collection start for correlation: {CorrelationId}" ,
request.Data?.AuthenticationContext?.CorrelationId);
var response = new WebJobsAttributeCollectionStartResponse();
response.Actions.Add(new WebJobsContinueWithDefaultBehavior());
return response;
}
}
4. Attribute Collection - Validate Submission (Submit Event) Validate and modify attributes after user submission.
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.AuthenticationEvents;
using Microsoft.Azure.WebJobs.Extensions.AuthenticationEvents.Framework;
using Microsoft.Extensions.Logging;
public static class AttributeCollectionSubmitFunction
{
[FunctionName("OnAttributeCollectionSubmit" ) ]
public static WebJobsAuthenticationEventResponse Run (
[WebJobsAuthenticationEventsTrigger] WebJobsAttributeCollectionSubmitRequest request,
ILogger log )
{
var response = new WebJobsAttributeCollectionSubmitResponse();
var attributes = request.Data?.UserSignUpInfo?.Attributes;
string ? email = attributes?["email" ]?.ToString();
string ? displayName = attributes?["displayName" ]?.ToString();
if (email?.EndsWith("@blocked.com" ) == true )
{
response.Actions.Add(new WebJobsShowBlockPage
{
Message = "Sign-up from this email domain is not allowed."
});
return response;
}
if (string .IsNullOrEmpty(displayName) || displayName.Length < 3 )
{
response.Actions.Add(new WebJobsShowValidationError
{
Message = "Display name must be at least 3 characters." ,
AttributeErrors = new Dictionary<string , string >
{
{ "displayName" , "Name is too short" }
}
});
return response;
}
response.Actions.Add(new WebJobsModifyAttributeValues
{
Attributes = new Dictionary<string , string >
{
{ "displayName" , displayName.Trim() },
{ "city" , attributes?["city" ]?.ToString()?.ToUpperInvariant() ?? "" }
}
});
return response;
}
}
5. Custom OTP Delivery Send one-time passwords via custom channels (SMS, email, push notification).
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.AuthenticationEvents;
using Microsoft.Azure.WebJobs.Extensions.AuthenticationEvents.Framework;
using Microsoft.Extensions.Logging;
public static class CustomOtpFunction
{
[FunctionName("OnOtpSend" ) ]
public static async Task<WebJobsAuthenticationEventResponse> Run (
[WebJobsAuthenticationEventsTrigger] WebJobsOnOtpSendRequest request,
ILogger log )
{
var response = new WebJobsOnOtpSendResponse();
string ? phoneNumber = request.Data?.OtpContext?.Identifier;
string ? otp = request.Data?.OtpContext?.OneTimeCode;
if (string .IsNullOrEmpty(phoneNumber) || string .IsNullOrEmpty(otp))
{
log.LogError("Missing phone number or OTP" );
response.Actions.Add(new WebJobsOnOtpSendFailed
{
Error = "Missing required data"
});
return response;
}
try
{
await SendSmsAsync(phoneNumber, $"Your verification code is: {otp} " );
response.Actions.Add(new WebJobsOnOtpSendSuccess());
log.LogInformation("OTP sent successfully to {PhoneNumber}" , phoneNumber);
}
catch (Exception ex)
{
log.LogError(ex, "Failed to send OTP" );
response.Actions.Add(new WebJobsOnOtpSendFailed
{
Error = "Failed to send verification code"
});
}
return response;
}
private static async Task SendSmsAsync (string phoneNumber, string message )
{
await Task.CompletedTask;
}
}
6. Function App Configuration Configure the Function App for authentication events.
using Microsoft.Extensions.Hosting;
var host = new HostBuilder()
.ConfigureFunctionsWorkerDefaults()
.Build();
host.Run();
{
"version" : "2.0" ,
"logging" : {
"applicationInsights" : {
"samplingSettings" : {
"isEnabled" : true
}
}
} ,
"extensions" : {
"http" : {
"routePrefix" : ""
}
}
}
{
"IsEncrypted" : false ,
"Values" : {
"AzureWebJobsStorage" : "UseDevelopmentStorage=true" ,
"FUNCTIONS_WORKER_RUNTIME" : "dotnet"
}
}
Key Types Reference Type Purpose WebJobsAuthenticationEventsTriggerAttributeFunction trigger attribute WebJobsTokenIssuanceStartRequestToken issuance event request WebJobsTokenIssuanceStartResponseToken issuance event response WebJobsProvideClaimsForTokenAction to add claims WebJobsAttributeCollectionStartRequestAttribute collection start request WebJobsAttributeCollectionStartResponseAttribute collection start response WebJobsAttributeCollectionSubmitRequestAttribute submission request WebJobsAttributeCollectionSubmitResponseAttribute submission response WebJobsSetPrefillValuesPrefill form values WebJobsShowBlockPageBlock user with message WebJobsShowValidationErrorShow validation errors WebJobsModifyAttributeValuesModify submitted values WebJobsOnOtpSendRequestOTP send event request WebJobsOnOtpSendResponseOTP send event response WebJobsOnOtpSendSuccessOTP sent successfully WebJobsOnOtpSendFailedOTP send failed WebJobsContinueWithDefaultBehaviorContinue with default flow
Entra ID Configuration After deploying your Function App, configure the custom extension in Entra ID:
Register the API in Entra ID → App registrations
Create Custom Authentication Extension in Entra ID → External Identities → Custom authentication extensions
Link to User Flow in Entra ID → External Identities → User flows
Required App Registration Settings Expose an API:
- Application ID URI: api://<your-function-app-name>.azurewebsites.net
- Scope: CustomAuthenticationExtension.Receive.Payload
API Permissions:
- Microsoft Graph: User.Read (delegated)
Best Practices
Validate all inputs — Never trust request data; validate before processing
Handle errors gracefully — Return appropriate error responses
Log correlation IDs — Use CorrelationId for troubleshooting
Keep functions fast — Authentication events have timeout limits
Use managed identity — Access Azure resources securely
Cache external data — Avoid slow lookups on every request
Test locally — Use Azure Functions Core Tools with sample payloads
Monitor with App Insights — Track function execution and errors
Error Handling [FunctionName("OnTokenIssuanceStart" ) ]
public static WebJobsAuthenticationEventResponse Run (
[WebJobsAuthenticationEventsTrigger] WebJobsTokenIssuanceStartRequest request,
ILogger log )
{
try
{
var response = new WebJobsTokenIssuanceStartResponse();
response.Actions.Add(new WebJobsProvideClaimsForToken
{
Claims = new Dictionary<string , string > { { "claim" , "value" } }
});
return response;
}
catch (Exception ex)
{
log.LogError(ex, "Error processing token issuance event" );
return new WebJobsTokenIssuanceStartResponse();
}
}
Related SDKs SDK Purpose Install Microsoft.Azure.WebJobs.Extensions.AuthenticationEventsAuth events (this SDK) dotnet add package Microsoft.Azure.WebJobs.Extensions.AuthenticationEventsMicrosoft.Identity.WebWeb app authentication dotnet add package Microsoft.Identity.WebAzure.IdentityAzure authentication dotnet add package Azure.Identity
Reference Links
When to Use This skill is applicable to execute the workflow or actions described in the overview.
Limitations
Use this skill only when the task clearly matches the scope described above.
Do not treat the output as a substitute for environment-specific validation, testing, or expert review.
Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.