Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions sdk/tables/Azure.Data.Tables/src/TableClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1405,6 +1405,10 @@ public virtual Uri GenerateSasUri(TableSasPermissions permissions, DateTimeOffse
public virtual Uri GenerateSasUri(
TableSasBuilder builder)
{
if (SharedKeyCredential == null)
Comment thread
jsquire marked this conversation as resolved.
{
throw new InvalidOperationException($"{nameof(GenerateSasUri)} requires a credential 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))
{
Expand Down
4 changes: 4 additions & 0 deletions sdk/tables/Azure.Data.Tables/src/TableServiceClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -911,6 +911,10 @@ public virtual Uri GenerateSasUri(
TableAccountSasBuilder builder)
{
Argument.AssertNotNull(builder, nameof(builder));
if (SharedKeyCredential == null)
{
throw new InvalidOperationException($"{nameof(GenerateSasUri)} requires a credential other than {nameof(TokenCredential)} in order to sign the SAS token.");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
throw new InvalidOperationException($"{nameof(GenerateSasUri)} requires a credential other than {nameof(TokenCredential)} in order to sign the SAS token.");
throw new InvalidOperationException($"{nameof(GenerateSasUri)} requires a credential that is not a {nameof(TokenCredential)} type in order to sign the SAS token.");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not in love with the suggestion, honestly... but it took me a couple of reads of the original to understand that you're looking for a shared key-based credential.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I am not in love with what I originally wrote either. I wanted to be less specific than Shared Key, since Connection String auth also works. Although the shared key is also present there, it's not explicitly a SharedKeyCredential.

What I was trying to convey with the current message is roughly - "this will fail if you used the TokenCredential ctor"

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think of this?

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.");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice.... I like that!

}

TableUriBuilder sasUri = new(_endpoint);
sasUri.Query = builder.ToSasQueryParameters(SharedKeyCredential).ToString();
Expand Down