This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
ExAzureCore is the base library for Azure SDKs in Elixir. It provides authentication, HTTP client infrastructure, and common utilities that service-specific Azure SDKs build upon.
# Run all tests
mix test
# Run a single test file
mix test test/ex_azure_core/auth/token_server_test.exs
# Run tests matching a pattern
mix test --only integration
# Code quality
mix format # Format code
mix credo # Lint
mix dialyzer # Type checking
mix sobelow # Security scanning
mix recode # Additional style checks
# All checks at once
mix checkExAzureCore.request(operation) → Config Resolution → HTTP Client + Plugins → Azure REST API
The library uses a protocol-based design where service SDKs define operations implementing ExAzureCore.Operation.
ExAzureCore- Public API (request/2,request!/2,stream!/2)ExAzureCore.Config- 4-level config hierarchy (defaults → global → service → per-request)ExAzureCore.Operation- Protocol for service operations;Operation.RESTis the main implementationExAzureCore.Http.Client- Req-based HTTP client with plugin architecture
Token management uses GenServers registered in ExAzureCore.Auth.Registry:
Auth.TokenServer- Manages token lifecycle with proactive refresh before expiryAuth.TokenSource- Behavior for token fetching strategies:TokenSource.ClientAssertion- Federation (AWS Cognito, GitHub Actions, K8s)TokenSource.ManagedIdentity- Azure managed identity (IMDS, App Service, AKS)TokenSource.WorkloadIdentity- AKS workload identity
Plugins compose into the request pipeline:
BearerToken/ApiKey/SasToken/SharedKey- Auth methodsAzureHeaders- Addsx-ms-version,x-ms-dateRetry- Exponential backoff for transient failures (408, 429, 5xx)ErrorHandler- Transforms HTTP errors to Splode errors
Three credential types (mirrors Azure Python SDK):
AzureKeyCredential- API keysAzureSasCredential- SAS tokensAzureNamedKeyCredential- Account name + key pairs
Uses Splode for structured errors. Error modules are in ExAzureCore.Errors.* and ExAzureCore.Auth.Errors.*.
Tests use Mimic for mocking. All mockable modules are registered in test/test_helper.exs. Most auth tests use async: false due to shared Registry state.
Pattern for mocking:
use ExUnit.Case, async: false
use Mimic
setup :set_mimic_from_context