diff --git a/sdk/tables/Azure.Data.Tables/src/TableClient.cs b/sdk/tables/Azure.Data.Tables/src/TableClient.cs index 22f4c74cf079..1dddd3280040 100644 --- a/sdk/tables/Azure.Data.Tables/src/TableClient.cs +++ b/sdk/tables/Azure.Data.Tables/src/TableClient.cs @@ -1405,6 +1405,10 @@ public virtual Uri GenerateSasUri(TableSasPermissions permissions, DateTimeOffse public virtual Uri GenerateSasUri( TableSasBuilder builder) { + if (SharedKeyCredential == null) + { + throw new InvalidOperationException($"{nameof(GenerateSasUri)} requires that this client be constructed with a credential type other than {nameof(TokenCredential)} in order to sign the SAS token."); + } builder = builder ?? throw Errors.ArgumentNull(nameof(builder)); if (!builder.TableName.Equals(Name, StringComparison.InvariantCulture)) { diff --git a/sdk/tables/Azure.Data.Tables/src/TableServiceClient.cs b/sdk/tables/Azure.Data.Tables/src/TableServiceClient.cs index 6b54a1da23cf..6b7feaec156f 100644 --- a/sdk/tables/Azure.Data.Tables/src/TableServiceClient.cs +++ b/sdk/tables/Azure.Data.Tables/src/TableServiceClient.cs @@ -911,6 +911,10 @@ public virtual Uri GenerateSasUri( TableAccountSasBuilder builder) { Argument.AssertNotNull(builder, nameof(builder)); + if (SharedKeyCredential == null) + { + throw new InvalidOperationException($"{nameof(GenerateSasUri)} requires that this client be constructed with a credential type other than {nameof(TokenCredential)} in order to sign the SAS token."); + } TableUriBuilder sasUri = new(_endpoint); sasUri.Query = builder.ToSasQueryParameters(SharedKeyCredential).ToString();