This Azure tutorial, we will discuss what is azure blob storage? How we can use Azure blob storage for video streaming? Also, we will see how to create Azure Storage using PowerShell and upload video files into Azure Container.
We will also discuss, how to copy blobs from one storage container to another storage Container in Microsoft Azure using PowerShell. And, how to download Blobs from Azure Container using PowerShell.
SharePoint 2016 Tutorial Contents
- Azure Blob Storage video streaming and performance: do you have a similar requirement?
- Azure Blob Storage
- Azure CDN
- Create Azure Storage using PowerShell and upload a video file
- Copy blobs from one storage container to another storage Container in Microsoft Azure
- Download Blobs from Azure Container using PowerShell
Azure Blob Storage video streaming and performance: do you have a similar requirement?
We had come across with requirement for one of the projects where the application was completely moved to Azure. The application had many video file reference which was earlier maintained in on-premise Server and there was lots of performance issue client was facing.
The application was used globally and performance was a big concern. We have multiple ways to handle the scenario and provide a solution.
We recommended the implementation approach with Azure Blob and Azure CDN.
So let’s talk more in detail.
Azure Blob Storage
We usually recommend to use Azure Blob storage for storing large amounts of unstructured data (e.g. – video, audio, images, documents, etc.). We can store the data publicly or privately as well.
Let’s understand Blob components which include a storage account, container, and blob.
We definitely need an Azure storage account (standard and premium) which will be used to store and access data objects. It also gives you storage services which include files, tables, blobs, azure virtual machine disk, and queues.
Next is a Container which will be used to keep an unlimited number of blobs and we can unlimited number of a container with our storage account.
The final component is blob which is file type and provided below types of a blob.
- Page Blobs – used for a high speed read/write operation.
- Block Blobs – used to store text, documents, and media files.
- Append Blobs – Optimized blocks used to make the operation efficient.
The further code needs to be written to create a storage account, container (one or many) and upload a blob to the respective container.
I have already posted an understanding of Azure CDN and its use. For our solution, we used CDN for better performance.
Create a CDN profile and CDN endpoint based on your application geographic need.
So your Azure storage account is integrated with Azure CDN to provide better performance for media files.
Create Azure Storage using PowerShell and upload a video file
Here, we will see how to create azure storage using PowerShell and upload video files into it.
What is the use of Azure Container?
I will explain in a simple one-line statement. Containers are basically used to pack many applications into a single physical server.
Azure Container Service provides simplified configuration to create, configure and manage cluster virtual machines. It provides a container hosting environment with the help of open-source tools to host your application.
We can create a container using the below PowerShell script. Make sure you have installed Azure PowerShell.
Refer to this link for Azure PowerShell download and installation process.
PowerShell Script to create Azure Container and upload video blob files.
$SubscriptionName = "StorageSubscription" $StorageAccountName = "samstorage" $Location = "West US" $ContainerName = "videocontainer" $VideoToUpload = "D:\Sam\Videos\Sample.wmv" Add-AzureAccount Select-AzureSubscription -SubscriptionName $SubscriptionName –Default New-AzureStorageAccount –StorageAccountName $StorageAccountName -Location $Location Set-AzureSubscription -CurrentStorageAccountName $StorageAccountName -SubscriptionName $SubscriptionName New-AzureStorageContainer -Name $ContainerName -Permission Off # Upload a blob into a container. Set-AzureStorageBlobContent -Container $ContainerName -File $VideoToUpload
Copy blobs from one storage container to another storage Container in Microsoft Azure
Now, we will see how to copy blobs from one storage container to another storage Container in Microsoft Azure. We had a further requirement to move the files from one container to another container in Azure.
As I have mentioned in my earlier blogs we can achieve by console application and PowerShell script.
Below is the PowerShell script to Copy blobs from one storage container to another storage Container in Microsoft Azure.
We will have to define source and destination storage account details to copy the blobs.
Please find the code below. Hope it will be helpful.
$srcAcc = "samstorage" $srcAccKey = "*************************** ==" $srccontName = "srcvideocontainer" $srcctx = New-AzureStorageContext -StorageAccountName $srcAcc -StorageAccountKey $srcAccKey $destAcc = "deststorage" $destAccKey = "*************************** ==" $destcontName = "destcontainername" $destctx = New-AzureStorageContext -StorageAccountName $destcontName -StorageAccountKey $destAccKey #source container reference $blobs = Get-AzureStorageBlob -Container $srccontName -Context $srcctx #Copy blobs $blobs| Start-AzureStorageBlobCopy -DestContainer $destcontName -DestContext $destctx
Download Blobs from Azure Container using PowerShell
Now, we will see how to download blobs from Azure container using PowerShell script.
There will also a requirement to download blob files to a local folder. We can write a console application or PowerShell script to get it done.
I am sharing the PowerShell script to download blobs from a specific container. If you have more than one container create an input CSV file to maintain the container name and respective destination folder. Write an additional loop code with the input CSV to automate the process.
$subname = "StorageSubscription" $stAcc = "samstorage" $stKey = "*************************** ==" $contName = "videocontainer" $DestinationFolder = "D:\Sam\Videos" $ctx = New-AzureStorageContext -StorageAccountName $stAcc -StorageAccountKey $stKey $blobs = Get-AzureStorageBlob -Container $contName -Context $ctx #Download blobs from a container. New-Item -Path $DestinationFolder -ItemType Directory -Force $blobs | Get-AzureStorageBlobContent -Destination $DestinationFolder -Context $ctx
You may like following Azure tutorials:
- Distribute user requests Azure Web site instances in Microsoft Azure
- Create Azure WebJobs for SharePoint Online and Deploy to Microsoft Azure
- Create a Web API for SharePoint Online and Deploy to Microsoft Azure using Visual Studio (Step by Step tutorial)
- Create Configure and Use SQL Server Database using Microsoft Azure
- Storage Analytics Data Retention Policy in Microsoft Azure
- Create a web app in Microsoft Azure step by step tutorial
- How to create a Microsoft Azure Active Directory?
- How to create SQL Database in Microsoft Windows Azure Portal?
- How to get Azure AD app-only access token and using Microsoft graph Api to interact with Azure Active Directory
- Learn azure artificial intelligence
- Create Azure Web App and Download Publish Profile from Azure Portal
- Design Windows Azure Application with Azure Table partitioning approach
- Blob Cache in SharePoint Tutorial
This Azure tutorial, we learned below things:
- What is azure blob storage?
- What is azure CDN?
- How to create Azure Storage using PowerShell and upload a video file into the azure container?
- How to Copy blobs from one storage container to another storage Container in Microsoft Azure?
- How to download Blobs from Azure Container using PowerShell?
I have 9 years of exprience into SharePoint implementation, architecture, Administrator, development and Training.Designing Information Architecture in SharePoint 2007, 2010,2013 and Office 365.
Download SharePoint Online Tutorial PDF FREE!
Get update on Webinars, video tutorials, training courses etc.