---
title: "Azure Kubernetes Service (AKS) Cluster using the native Azure Provider"
description: "Using the native Azure provider to create AKS cluster with python"
url: "https://www.pulumi.com/dev/examples/azure-py-aks/"
image: "https://www.pulumi.com/assets/og/dev/examples/azure-py-aks.png"
---

# Azure Kubernetes Service (AKS) Cluster using the native Azure Provider

Using the native Azure provider to create AKS cluster with python

- Source on GitHub: https://github.com/pulumi/examples/tree/master/azure-py-aks

## Get started with this example

This example lives in the [pulumi/examples](https://github.com/pulumi/examples/tree/master/azure-py-aks) repo. Pull down just this directory to follow along:

```bash
git clone --filter=blob:none --sparse https://github.com/pulumi/examples pulumi-examples
git -C pulumi-examples sparse-checkout set azure-py-aks
cd pulumi-examples/azure-py-aks
```

This example deploys an AKS cluster, creates an Azure Active AD application, creates a Service Principal and sets credentials to manage access to the cluster.

## Deploying the App

To deploy your infrastructure, follow the below steps.

### Prerequisites

1. [Install Pulumi](https://www.pulumi.com/docs/get-started/install/)
2. [Install Python 3.6 or higher](https://www.python.org/downloads/)
3. [Configure Azure Credentials](https://www.pulumi.com/docs/intro/cloud-providers/azure/setup/)

### Steps

After cloning this repo, from this working directory, run these commands:

1. Create a new stack, which is an isolated deployment target for this example:

    ```bash
    $ pulumi stack init
    ```

1. Set the Azure region location to use:

    ```
    $ pulumi config set azure-native:location westus2
    ```

1. Initiate pulumi to stand up the cluster

    ```bash
    $ pulumi up
    ```

    > Note: Due to a propagation delay in Azure AD, the Service Principal created for the cluster may not be available the moment the cluster is provisioned. If you get a "Service Principal not found" error, run `pulumi up` again and it should complete successfully.

1. After 3-4 minutes, your cluster will be ready, and the kubeconfig YAML you'll use to connect to the cluster will be available as an output. You can save this kubeconfig to a file like so:

    ```bash
    $ pulumi stack output kubeconfig --show-secrets > kubeconfig.yaml
    ```

    Once you have this file in hand, you can interact with your new cluster as usual via `kubectl`:

    ```bash
    $ KUBECONFIG=./kubeconfig.yaml kubectl get nodes
    ```

1. From there, feel free to experiment. Simply making edits and running `pulumi up` will incrementally update your stack.

1. Once you've finished experimenting, tear down your stack's resources by destroying and removing it:

    ```bash
    $ pulumi destroy --yes
    $ pulumi stack rm --yes
    ```
