Requirements:
- 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 :
![](https://altaica.be/wp-content/uploads/2024/01/image.png)
- Import the librairies
![](https://altaica.be/wp-content/uploads/2024/01/image-1.png)
![](https://altaica.be/wp-content/uploads/2024/01/image-1.png)
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>.blob.core.windows.net”
![](https://altaica.be/wp-content/uploads/2024/01/image-5.png)
![](https://altaica.be/wp-content/uploads/2024/01/image-5.png)
3. A Python function to loop over the containers to be created and call the create_container function
![](https://altaica.be/wp-content/uploads/2024/01/image-3.png)
![](https://altaica.be/wp-content/uploads/2024/01/image-3.png)
Execute the python function to see the containers created in the azure interface:
![](https://altaica.be/wp-content/uploads/2024/01/image-4-1920x405.png)
![](https://altaica.be/wp-content/uploads/2024/01/image-4-1920x405.png)
Thanks for reading.
Othmane.