Azure / azure-sdk-for-go

This repository is for active development of the Azure SDK for Go. For consumers of the SDK we recommend visiting our public developer docs at:
https://docs.microsoft.com/azure/developer/go/
MIT License
1.65k stars 844 forks source link

[azblob] BlobURLParts does not support VersionID #17188

Closed hy3 closed 2 years ago

hy3 commented 2 years ago

Bug Report

I'm using Azure Blob Storage with version management, and want to download old version with this SDK. So, I tried to use BlobClient.WithVersionID() or BlobURLParts.VersionID , but both of them didn't work. Because BlobURLParts outputs URL without VersionID, nevertheless preview SDK does it. ( ref. )

If it is as expected, please tell me how to download blob by Version ID with the SDK. I avoiding this issue by editing URL directly, but It doesn't look smart way.

u, _ := url.Parse(blobClient.URL())

q := u.Query()
q.Set("versionId", versionID)
u.RawQuery = q.Encode()

newBlobClient, _ := azblob.NewBlobClient(u.String(), cred, nil)
amishra-dev commented 2 years ago

Thanks for this report @hy3. Currently there maynot be a way to do this other than edit URL @mohsha-msft to confirm.

mohsha-msft commented 2 years ago

Hey @hy3 ,

Thanks for reaching out!

Yes this is indeed a bug at our end. Somehow it got escaped from our tests. I apologize for inconvenience. I've raised a request to fix it and added more tests to make sure this doesn't happen in future. We'll ship it in next release. In the meantime, you can pull the changes from my branch by using the command

go get github.com/Azure/azure-sdk-for-go/sdk/storage/azblob@mohsha-msft-azblob-fix-versioning-bug

Please reach out for any clarification!

hy3 commented 2 years ago

@mohsha-msft @amishra-dev Thanks for your reply. I got it. I'm looking forward to next release.

hy3 commented 2 years ago

@mohsha-msft I found same bug on NewBlobURLParts() not only on BlobURLParts.URL() . Your commit does not include it. Please fix it too.

This is example in azure-storage-blob-go . https://github.com/Azure/azure-storage-blob-go/blob/b32b5e3579400739418747a71c4bffaf8a19c4a0/azblob/parsing_urls.go#L98-L103

mohsha-msft commented 2 years ago

Fixed in main. Target release for next release.

@hy3, can you give it a try and let me know if the issue is persisting?

hy3 commented 2 years ago

@mohsha-msft It works 🎉

However, through my trying, I found that BlobClient.WithVersionID() returns not BlobClient but BlockBlobClient . Would you fix it too ?

screenshot

mohsha-msft commented 2 years ago

Yes that's correct. It'll be fixed too..

I'm glad it worked for your. I am sorry for the inconviniece caused. As you know we're still in preview version and still trying things. I will appreciate your efforts/feedbacks on the findings.

hy3 commented 2 years ago

Thanks a lot !

The SDK is already a big help for me. I'll continue to use it and give feedback on it. I'm looking forward to its stable release :+1:

mohsha-msft commented 2 years ago

Hey @hy3 ,

azblob v0.4.0 is now publically available. I have fixed the issue here and here.

Please reach out and reopen the issue if it still persists.

Thanks a lot for your feedbacks!