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, 2019 in Azure by sabby
• 4,370 points
7,406 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.


Hope this helps!!

If you need to know more about Azure, then you should join Microsoft Azure certification course today.

Thank you!!

answered Apr 25, 2019 by Prerna
• 1,960 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
3,604 views
0 votes
1 answer
+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
2,243 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
1,606 views
0 votes
1 answer

How to install Windows Azure Storage Emulator?

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

answered Mar 7, 2019 in Azure by Prerna
• 1,960 points
2,833 views
0 votes
1 answer

Azure Storage Emulator shows error.

Check if you are running BitTorrent/uTorrent or similar ...READ MORE

answered Mar 16, 2019 in Azure by Prerna
• 1,960 points
1,741 views
0 votes
1 answer

Friendly filename when downloading Azure blob.

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

answered Mar 16, 2019 in Azure by Prerna
• 1,960 points
3,809 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, 2019 in Azure by Prerna
• 1,960 points
12,635 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 26, 2019 in Azure by Prerna
• 1,960 points
7,236 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, 2019 in Azure by Prerna
• 1,960 points

edited Oct 7, 2021 by Sarfaraz 1,499 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP