Mounting Azure File Share As Volumes In Azure Containers – Step By Step Demo

When storing your software knowledge, it is strongly recommended that you shouldn’t instantly retailer it in your Docker container.  Doing that will imply that the lifetime of your knowledge and the lifetime of your container are certain collectively, which, in flip, prevents you from updating to a brand new model of the container with out shedding your knowledge. You’ll clearly need to persist your knowledge and to try this, you would need to retailer it in an connected quantity.


Presently, the very best appropriate choice for doing that with Azure Container Situations is to connect an Azure file share. Within the close to future, nevertheless, Azure Container Situations will most likely help mounting Azure disks and even blob storage containers. All you want for now could be a file share and as you already know, file shares may be created inside an Azure Storage account.


Then if we need to mount that file share to our container once we create it with Azure CLI, we would wish a set of 4 arguments that will permit us to configure it. We’ll see the arguments additional through the demo half.


There are some limitations to this as properly,

  1. You’ll be able to solely mount the entire share and never the subfolders inside it.
  2. Share can’t be mounted as read-only.
  3. You’ll be able to mount a number of volumes however not with Azure CLI and must use ARM templates as a substitute.
  4. They aren’t supported on Home windows Containers as of but and that limits the usefulness of Home windows Containers in the intervening time

On this demo, we are going to create an Azure Container Occasion and mount an Azure File Share as a quantity which we are going to use to extract a thumbnail from a video utilizing the open-source FFMPEG instrument. The container picture we are going to use is solely a picture from Docker Hub containing the FFMPEG binaries. We’ll then add a video into our file share to make use of because the enter file. We’ll create a brand new container group with an Azure File Share mounted as a quantity after which we are going to write the output picture to our file share. We will even use the command-line argument to override the startup command for the container which is able to specify the FFMPEG arguments for thumbnail extraction operation in addition to the placement of the enter and output recordsdata. Final however not the least, we are going to specify the retry coverage as to not restart.


Step 1


Initially, we are going to begin by making a useful resource group. (You’ll be able to log in to your Azure account utilizing the PowerShell command az login and set your most well-liked subscription).




Step 2


Then, we are going to create a brand new storage account, specifying the useful resource group, a singular storage account title, and the Normal LRS pricing tier.




Step 3


To add recordsdata into our file share with Azure CLI, we might want to arrange an atmosphere variable that comprises the storage account connection string and we are able to pay money for the connection string utilizing the next command.




Step 4


The atmosphere variable must be referred to as AZURE_STORAGE_CONNECTION_STRING and with that atmosphere variable in place, we are able to now create our file share.




Step 5


Subsequent, we are going to name it with a reputation after which use az storage share create to create it by specifying the title of the share.




Step 6


Now, we’ve a storage account with a file share in it, so allow us to add our check file enter to that share. My file right here is demo.mp4 and it’s saved on my native disk and I can use the next command to add it into my share.



  • Now we have all of the setup that we wanted. Now we have an Azure File Share that comprises a single video file.
  • Now we’re going to create an ACI container group that can mount this Azure file share as a quantity.

Step 7


We want the storage key for the storage account so we’ll entry that utilizing the az storage account keys listing command and we are going to use a question parameter that permits us to pick simply the important thing we would like.




Step 8


We’ll give a reputation to our container group as transcodedemo and we are going to retailer the command line in a variable which we can be needing subsequent.




Step 9


Subsequent, we are going to use the az container create command specifying the useful resource group title and the container group title. Then the container picture that we’re utilizing which is Linux container that has bought FFMPEG construct put in. The restart coverage could be set to by no means as a result of if the thumbnail extraction fails, we would not need it to loop round perpetually and carry on making an attempt to do the identical factor. The following 4 arguments specify the small print of our mounted quantity. The storage account title, the storage account key, the title of the Azure file share and the trail inside the container that we mounting it to. Lastly, our container will not know what we would like it to do when it begins up. So we’ve offered a command line for it to execute. Right here we’re operating FFMPEG with an enter argument pointing to the file inside our mounted Azure file share. After which there are another FFMPEG particular arguments. In our case, we’re asking it to extract a thumbnail picture from the video and the ultimate FFMPEG argument specifies the output file and we’re telling it to put in writing the thumbnail png file again into our mounted Azure file share.



  • Your container group would have been created thus far however it might take a bit longer to complete beginning up the container and carry out the thumbnail extraction. Subsequent, we are going to try this.
  • If the whole lot is working effective then the container needs to be transcoding our enter file from the Azure file share with FFMPEG and may write the output thumbnail again to that very same file share.
  • We are able to verify that utilizing az container logs command which is able to present us the output of the FFMPEG command and provides us an concept if there was any drawback.

Step 10


Run the next command to generate the logs of the container.




Step 11


Right here it is possible for you to to see that FFMPEG has completed operating and it has picked out a body, in my case body quantity 89 to make use of because the thumbnail.




Step 12


To verify the contents of our file share and see whether or not the thumbnail picture is there or not, we are going to use the az storage file listing command. And you’d be capable of see that the thumb.png file could be there alongside the enter file.




Step 13


Subsequent, we are going to obtain the picture with the az storage file obtain command and try it.




Step 14


The under picture is what it has captured from the video that I had uploaded.




Step 15


You’ll be able to delete the useful resource group upon getting completed this demo by operating the next command.



So, on this demo, you noticed how you need to use Azure file shares as a quantity which could be very helpful for you when you could retailer knowledge that should reside independently of your container. And also you additionally noticed how a command-line argument can be utilized to manage the startup command of our container.

Show More

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button