arolariu.Backend.Common.Azure
arolariu.Backend.Common
arolariu.Backend.Common.Azure Namespace
Classes
AzureCredentialFactory Class
Centralized singleton factory for creating Azure credentials. Ensures consistent credential configuration across all Azure service clients.
public static class AzureCredentialFactory
Inheritance System.Object 🡒 AzureCredentialFactory
Remarks
Azure.Identity.DefaultAzureCredential handles token lifecycle internally — it caches tokens and requests fresh ones ~5 minutes before expiry. A singleton is safe and recommended to avoid redundant token acquisitions.
In RELEASE builds, uses AZURE_CLIENT_ID for User Assigned Managed Identity. In DEBUG builds, falls back to Azure CLI, Visual Studio, etc.
Methods
AzureCredentialFactory.CreateCredential() Method
Returns the shared Azure.Core.TokenCredential instance. Thread-safe, lazy-initialized, and never expires (Azure SDK refreshes tokens internally).
public static Azure.Core.TokenCredential CreateCredential();
Returns
BearerTokenHandler Class
DelegatingHandler that acquires a Bearer token from Azure Identity and attaches it to outgoing HTTP requests.
public sealed class BearerTokenHandler : System.Net.Http.DelegatingHandler
Inheritance System.Object 🡒 System.Net.Http.HttpMessageHandler 🡒 System.Net.Http.DelegatingHandler 🡒 BearerTokenHandler
Constructors
BearerTokenHandler(TokenCredential, string) Constructor
DelegatingHandler that acquires a Bearer token from Azure Identity and attaches it to outgoing HTTP requests.
public BearerTokenHandler(Azure.Core.TokenCredential credential, string scope);
Parameters
credential Azure.Core.TokenCredential
The Azure token credential used to acquire tokens.
scope System.String
The scope to request when acquiring the token.