An Azure service that provides enterprise-grade file shares powered by NetApp.
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:
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.