In one of my automation, I need to store the reports on daily basis in Azure storage account in automated way so i need to have separate container to store all my reports. So i need to ensure my container is available or need to be create before pushing my report to the container. This article will have detail explain about How to Create a Container in Azure Storage Account using PowerShell.

To create containers with PowerShell, call the New-AzStorageContainer cmdlet. There are no limits to the number of blobs or containers that can be created within a storage account. Containers cannot be nested within other containers.

New to storage account?

One of the core services within Microsoft Azure is the Storage Account service. There are many service that utilize Storage Accounts for storing data, such as Virtual Machine Disks, Diagnostics logs (specially application log), SQL backups and others. You can also use the Azure Storage Account service to store your own data; such as blobs or binary data.

As per MSDN, Azure blob storage allows you to store large amounts of unstructured object data. You can use blob storage to gather or expose media, content, or application data to users. Because all blob data is stored within containers, you must create a storage container before you can begin to upload data.

How to Create Containers in Azure Storage Account using powershell

Step: 1 Get the prerequisite inputs

Step: 2 Connect to your Azure subscription

Step: 3 Get the storage account to Check the container exit or not

Step: 4 Check the container exist before creating

We need to use New-AzStorageContainer cmdlet creates an Azure storage container

Full Code for Create a Container in Azure Storage Account

Output:

Create a Container in an Azure Storage Account

Note:

To list down all the containers present in the specific storage account, you can use
Get-AzStorageContainer -Name $containerName -Context $context