Creating containers in Azure using python.


  • Azure identity package : pip install azure-identity
  • azure storage blob package: pip install azure-storage-blob
  • Azure cli, after installing the cli you have to log in using the command : az login.
  • An Azure account with a subscription and a storage account already created via the interface

The goal is to create containers in an Azure storage account using a simple Python script. The container names (months) to be created are located in a .txt file :

  1. Import the librairies

These are the two needed classes.

2. Define the account url

The account url is a unique url defining the path to the storage account, it has the following format :

account_url = “https://<nameOfYourStorageAccount>”

3. A Python function to loop over the containers to be created and call the create_container function

Execute the python function to see the containers created in the azure interface:

Thanks for reading.


Othmane Bousselham

SAS Technical Consultant

Leave a Reply

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

Related Articles

Altaica Logo - SAS Technical Consultant