简体   繁体   English

如何从Azure Blob存储访问图像

[英]How to access an image from azure blob storage

I have uploaded images a,b,c and d, now how do I know what is the location/address of my image b in azure blob storage(I am using c# code). 我已经上传了图像a,b,c和d,现在我如何知道我的图像b在蔚蓝斑点存储中的位置/地址是什么(我正在使用c#代码)。 I know i have a way to get the list of all images stored in container but how should i approach if ask is specific to a particular image. 我知道我有办法获取存储在容器中的所有图像的列表,但是如果询问特定于特定图像,我应该如何处理。

Any guidance should be helpful. 任何指导都应该有所帮助。

If you're using CloudBlobClient you can get the primary and secondary location of the blob: 如果您使用的是CloudBlobClient ,则可以获取Blob的主要位置和次要位置:

var storageCredentials = new StorageCredentials(accountName, keyValue);

var cloudStorageAccount = new CloudStorageAccount(storageCredentials, true);

var cloudBlobClient = cloudStorageAccount.CreateCloudBlobClient();

var container = cloudBlobClient.GetContainerReference(containerName);

var cloudBlockBlob = container.GetBlockBlobReference(blobName); // "a/b/c/d" blob names

Uri primaryLocation = cloudBlockBlob.StorageUri.PrimaryUri;
Uri secondaryLocation = cloudBlockBlob.StorageUri.SecondaryUri;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM