'How to define Directory in Azure Storage Container with Terraform

I know to how to create Storage and Container. But is it possible to create "directory"?

I find followings, but not for creating directory.

resource "azurerm_resource_group" "example" {
  name     = "example-resources"
  location = "West Europe"
}

resource "azurerm_storage_account" "example" {
  name                     = "examplestoraccount"
  resource_group_name      = azurerm_resource_group.example.name
  location                 = azurerm_resource_group.example.location
  account_tier             = "Standard"
  account_replication_type = "LRS"

  tags = {
    environment = "staging"
  }
}

resource "azurerm_storage_container" "example" {
  name                  = "vhds"
  storage_account_name  = azurerm_storage_account.example.name
  container_access_type = "private"
}

enter image description here



Solution 1:[1]

Simple answer is that you cannot because regular storage accounts (i.e. which are not Data Lake Gen 2) do not have the concept of actual directories.

The directories you see are virtual and are essentially the blob prefix e.g. if you upload a blob with name images/my-image.png, images will be presented as a directory.

Even when you click on the "Add Directory" button in Azure Portal, you will see the following message:

enter image description here

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Gaurav Mantri