SMB volume creation using terraform

KrishnaveniAnumala-7706 20 Reputation points
2025-05-21T15:07:38.58+00:00

Hello,

We are trying to migrate the shares from onprem to azure

1.Can we create SMB volume using terraform code? if yes, please provide the sample code to provision

Regards,

Krishnaveni A

Azure NetApp Files
Azure NetApp Files

An Azure service that provides enterprise-grade file shares powered by NetApp.

0 comments No comments

Answer accepted by question author
Anonymous
2025-05-22T09:14:55.3233333+00:00

Hi @Krishnaveni Anumala

Can we create SMB volume using terraform code? if yes, please provide the code to provision Yes, you can use the below code to create SMB volume with AD configuration block using terraform.

According to this MS-Document 1 and MS-Document 2,

  • Terraform maps the SMB protocol to the value "CIFS" for the Azure NetApp Files API.

Code:

provider "azurerm" {
  features {}
  subscription_id = "xxxxxxx"
}

resource "azurerm_resource_group" "example" {
  name     = "xxxxx"
  location = "eastus"
}

resource "azurerm_virtual_network" "example" {
  name                = "vnet1"
  address_space       = ["10.0.0.0/16"]
  location            = azurerm_resource_group.example.location
  resource_group_name = azurerm_resource_group.example.name
}

resource "azurerm_subnet" "example" {
  name                 = "anf-subnet"
  resource_group_name  = azurerm_resource_group.example.name
  virtual_network_name = azurerm_virtual_network.example.name
  address_prefixes     = ["10.0.2.0/24"]

  delegation {
    name = "netAppDelegation"

    service_delegation {
      name = "Microsoft.Netapp/volumes"  

      actions = [
"Microsoft.Network/networkinterfaces/*","Microsoft.Network/virtualNetworks/subnets/join/action"]
      ]
    }
  }
}

resource "azurerm_netapp_account" "example" {
  name                = "netappacctdemo"
  location            = azurerm_resource_group.example.location
  resource_group_name = azurerm_resource_group.example.name

  active_directory {
    username            = "aduser"
    password            = "aduserpwd"
    smb_server_name     = "SMBSERVER"
    dns_servers         =  "xxxxx"
    domain              = "xxxx"
    organizational_unit = "xxxxx"
  }
}

resource "azurerm_netapp_pool" "example" {
  name                = "pool1"
  location            = azurerm_resource_group.example.location
  resource_group_name = azurerm_resource_group.example.name
  account_name        = azurerm_netapp_account.example.name
  service_level       = "Premium"
  size_in_tb          = 4
}

resource "azurerm_netapp_volume" "example" {
  name                   = "smbvol1"
  location               = azurerm_resource_group.example.location
  resource_group_name    = azurerm_resource_group.example.name
  account_name           = azurerm_netapp_account.example.name
  pool_name              = azurerm_netapp_pool.example.name
  volume_path            = "smbvol1"
  service_level          = "Premium"
  subnet_id              = azurerm_subnet.example.id
  protocols              = ["CIFS"]
  storage_quota_in_gb    = 100
}

Portal:

User's image

Reference:

azurerm_netapp_volume | Resources | hashicorp/azurerm | Terraform | Terraform Registry

You can refer to the link above to create a volume according to your environment requirements.

Hope this answer helps! please let us know if you have any further queries. I’m happy to assist you further.

Please do not forget to "Accept the answer” and “up-vote” wherever the information provided helps you, this can be beneficial to other community members.

Was this answer helpful?


1 additional answer

Sort by: Most helpful
  1. Vinod Kumar Reddy Chilupuri 4,190 Reputation points Microsoft External Staff Moderator
    2025-05-21T15:51:26.9866667+00:00

    Hi Krishnaveni Anumala,

    Migrating your Powermax and Isilon shares to Azure, specifically focusing on creating SMB volumes using Terraform.

    1. Creating SMB Volumes with Terraform: While the official Azure documentation doesn't provide a direct Terraform example for creating SMB volumes on Azure NetApp Files, you can accomplish this by using the Azure Provider for Terraform. You’ll generally utilize resources like azurerm_netapp_volume in your Terraform code. Here’s a basic template.
         provider "azurerm" {
         features {}
         }
         resource "azurerm_netapp_account" "example" {
         name                = "example-account"
         resource_group_name = azurerm_resource_group.example.name
         location           = azurerm_resource_group.example.location
         sku {
         name = "Standard"
         }
         }
         resource "azurerm_netapp_pool" "example" {
         name                = "example-pool"
         netapp_account_name = azurerm_netapp_account.example.name
         resource_group_name = azurerm_resource_group.example.name
         location           = azurerm_resource_group.example.location
         service_level      = "Standard"
         size               = 4398046511104 # Size in bytes
         }
         resource "azurerm_netapp_volume" "example" {
         name                  = "example-volume"
         netapp_account_name   = azurerm_netapp_account.example.name
         netapp_pool_name      = azurerm_netapp_pool.example.name
         resource_group_name   = azurerm_resource_group.example.name
         location              = azurerm_resource_group.example.location
         subnet_id             = azurerm_subnet.example.id
         service_level         = "Standard"
         usage_threshold       = 10000000000 # Size in bytes
         volume_type           = "SMB"
         }
         
      
      Make sure to tweak the parameters to match your requirements.
    2. Azure RM Provider Support: Yes, the Azure Resource Manager (ARM) provider for Terraform does support the creation of SMB volumes via the Azure NetApp Files. You'll find the necessary support in the Azure RM provider documentation.
    3. Alternative Methods: If you run into issues with Terraform or need an alternative, you can create SMB volumes directly through the Azure Portal or using Azure CLI.
    • Create an SMB volume using the Azure Portal:
      Go to the Azure NetApp Files resource.
      Choose the capacity pool where you want to provision the volume.
      Click on “Add volume” and fill out the necessary fields like volume name, quota, etc.Using
    • Azure CLI.
    az netappfiles volume create --resource-group example-rg \
      --account-name example-account \
      --pool-name example-pool \
      --name example-volume \
      --location eastus \
      --service-level Standard \
      --usage-threshold 100 \
      --protocol-types SMB \
      --subnet-id example-subnet-id
    

    Create an SMB volume for Azure NetApp Files

    Configure Azure Files using Terraform

    Hope the above suggestion helps! Please let us know do you have any further queries.

    Please do consider to “Accept the answer” wherever the information provided helps you, this can be beneficial to other community members.

    Was this answer helpful?


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.