Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to get blob-URL after file upload in azure

I'm trying to connect web and worker role. So i have a page where user can upload video files. Files are large so i can't use the query to send files. That's why i'm trying to upload them into the Blob Storage and then send the url by the query. But i don't know how to get this url.

Can anyone help me?

like image 772
Stasy Concelgoger Avatar asked Jun 06 '13 12:06

Stasy Concelgoger


People also ask

What is blob URI in Azure?

The URI to reference a container or a blob must be unique. Because every account name is unique, two accounts can have containers with the same name. However, within a given storage account, every container must have a unique name. Every blob within a given container must also have a unique name within that container.


1 Answers

Assuming you're uploading the blobs into blob storage using .Net storage client library by creating an instance of CloudBlockBlob, you can get the URL of the blob by reading Uri property of the blob.

static void BlobUrl() {     var account = new CloudStorageAccount(new StorageCredentials(accountName, accountKey), true);     var cloudBlobClient = account.CreateCloudBlobClient();     var container = cloudBlobClient.GetContainerReference("container-name");     var blob = container.GetBlockBlobReference("image.png");     blob.UploadFromFile("File Path ....");//Upload file....      var blobUrl = blob.Uri.AbsoluteUri; } 

View example on Pastebin

like image 55
Gaurav Mantri Avatar answered Oct 01 '22 02:10

Gaurav Mantri