I'm using the Azure.Storage.Blobs SDK version 12.7 in C# with .net core and I want to access a blob directly by it's URI using the blob storage connection string for deletion.
How would I do that?
I assume I can use the BlobClient class, which constructor takes the URI, but then im not authorized. The constructor takes also a StorageSharedKeyCredential, but how can I create it from the connection string?
You can create StorageSharedKeyCredential in this way. Note that it uses the key instead of the connection string:
StorageSharedKeyCredential storageSharedKeyCredential = new StorageSharedKeyCredential(<your-account-name>,<your-account-key>)
You can refer to this official document.
By the way, if you want to use connection string, you can use this way:
BlobServiceClient blobServiceClient = new BlobServiceClient(connectionString);
BlobContainerClient containerClient = blobServiceClient.GetBlobContainerClient(<you-container-name>)
BlobClient blobClient = containerClient.GetBlobClient(fileName);
Please refer to this official document.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With