azure-sdk-for-net: [BUG] SasQueryParameters unable to parse multiple DateTime query parameters from a Uri authenticated with a Sas Token
Describe the bug
GetBlobClient
is unable to parse my Uri if I have multiple date query parameters. Note that I am using a SAS token generated from an azure storage using version 2017-04-17.
Expected behavior What is the expected behavior? I would expect that the query string would be able to be parsed and if it was invalid I would hit a 403 web request error.
Actual behavior (include Exception or Stack Trace) What is the actual behavior? I hit a Format Exception at SasQueryParameters…ctor(IDictionary`2 values)
See exception detail here:
Exception Type: System.FormatException
Error message: String was not recognized as a valid DateTime.
at System.DateTimeParse.ParseExact(String s, String format, DateTimeFormatInfo dtfi, DateTimeStyles style, TimeSpan& offset)
at System.DateTimeOffset.ParseExact(String input, String format, IFormatProvider formatProvider, DateTimeStyles styles)
at Azure.Storage.Sas.SasQueryParameters..ctor(IDictionary`2 values)
at Azure.Storage.Blobs.BlobUriBuilder..ctor(Uri uri)
at Azure.Storage.Blobs.BlobContainerClient.GetBlobClient(String blobName)
To Reproduce Steps to reproduce the behavior (include a code snippet, screenshot, or any additional information that might help us reproduce the issue)
I am able to reproduce using Linqpad that while I am able to use the containerService, the blob service fails. I’ve redacted identifying information, but the below code will still error out since we fail before issuing the web request.
void Main()
{
var baseUrl1 = "https://serviceAccountName.blob.core.windows.net/";
var queryString1 = "sv=2017-04-17&sp=rl&sr=c&sig={redacted}&se=2020-12-25";
var uri1 = new UriBuilder(baseUrl1)
{
Query = queryString1
}.Uri;
var serviceClient = new BlobServiceClient(uri1);
var container = serviceClient.GetBlobContainerClient("aptdata");
var blobClient = container.GetBlobClient("randomBlob"); // fails here
}
The same information works using the Azure CLI
Environment:
- Name and version of the Library package used:
AzureStorageBlobs v. 12.6.0
- Hosting platform or OS and .NET runtime version (
dotnet --info
output for .NET Core projects):
.NET Core SDK (reflecting any global.json):
Version: 3.1.200
Commit: c5123d973b
Runtime Environment:
OS Name: Windows
OS Version: 10.0.18363
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\3.1.200\
Host (useful for support):
Version: 3.1.2
Commit: 916b5cba26
.NET Core SDKs installed:
2.1.4 [C:\Program Files\dotnet\sdk]
2.1.202 [C:\Program Files\dotnet\sdk]
2.1.509 [C:\Program Files\dotnet\sdk]
3.1.200 [C:\Program Files\dotnet\sdk]
.NET Core runtimes installed:
Microsoft.AspNetCore.All 2.1.13 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.16 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.13 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.16 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.0.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.13 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.16 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 3.1.2 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
- IDE and version : Visual Studio v. 16.5.0
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 1
- Comments: 15 (8 by maintainers)
I have merged a PR with a fix, it will go out with next next release.
We know about the issue, I’m going to look into trying to fix it later this week.
Hi @hikarunoryoma, I can reproduce this issue and am investigating.