abpframework/abp · error · AbpException

Either Region or ServiceURL must be configured on AwsBlobPro

Error message

Either Region or ServiceURL must be configured on AwsBlobProviderConfiguration.

What it means

Thrown by DefaultAmazonS3ClientFactory.GetAmazonS3Client when neither AwsBlobProviderConfiguration.Region nor ServiceURL is configured (both null/whitespace). The AWS SDK requires at least one to build an AmazonS3Config, so ABP fails fast with an AbpException before constructing the client. Region and ServiceURL are mutually exclusive routing inputs: Region targets an AWS regional endpoint, ServiceURL targets a custom/MinIO endpoint.

Source

Thrown at framework/src/Volo.Abp.BlobStoring.Aws/Volo/Abp/BlobStoring/Aws/DefaultAmazonS3ClientFactory.cs:35

{
    protected IDistributedCache<AwsTemporaryCredentialsCacheItem> Cache { get; }

    protected IStringEncryptionService StringEncryptionService { get; }

    public DefaultAmazonS3ClientFactory(
        IDistributedCache<AwsTemporaryCredentialsCacheItem> cache,
        IStringEncryptionService stringEncryptionService)
    {
        Cache = cache;
        StringEncryptionService = stringEncryptionService;
    }

    public virtual async Task<AmazonS3Client> GetAmazonS3Client(
        AwsBlobProviderConfiguration configuration)
    {
        if (configuration.Region.IsNullOrWhiteSpace() && configuration.ServiceURL.IsNullOrWhiteSpace())
        {
            throw new AbpException(
                $"Either {nameof(AwsBlobProviderConfiguration.Region)} or {nameof(AwsBlobProviderConfiguration.ServiceURL)} must be configured on {nameof(AwsBlobProviderConfiguration)}.");
        }

        var region = !configuration.Region.IsNullOrWhiteSpace()
            ? RegionEndpoint.GetBySystemName(configuration.Region)
            : null;
        var clientConfig = await CreateS3ClientConfigAsync(configuration, region);

        if (configuration.UseCredentials)
        {
            var awsCredentials = GetAwsCredentials(configuration);
            return awsCredentials == null
                ? new AmazonS3Client(clientConfig)
                : new AmazonS3Client(awsCredentials, clientConfig);
        }

        if (configuration.UseTemporaryCredentials)
        {

View on GitHub (pinned to 7ed43b1931)

Solutions

  1. Set Region in the Aws blob configuration (e.g. "us-east-1") for standard AWS S3.
  2. For MinIO/LocalStack/custom endpoints, set ServiceURL (e.g. "http://localhost:9000") instead.
  3. Verify the configuration section is bound (Configure<AwsBlobProviderConfiguration>) and the keys match.
  4. Check that environment-specific appsettings actually override the base values.

Example fix

// before (appsettings.json)
"Aws": {
  "AccessKeyId": "...",
  "SecretAccessKey": "..."
}

// after (AWS regional)
"Aws": {
  "AccessKeyId": "...",
  "SecretAccessKey": "...",
  "Region": "us-east-1"
}

// after (MinIO / custom endpoint)
"Aws": {
  "AccessKeyId": "...",
  "SecretAccessKey": "...",
  "ServiceURL": "http://localhost:9000"
}
Defensive patterns

Strategy: validation

Validate before calling

var cfg = serviceProvider.GetRequiredService<IOptions<AwsBlobProviderConfiguration>>().Value;
if (cfg.Region.IsNullOrWhiteSpace() && cfg.ServiceURL.IsNullOrWhiteSpace())
{
    throw new InvalidOperationException("Configure AwsBlobProviderConfiguration.Region or ServiceURL.");
}

Type guard

bool awsEndpointConfigured =
    !configuration.Region.IsNullOrWhiteSpace() ||
    !configuration.ServiceURL.IsNullOrWhiteSpace();

Try / catch

try { await container.SaveAsync(name, stream); }
catch (AbpException ex) when (ex.Message.Contains("Either Region or ServiceURL"))
{ /* fix configuration before retrying */ }

Prevention

When it happens

Trigger: Calling any blob operation (Save/Get/Delete/Exists) when the AwsBlobProviderConfiguration has been registered without setting Region or ServiceURL. The factory is invoked on the first operation that needs an AmazonS3Client.

Common situations: Configuration loaded from appsettings where the Aws section is missing Region/ServiceURL, using MinIO/LocalStack without setting ServiceURL, environment-specific config not overriding the empty defaults, or a typo in the config key name.

Related errors


AI-assisted analysis of abpframework/abp@7ed43b1931 (2026-08-13). Data as JSON: /api/errors/a9ecbf77d130f6a5. Report an issue: GitHub.