dotnet/orleans · error · ArgumentNullException

Value cannot be null. (Parameter 'serviceUri')

Error message

Value cannot be null. (Parameter 'serviceUri')

What it means

Thrown by AzureStorageOperationOptions.SetTableServiceClient(Uri serviceUri) when the URI is null. This single-argument overload (anonymous/public endpoint) cannot proceed without a target, so the guard fires immediately. Reached via the obsolete ConfigureTableServiceClient(Uri).

Source

Thrown at src/Azure/Shared/Storage/AzureStorageOperationOptions.cs:132

        /// <summary>
        /// Configures the <see cref="TableServiceClient"/> using an authenticated service URI and a <see cref="TableSharedKeyCredential"/>.
        /// </summary>
        [Obsolete($"Set the {nameof(TableServiceClient)} property directly.")]
        public void ConfigureTableServiceClient(Uri serviceUri, TableSharedKeyCredential sharedKeyCredential)
        {
            SetTableServiceClient(serviceUri, sharedKeyCredential);
        }

        internal void SetTableServiceClient(string connectionString)
        {
            if (string.IsNullOrWhiteSpace(connectionString)) throw new ArgumentNullException(nameof(connectionString));
            _tableServiceClient = null;
            CreateClient = () => Task.FromResult(new TableServiceClient(connectionString, GetTableClientOptions()));
        }

        internal void SetTableServiceClient(Uri serviceUri)
        {
            if (serviceUri is null) throw new ArgumentNullException(nameof(serviceUri));
            _tableServiceClient = null;
            CreateClient = () => Task.FromResult(new TableServiceClient(serviceUri, GetTableClientOptions()));
        }

        internal void SetTableServiceClient(Uri serviceUri, TokenCredential tokenCredential)
        {
            if (serviceUri is null) throw new ArgumentNullException(nameof(serviceUri));
            if (tokenCredential is null) throw new ArgumentNullException(nameof(tokenCredential));
            _tableServiceClient = null;
            CreateClient = () => Task.FromResult(new TableServiceClient(serviceUri, tokenCredential, GetTableClientOptions()));
        }

        internal void SetTableServiceClient(Uri serviceUri, AzureSasCredential azureSasCredential)
        {
            if (serviceUri is null) throw new ArgumentNullException(nameof(serviceUri));
            if (azureSasCredential is null) throw new ArgumentNullException(nameof(azureSasCredential));
            _tableServiceClient = null;
            CreateClient = () => Task.FromResult(new TableServiceClient(serviceUri, azureSasCredential, GetTableClientOptions()));

View on GitHub (pinned to fca799fa70)

Solutions

  1. Supply a non-null absolute table service URI, or set TableServiceClient directly.
  2. Bind and validate the endpoint setting before calling configure.
  3. Prefer constructing the client yourself and assigning TableServiceClient.

Example fix

// before
options.ConfigureTableServiceClient(uri);  // uri is null
// after
var uri = new Uri(config["TableServiceUrl"] ?? throw new InvalidOperationException("Missing TableServiceUrl"));
options.TableServiceClient = new TableServiceClient(uri);
Defensive patterns

Strategy: validation

Validate before calling

var uri = optionsUri ?? throw new ArgumentNullException(nameof(optionsUri));
options.TableServiceClient = new TableServiceClient(uri);

Type guard

static bool IsUriReady(Uri? u) => u is not null && u.IsAbsoluteUri;

Try / catch

catch (ArgumentNullException ex) when (ex.ParamName == "serviceUri") { /* bind and validate the endpoint setting */ }

Prevention

When it happens

Trigger: Calling ConfigureTableServiceClient(serviceUri) where serviceUri is null — usually because a configured endpoint URL was not present.

Common situations: Endpoint URL missing from configuration; wrong key name when reading the table endpoint; environment-specific config not deployed.

Related errors


AI-assisted analysis of dotnet/orleans@fca799fa70 (2026-08-13). Data as JSON: /api/errors/6a75d1fabd762718. Report an issue: GitHub.