You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if (includeUrl) {
string url = new Uri(_client.Uri, StoragePath.Normalize(fullPath)).ToString();
url += "?";
url += sas;
return url;
}
Typically, the _client.Uri will be something like https://myaccount.blob.core.windows.net/ or similar. However, when using Azurite, it's something like http://127.0.0.1:51256/devstoreaccount1/, with the devstoreaccount1 part being important.
In the function above, the fullPath should be something like container/name. However, StoragePath.Normalize is returning /container/name, and I don't understand why. This code here is doing it, removeTrailingSlash is false here:
This makes no sense -- if "remove trailing slash" is false, the method.. prepends a slash? Also, given how this method is implemented, it's impossible for there to ever be a leading or trailing slash here. It splits the path by the separator with RemoveEmptyEntries and then recombines it.
All of this leads to the Uri() constructor stripping devstoreaccount1 from the base Uri. There's an additional subtle bug here -- connection strings for Azurite include a BlobEndpoint=http://127.0.0.1:51256/devstoreaccount1 (note lack of trailing slash). This works until a Uri constructor is used like the above -- Uri will strip off the last base path element if it doesn't end in a /.
The text was updated successfully, but these errors were encountered:
vvuk
changed the title
Broken StoragePath.Normalize, leading to broken Azure SAS URLs when using Azurite --
Broken StoragePath.Normalize, leading to broken Azure SAS URLs when using Azurite
Dec 20, 2024
Azure SAS URLs are created here in AzureBlobStorage using:
Typically, the
_client.Uri
will be something likehttps://myaccount.blob.core.windows.net/
or similar. However, when using Azurite, it's something likehttp://127.0.0.1:51256/devstoreaccount1/
, with thedevstoreaccount1
part being important.In the function above, the fullPath should be something like
container/name
. However,StoragePath.Normalize
is returning/container/name
, and I don't understand why. This code here is doing it,removeTrailingSlash
isfalse
here:This makes no sense -- if "remove trailing slash" is false, the method.. prepends a slash? Also, given how this method is implemented, it's impossible for there to ever be a leading or trailing slash here. It splits the path by the separator with
RemoveEmptyEntries
and then recombines it.All of this leads to the
Uri()
constructor strippingdevstoreaccount1
from the base Uri. There's an additional subtle bug here -- connection strings for Azurite include aBlobEndpoint=http://127.0.0.1:51256/devstoreaccount1
(note lack of trailing slash). This works until a Uri constructor is used like the above -- Uri will strip off the last base path element if it doesn't end in a/
.The text was updated successfully, but these errors were encountered: