How do I stream videos from Azure Blob Storage?

0 votes

I have an .mp4 video stored in Azure Blob Storage and I am unable to show it in a website hosted on Azure. The storage account is not public, but it is linked to the web role, and I've updated the version using this code:

var credentials = new StorageCredentials("myaccountname", "mysecretkey"); 
var account = new CloudStorageAccount(credentials, true); 
var client = account.CreateCloudBlobClient(); 
var properties = client.GetServiceProperties(); 
properties.DefaultServiceVersion = "2012-02-12"; 
client.SetServiceProperties(properties); 

I am only using the HTML5 video tag.

I'm out of stuff to look at, and any help and pointers are appreciated to help me play that video. Thanks!

Apr 25 in Azure by sabby
• 4,350 points
347 views

1 answer to this question.

0 votes

What you are missing is a Shared Access Signature. Try using the code below to create a SAS on your mp4 file:

        var credentials = new StorageCredentials("myaccountname", "mysecretkey");
        var account = new CloudStorageAccount(credentials, true);
        var container = account.CreateCloudBlobClient().GetContainerReference("yourcontainername");
        var blob = container.GetBlockBlobReference("yourmp4filename");
        var sas = blob.GetSharedAccessSignature(new SharedAccessBlobPolicy()
        {
            Permissions = SharedAccessBlobPermissions.Read,
            SharedAccessExpiryTime = DateTime.UtcNow.AddHours(1),//Set this date/time according to your requirements
        });
        var urlToBePlayed = string.Format("{0}{1}", blob.Uri, sas);//This is the URI which should be embedded in your video player.
answered Apr 25 by Prerna
• 1,940 points

Related Questions In Azure

0 votes
1 answer

How can i upload to Azure Blob storage with Shared Access key?

For GetBlobReferenceFromServer to work, the blob must be present ...READ MORE

answered Jun 12, 2018 in Azure by club_seesharp
• 3,450 points
775 views
+1 vote
2 answers

How do I establish an connection to Azure IoT Hub? Say a connection like MQTT/AMQP using Python.

Azure IoT Hub comes with 3 SDK's: Service SDK Device ...READ MORE

answered Apr 13, 2018 in Azure by null_void
• 3,220 points
558 views
0 votes
1 answer

How to upload a file on to Azure Blob storage without writing a code?

You can find the below tools useful ...READ MORE

answered Apr 13, 2018 in Azure by club_seesharp
• 3,450 points
134 views
+1 vote
1 answer

Can I rename a Azure Storage Blob?

Though the approach I'm about to share ...READ MORE

answered May 10, 2018 in Azure by club_seesharp
• 3,450 points
842 views
0 votes
1 answer

How to install Windows Azure Storage Emulator?

There may be an issue with the ...READ MORE

answered Mar 6 in Azure by Prerna
• 1,940 points
137 views
0 votes
1 answer

Azure Storage Emulator shows error.

This blog might help with your query: http://blog.smarx.com/posts/windows-azure-storage-emulator-the-process-cannot-access-the-file-because-it-is-being-used-by-another-process Also, ...READ MORE

answered Mar 15 in Azure by Prerna
• 1,940 points
110 views
0 votes
1 answer

Friendly filename when downloading Azure blob.

Azure blobs can be downloaded in four ...READ MORE

answered Mar 15 in Azure by Prerna
• 1,940 points
50 views
0 votes
1 answer

How to create a sub directory in a blob container?

There are two ways:  using the GetDirectoryReference looping through a containers ...READ MORE

answered Mar 26 in Azure by Prerna
• 1,940 points
632 views
0 votes
1 answer

How to download a file from Blob Storage to the browser?

If you use ASP.NET (core), you can ...READ MORE

answered Mar 25 in Azure by Prerna
• 1,940 points
334 views
0 votes
1 answer

Azure App Service Plan: how do I pause it ?

If you want to use the S1 ...READ MORE

answered Apr 3 in Azure by Prerna
• 1,940 points
34 views