DataWeb
Search Results for

    Show / Hide Table of Contents

    Class ServicesConfiguration

    Dependency injection configuration for Azure Translator localization services.

    Inheritance
    object
    ServicesConfiguration
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: DataWeb.Localization.AzureTranslator
    Assembly: DataWeb.Localization.AzureTranslator.dll
    Syntax
    public static class ServicesConfiguration
    Remarks

    This configuration class sets up the Azure Translator service integration with proper HTTP client factory configuration. It validates API credentials at startup and configures the named HTTP client with required Azure authentication headers.

    Methods

    AddDataWebLocalizationAzureTranslator(IServiceCollection)

    Registers Azure Translator localization services in the dependency injection container.

    Declaration
    public static IServiceCollection AddDataWebLocalizationAzureTranslator(this IServiceCollection services)
    Parameters
    Type Name Description
    IServiceCollection services

    The service collection to register services in.

    Returns
    Type Description
    IServiceCollection

    The service collection for method chaining.

    Remarks

    This method configures:

    • A named HTTP client "AzureTranslator" with Azure Translator API credentials and authentication headers
    • Validates API key and region configuration values at startup (fail-fast approach)
    • Registers the ITranslationService implementation as a scoped service

    The Azure Translator HTTP client is configured with:

    • Ocp-Apim-Subscription-Key header for API authentication
    • Ocp-Apim-Subscription-Region header for service region specification

    Configuration is read from app settings with keys:

    • "AzureAITranslator:ApiKey" - Azure Translator API subscription key
    • "AzureAITranslator:Region" - Azure Translator service region (e.g., "eastus", "westeurope")
    Exceptions
    Type Condition
    ArgumentException

    Thrown at startup if ApiKey or Region configuration is null or empty.

    In this article
    Back to top Generated by DocFX