Skip to content

Commit 1c3b490

Browse files
Merge pull request #309615 from eh8/main
Explain Terraform support for Azure Container Storage
2 parents 39be29a + 65e6c88 commit 1c3b490

4 files changed

Lines changed: 282 additions & 77 deletions

File tree

articles/storage/container-storage/install-container-storage-aks.md

Lines changed: 177 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ ms.topic: tutorial
77
ms.date: 09/10/2025
88
ms.author: kendownie
99
ms.custom: devx-track-azurecli, references_regions
10+
zone_pivot_groups: azure-cli-or-terraform
1011
# Customer intent: "As a cloud administrator, I want to install Azure Container Storage on an AKS cluster so that I can efficiently manage storage for containerized applications."
1112
---
1213

@@ -19,6 +20,8 @@ If you prefer the open-source version of Azure Container Storage, visit the [loc
1920
> [!IMPORTANT]
2021
> This article applies to [Azure Container Storage (version 2.x.x)](container-storage-introduction.md). For earlier versions, see [Azure Container Storage (version 1.x.x) documentation](container-storage-introduction-version-1.md). If you already have Azure Container Storage (version 1.x.x) installed on your AKS cluster, remove it by following [these steps](remove-container-storage-version-1.md).
2122
23+
::: zone pivot="azurecli"
24+
2225
> [!div class="checklist"]
2326
> * Prepare your Azure CLI environment
2427
> * Create or select a resource group for your cluster
@@ -27,15 +30,18 @@ If you prefer the open-source version of Azure Container Storage, visit the [loc
2730
2831
## Prerequisites
2932

30-
- If you don't have an Azure subscription, create a [free account](https://azure.microsoft.com/pricing/purchase-options/azure-account?cid=msft_learn) before you begin.
33+
- Create an Azure subscription if you don’t already have one by signing up for a [free account](https://azure.microsoft.com/pricing/purchase-options/azure-account?cid=msft_learn).
3134

32-
- This article requires the latest version (2.77.0 or later) of the Azure CLI. See [How to install the Azure CLI](/cli/azure/install-azure-cli). Don't use Azure Cloud Shell, because `az upgrade` isn't available in Cloud Shell. Be sure to run the commands in this article with administrative privileges. Some Azure CLI extensions, such as `aks-preview`, can conflict with required command flags. Disable them if you encounter issues.
35+
- Confirm that your target region is supported by reviewing the [Azure Container Storage regional availability](container-storage-introduction.md#regional-availability).
3336

34-
- You need the Kubernetes command-line client, `kubectl`. You can install it locally by running the `az aks install-cli` command.
37+
- Plan your node pool configuration:
38+
- Use Linux as the OS type (Windows is not supported).
39+
- Select a VM SKU that supports local NVMe data disks, such as [storage-optimized](/azure/virtual-machines/sizes/overview#storage-optimized) or [GPU-accelerated](/azure/virtual-machines/sizes/overview#gpu-accelerated) VMs.
40+
- For existing clusters, ensure node pools already use a supported VM SKU before enabling Azure Container Storage.
3541

36-
- Check if your target region is supported in [Azure Container Storage regions](container-storage-introduction.md#regional-availability).
42+
- Install the latest version of the [Azure CLI](/cli/azure/install-azure-cli) (2.77.0 or later), then sign in with `az login`. Avoid using Azure Cloud Shell (since `az upgrade` isn’t available), and disable conflicting extensions such as `aks-preview` if issues occur.
3743

38-
- Sign in to Azure by using the [az login](/cli/azure/reference-index#az-login) command.
44+
- Install the Kubernetes command-line client, `kubectl`. You can install it locally by running `az aks install-cli`.
3945

4046
## Install the required extension
4147

@@ -81,19 +87,14 @@ If the resource group is created successfully, you see output similar to this ex
8187
}
8288
```
8389

84-
## Ensure the VM type for your cluster meets the installation criteria
85-
86-
Follow these guidelines when choosing a virtual machine type for the cluster nodes.
87-
88-
- Choose a virtual machine SKU that supports local NVMe data disks, for example, [storage optimized VMs](/azure/virtual-machines/sizes/overview#storage-optimized) or [GPU accelerated VMs](/azure/virtual-machines/sizes/overview#gpu-accelerated).
89-
- Choose the OS type for the VMs in the node pools as Linux OS. Windows OS isn't currently supported.
90-
- For existing clusters, make sure node pools already use a supported VM SKU before enabling Azure Container Storage.
91-
92-
## Install Azure Container Storage on your AKS cluster
90+
## Install Azure Container Storage on an AKS cluster
9391

9492
Choose the scenario that matches your environment.
9593

96-
### Option 1: Create a new AKS cluster with Azure Container Storage enabled
94+
> [!IMPORTANT]
95+
> Azure Container Storage installs the latest available version and updates itself automatically. Manual version selection is not supported.
96+
97+
### Option 1: Creating a new AKS cluster with Azure Container Storage enabled
9798

9899
Run the following command to create a new AKS cluster and install Azure Container Storage. Replace `<cluster-name>` and `<resource-group>` with your own values, and specify which VM type you want to use.
99100

@@ -103,7 +104,7 @@ az aks create -n <cluster-name> -g <resource-group> --node-vm-size Standard_L8s_
103104

104105
The deployment takes 5-10 minutes. When it completes, you have an AKS cluster with Azure Container Storage installed and the components for local NVMe storage type deployed.
105106

106-
### Option 2: Enable Azure Container Storage on an existing AKS cluster
107+
### Option 2: Enabling Azure Container Storage on an existing AKS cluster
107108

108109
Run the following command to enable Azure Container Storage on an existing AKS cluster. Replace `<cluster-name>` and `<resource-group>` with your own values.
109110

@@ -113,6 +114,165 @@ az aks update -n <cluster-name> -g <resource-group> --enable-azure-container-sto
113114

114115
The deployment takes 5-10 minutes. When it completes, the targeted AKS cluster has Azure Container Storage installed and the components for local NVMe storage type deployed.
115116

117+
::: zone-end
118+
119+
::: zone pivot="terraform"
120+
121+
> [!div class="checklist"]
122+
> * Prepare Terraform and authenticate to Azure
123+
> * Define your resource group and AKS cluster configuration
124+
> * Confirm your node pool virtual machine types meet the installation criteria
125+
> * Apply Terraform to deploy Azure Container Storage or enable it on an existing cluster
126+
127+
## Prerequisites
128+
129+
- Create an Azure subscription if you don’t already have one by signing up for a [free account](https://azure.microsoft.com/pricing/purchase-options/azure-account?cid=msft_learn).
130+
131+
- Verify that your target region is supported by checking the [Azure Container Storage regional availability](container-storage-introduction.md#regional-availability).
132+
133+
- Plan your node pool configuration:
134+
- Use Linux as the OS type (Windows is not supported).
135+
- Select a VM SKU that supports local NVMe data disks, such as [storage-optimized](/azure/virtual-machines/sizes/overview#storage-optimized) or [GPU-accelerated](/azure/virtual-machines/sizes/overview#gpu-accelerated) VMs.
136+
- For existing clusters, ensure node pools already use a supported VM SKU before enabling Azure Container Storage.
137+
138+
- Install the [Azure CLI](/cli/azure/install-azure-cli) version 2.77.0 or later, then sign in with `az login`.
139+
140+
- Install [Terraform](https://developer.hashicorp.com/terraform/install) version 1.5 or later and confirm the installation with `terraform version`. Terraform can reuse your Azure CLI authentication.
141+
142+
- Install `kubectl` so you can validate the cluster after deployment. If needed, run `az aks install-cli` to install it locally.
143+
144+
## Set subscription context
145+
146+
Terraform can determine a target Azure subscription via various means:
147+
148+
- `subscription_id` in the provider block
149+
- `ARM_SUBSCRIPTION_ID` environment variable
150+
- Azure CLI default subscription
151+
- Managed identity (when running in Azure)
152+
153+
For local use, set the Azure CLI context:
154+
155+
```azurecli
156+
az account set --subscription <subscription-id>
157+
```
158+
159+
## Install Azure Container Storage on an AKS cluster
160+
161+
Choose the scenario that matches your environment.
162+
163+
> [!IMPORTANT]
164+
> Azure Container Storage installs the latest available version and updates itself automatically. Manual version selection is not supported.
165+
166+
### Option 1: Creating a new AKS cluster with Azure Container Storage enabled
167+
168+
1. In an empty working directory, create a `main.tf` file with the following minimal configuration of an AKS cluster. Update the resource names, locations, and VM sizes to meet your requirements.
169+
170+
```tf
171+
terraform {
172+
required_version = ">= 1.5.0"
173+
required_providers {
174+
azurerm = {
175+
source = "hashicorp/azurerm"
176+
version = "~> 4.x"
177+
}
178+
}
179+
}
180+
181+
provider "azurerm" {
182+
features {}
183+
}
184+
185+
resource "azurerm_resource_group" "rg" {
186+
name = "demo-aks-rg"
187+
location = "eastus"
188+
}
189+
190+
resource "azurerm_kubernetes_cluster" "aks" {
191+
name = "demo-aks-cluster"
192+
dns_prefix = "demo-aks"
193+
location = azurerm_resource_group.rg.location
194+
resource_group_name = azurerm_resource_group.rg.name
195+
196+
default_node_pool {
197+
name = "systempool"
198+
vm_size = "Standard_L8s_v3"
199+
node_count = 3
200+
}
201+
202+
identity {
203+
type = "SystemAssigned"
204+
}
205+
}
206+
207+
resource "azurerm_kubernetes_cluster_extension" "container_storage" {
208+
name = "microsoft-azurecontainerstorage"
209+
cluster_id = azurerm_kubernetes_cluster.aks.id
210+
extension_type = "microsoft.azurecontainerstoragev2"
211+
212+
configuration_settings = {
213+
enable-azure-container-storage = "true"
214+
}
215+
}
216+
```
217+
218+
2. Initialize the working directory to download the AzureRM provider.
219+
220+
```bash
221+
terraform init
222+
```
223+
224+
3. Review the planned changes.
225+
226+
```bash
227+
terraform plan
228+
```
229+
230+
4. Apply the configuration to create the resource group, AKS cluster, and Azure Container Storage extension. Deployment typically takes 5-10 minutes.
231+
232+
```bash
233+
terraform apply
234+
```
235+
236+
### Option 2: Enabling Azure Container Storage on an existing AKS cluster
237+
238+
If your AKS cluster already exists and you're managing it outside of Terraform, you can still enable Azure Container Storage by authoring only the extension resource. Use a data source to look up the cluster ID.
239+
240+
```tf
241+
terraform {
242+
required_version = ">= 1.5.0"
243+
required_providers {
244+
azurerm = {
245+
source = "hashicorp/azurerm"
246+
version = "~> 4.x"
247+
}
248+
}
249+
}
250+
251+
provider "azurerm" {
252+
features {}
253+
}
254+
255+
data "azurerm_kubernetes_cluster" "existing" {
256+
name = "existing-aks"
257+
resource_group_name = "existing-aks-rg"
258+
}
259+
260+
resource "azurerm_kubernetes_cluster_extension" "container_storage" {
261+
name = "microsoft-azurecontainerstorage"
262+
cluster_id = data.azurerm_kubernetes_cluster.existing.id
263+
extension_type = "microsoft.azurecontainerstoragev2"
264+
265+
configuration_settings = {
266+
enable-azure-container-storage = "true"
267+
}
268+
}
269+
```
270+
271+
Run `terraform init` (if this is a new working directory) followed by `terraform apply` to install Azure Container Storage on the targeted cluster.
272+
273+
::: zone-end
274+
275+
116276
## Connect to the cluster and verify status
117277

118278
After installation, configure `kubectl` to connect to your cluster and verify the nodes are ready.
@@ -138,7 +298,7 @@ After installation, configure `kubectl` to connect to your cluster and verify th
138298
aks-nodepool1-34832848-vmss000002 Ready agent 80m v1.32.6
139299
```
140300
141-
## Next step
301+
## Next steps
142302
143303
- [Use Azure Container Storage with local NVMe](use-container-storage-with-local-disk.md)
144304
- [Overview of deploying a highly available PostgreSQL database on Azure Kubernetes Service (AKS)](/azure/aks/postgresql-ha-overview#storage-considerations)

articles/storage/container-storage/remove-container-storage.md

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Remove Azure Container Storage
3-
description: Remove Azure Container Storage by deleting the extension instance for Azure Kubernetes Service (AKS). Optionally delete the AKS cluster or entire resource group to clean up resources.
3+
description: Remove Azure Container Storage by deleting the extension instance for Azure Kubernetes Service (AKS). To clean up resources, optionally delete the AKS cluster or entire resource group.
44
author: khdownie
55
ms.service: azure-container-storage
66
ms.date: 09/10/2025
@@ -11,7 +11,7 @@ ms.topic: how-to
1111

1212
# Remove Azure Container Storage
1313

14-
This article shows you how to remove Azure Container Storage by deleting the extension instance for Azure Kubernetes Service (AKS). Optionally, you can also delete the AKS cluster or entire resource group to clean up resources.
14+
This article shows you how to remove Azure Container Storage by deleting the extension instance for Azure Kubernetes Service (AKS). To clean up resources, you can also delete the AKS cluster or entire resource group.
1515

1616
> [!IMPORTANT]
1717
> This article applies to [Azure Container Storage (version 2.x.x)](container-storage-introduction.md). If you have Azure Container Storage (version 1.x.x) installed on your AKS cluster, remove it by following [these steps](remove-container-storage-version-1.md).
@@ -28,6 +28,23 @@ Follow these steps to remove Azure Container Storage from your AKS cluster.
2828
az aks update -n <cluster-name> -g <resource-group> --disable-azure-container-storage
2929
```
3030

31+
### Remove the extension with Terraform
32+
33+
If you provisioned Azure Container Storage with Terraform, remove the corresponding extension resource from your configuration and apply the change so the result matches the CLI workflow.
34+
35+
1. Delete the `azurerm_kubernetes_cluster_extension` block (or set `count = 0`) in your Terraform configuration and save the file.
36+
1. Review the plan to confirm Terraform destroys only the extension resource.
37+
38+
```bash
39+
terraform plan
40+
```
41+
42+
1. Apply the plan to delete the extension. Terraform displays the same outcome as the CLI command: the extension resource is removed and AKS no longer reports Azure Container Storage as enabled.
43+
44+
```bash
45+
terraform apply
46+
```
47+
3148
## Delete AKS cluster
3249

3350
To delete an AKS cluster and all persistent volumes, run the following Azure CLI command. Replace `<resource-group>` and `<cluster-name>` with your own values.
@@ -36,6 +53,14 @@ To delete an AKS cluster and all persistent volumes, run the following Azure CLI
3653
az aks delete --resource-group <resource-group> --name <cluster-name>
3754
```
3855

56+
If the AKS cluster was created with Terraform, you can also remove it by running the following command.
57+
58+
```bash
59+
terraform destroy
60+
```
61+
62+
This command deletes all resources that Terraform manages in the current working directory. This includes the cluster, the resource group, and the Azure Container Storage extension. Run this command only when you intend to remove the entire deployment.
63+
3964
## Delete resource group
4065

4166
You can also use the [`az group delete`](/cli/azure/group) command to delete the resource group and all resources it contains. Replace `<resource-group>` with your resource group name.
@@ -46,4 +71,4 @@ az group delete --name <resource-group>
4671

4772
## See also
4873

49-
- [What is Azure Container Storage?](container-storage-introduction.md)
74+
- [What is Azure Container Storage?](container-storage-introduction.md)

0 commit comments

Comments
 (0)