Search code examples
c#azureblobstorage

Azure blob reference to file with question mark in the name


I have a blob in a container called 'a' at 'b/123?/1.xml' and I'm having trouble deleting it via a cloudclient.

string blobAddressUri = "b/123%3f/1.xml";
var cloudBlobContainer = csa.CreateCloudBlobClient().GetContainerReference("ndrdata");
var blobToDelete = cloudBlobContainer.GetBlobReference(HttpUtility.UrlEncode(blobAddressUri));
            blobToDelete.Delete();

This is the code I've tried with different variations on using ? vs %3f. and not UrlEncoding the string.

I can access the file if I generate a SAS uri through CloudBerry and then replace the '?' with %3f.

Thanks for any help.


Solution

  • What version of Storage Client library you're using? I used version 1.7.0 and used the following code against development storage and it worked fine for me.

                var storage = CloudStorageAccount.DevelopmentStorageAccount;
            string blobAddressUri = "b/123?/MainWindow.xaml";
            var cloudBlobContainer = storage.CreateCloudBlobClient().GetContainerReference("abc");
            var blobToDelete = cloudBlobContainer.GetBlobReference(blobAddressUri);
            blobToDelete.Delete();