dotnet/orleans · error · ArgumentNullException

Value cannot be null. (Parameter 'azureSasCredential')

Error message

Value cannot be null. (Parameter 'azureSasCredential')

What it means

Thrown by AzureStorageOperationOptions.SetTableServiceClient(Uri, AzureSasCredential) when the AzureSasCredential is null. The SAS credential carries the signed token; without it authentication is impossible.

Source

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

        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()));
        }

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

        internal TableClientOptions GetTableClientOptions()
        {
            var clientOptions = ClientOptions ??= new TableClientOptions();
            ConfigureRetryOptions(clientOptions.Retry, StoragePolicyOptions);
            return clientOptions;
        }

View on GitHub (pinned to fca799fa70)

Solutions

  1. Build a non-null AzureSasCredential from a valid SAS query string, or set TableServiceClient directly.
  2. Read the SAS from a secret manager and validate it is present.
  3. Prefer constructing the client yourself.

Example fix

// before
options.ConfigureTableServiceClient(uri, sasCredential); // sasCredential null
// after
var sas = secrets["TableSasToken"] ?? throw new InvalidOperationException("Missing TableSasToken");
options.TableServiceClient = new TableServiceClient(uri, new AzureSasCredential(sas));
Defensive patterns

Strategy: validation

Validate before calling

var sas = secrets["TableSasToken"] ?? throw new InvalidOperationException("Missing TableSasToken");
options.TableServiceClient = new TableServiceClient(serviceUri, new AzureSasCredential(sas));

Type guard

static bool HasSas(AzureSasCredential? c) => c is not null;

Try / catch

catch (ArgumentNullException ex) when (ex.ParamName == "azureSasCredential") { /* load the SAS token from the secret store */ }

Prevention

When it happens

Trigger: Calling ConfigureTableServiceClient(uri, sas) with a valid uri but a null AzureSasCredential — typically the SAS token was never read from config/secrets.

Common situations: SAS token not stored in the secret store; expired/rotated token leading to code path that constructs null; misnamed config key.

Related errors


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