<p>I am trying to Terraform an Azure Kubernetes Service cluster (AKS) with a <strong>Windows node pool</strong> but I get the following error:</p>
<blockquote>
<p>Error: creating Managed Kubernetes Cluster &quot;example-aks1&quot; (Resource Group &quot;test-aks-resource&quot;): containerservice.ManagedClustersClient#CreateOrUpdate: Failure sending request: StatusCode=0 -- Original Error: Code=&quot;AzureCNIOnlyForWindows&quot; Message=&quot;Windows agent pools can only be added to AKS clusters using Azure-CNI.&quot;</p>
</blockquote>
<p>And here is the screen shot of the command line:</p>
<p><img src="https://i.stack.imgur.com/2nCUf.png" alt="enter image description here" /></p>
<p>The code I am using is this:</p>
<pre><code>terraform {
  required_providers {
    azurerm = {
      source  = &quot;hashicorp/azurerm&quot;
      version = &quot;&gt;= 2.63.0&quot;
    }
  }
}

provider &quot;azurerm&quot; {
  features {}
}

resource &quot;azurerm_resource_group&quot; &quot;example&quot; {
  name     = &quot;test-aks-resource&quot;
  location = &quot;Central US&quot;
}

resource &quot;azurerm_kubernetes_cluster&quot; &quot;aks&quot; {
  name                = &quot;example-aks1&quot;
  location            = azurerm_resource_group.example.location
  resource_group_name = azurerm_resource_group.example.name
  dns_prefix          = &quot;exampleaks1&quot;
  default_node_pool {
    name       = &quot;default&quot;
    node_count = 1
    vm_size    = &quot;Standard_D2_v2&quot;
  }

  identity {
    type = &quot;SystemAssigned&quot;
  }

  windows_profile {
    admin_username = &quot;adminusername&quot;
    admin_password = &quot;xxxxxxxxxxxxx&quot;
  }

  tags = {
    Environment = &quot;dev&quot;
  }
}

resource &quot;azurerm_kubernetes_cluster_node_pool&quot; &quot;windows_node_pool&quot; {
  kubernetes_cluster_id = azurerm_kubernetes_cluster.aks.id
  orchestrator_version  = azurerm_kubernetes_cluster.aks.kubernetes_version
  name                  = &quot;winnp&quot;
  node_count            = 1
  vm_size               = &quot;Standard_D2_v2&quot;
  os_type               = &quot;Windows&quot;
}

output &quot;client_certificate&quot; {
    sensitive = true
    value = azurerm_kubernetes_cluster.aks.kube_config.0.client_certificate
}

output &quot;kube_config&quot; {
    sensitive = true
    value = azurerm_kubernetes_cluster.aks.kube_config_raw
}
</code></pre>
<p>Just a note that if I remove the following block from the Terraform code I get a different error:</p>
<pre><code>  windows_profile {
    admin_username = &quot;adminusername&quot;
    admin_password = &quot;xxxxxxxxxxxxx&quot;
  }
</code></pre>
<p>The error that I get is:</p>
<blockquote>
<p>Error: creating/updating Managed Kubernetes Cluster Node Pool &quot;winnp&quot; (Resource Group &quot;test-aks-resource&quot;): containerservice.AgentPoolsClient#CreateOrUpdate: Failure sending request: StatusCode=0 -- Original Error: Code=&quot;WindowsProfileMissing&quot; Message=&quot;Windows profile definition is missing for the cluster.&quot;</p>
</blockquote>
<p>Screen shot of the command line:</p>
<p><img src="https://i.stack.imgur.com/j97b3.png" alt="enter image description here" /></p>
<p>And obviously if I remove the &quot;azurerm_kubernetes_cluster_node_pool&quot; block of code the AKS is created with a default Linux node pool.</p>
<p>So my question is: how can I add a Windows node pool to an AKS?</p>

Milad Ghafoori
<p>Turned out I had to include a network adapter in &quot;azurerm_kubernetes_cluster&quot;:</p>
<pre><code>network_profile {
  network_plugin = &quot;azure&quot;
}
</code></pre>
<p>More details:</p>
<blockquote>
<p><a href="https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/kubernetes_cluster#network_plugin" rel="nofollow noreferrer">https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/kubernetes_cluster#network_plugin</a></p>
</blockquote>
