---
title: "AKS Helm chart with Azure Cosmos DB"
description: "A Helm chart deployed to AKS that stores TODOs in an Azure Cosmos DB MongoDB API"
url: "https://www.pulumi.com/dev/examples/azure-cs-aks-cosmos-helm/"
image: "https://www.pulumi.com/assets/og/dev/examples/azure-cs-aks-cosmos-helm.png"
---

# AKS Helm chart with Azure Cosmos DB

A Helm chart deployed to AKS that stores TODOs in an Azure Cosmos DB MongoDB API

- Source on GitHub: https://github.com/pulumi/examples/tree/master/azure-cs-aks-cosmos-helm
- Deploy with Pulumi: https://app.pulumi.com/new?template=https%3A%2F%2Fgithub.com%2Fpulumi%2Fexamples%2Ftree%2Fmaster%2Fazure-cs-aks-cosmos-helm

## Get started with this example

This example lives in the [pulumi/examples](https://github.com/pulumi/examples/tree/master/azure-cs-aks-cosmos-helm) 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-cs-aks-cosmos-helm
cd pulumi-examples/azure-cs-aks-cosmos-helm
```

Stands up an Azure Kubernetes Service (AKS) cluster and a MongoDB-flavored instance of
Azure Cosmos DB. On top of the AKS cluster, we also deploy a Helm Chart with a simple
Node.js TODO app `bitnami/node`, swapping out the usual in-cluster MongoDB instance
with our managed Cosmos DB instance.

## Prerequisites

1. [Install Pulumi](https://www.pulumi.com/docs/get-started/install/)
2. [Configure Azure credentials](https://www.pulumi.com/docs/intro/cloud-providers/azure/setup/)
3. [Install .NET](https://www.pulumi.com/docs/intro/languages/dotnet/)

## Deploying the example

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

    ```bash
    pulumi stack init dev
    ```

1.  Set the Azure region location to use:

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

1.  Deploy everything with the `pulumi up` command. This provisions all the Azure
    resources necessary, including an Active Directory service principal, AKS cluster,
    Cosmos DB instance, and then deploys the Helm Chart, all in a single gesture (takes
    5-10 min):

    ```bash
    pulumi up
    ```

    ```
         Type                                                          Name                          Status      Info
    +   pulumi:pulumi:Stack                                           azure-cs-aks-cosmos-helm-dev  created     1 warning
    +   ├─ kubernetes:helm.sh/v3:Chart                                node                          created
    +   │  ├─ kubernetes:core/v1:Service                              node                          created
    +   │  └─ kubernetes:apps/v1:Deployment                           node                          created
    +   ├─ example:component:CosmosDBMongoDB                          mongo-todos                   created
    +   │  ├─ azure-native:documentdb:DatabaseAccount                 cosmos-mongodb                created
    +   │  └─ azure-native:documentdb:MongoDBResourceMongoDBDatabase  todos                         created
    +   ├─ example:component:AksCluster                               demoaks                       created
    +   │  ├─ azuread:index:Application                               app                           created
    +   │  ├─ random:index:RandomPassword                             pw                            created
    +   │  ├─ tls:index:PrivateKey                                    ssh-key                       created
    +   │  ├─ azuread:index:ServicePrincipal                          service-principal             created
    +   │  ├─ azuread:index:ServicePrincipalPassword                  sp-password                   created
    +   │  ├─ azure-native:containerservice:ManagedCluster            demoaks                       created
    +   │  └─ pulumi:providers:kubernetes                             k8s-provider                  created
    +   ├─ azure-native:resources:ResourceGroup                       cosmosrg                      created
    +   └─ kubernetes:core/v1:Secret                                  mongo-secrets                 created

    Outputs:
        Endpoint: "http://20.73.205.163"
    ```

1.  Now your database, your cluster, and application are ready. An output variable is
    printed to provide the application endpoint:

    ```bash
    curl $(pulumi stack output Endpoint)
    ```

    ```
    <!doctype html>

    <!-- ASSIGN OUR ANGULAR MODULE -->
    <html ng-app="scotchTodo">
    <head>
        <!-- META -->
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1"><!-- Optimize mobile viewport -->

        <title>Node/Angular Todo App</title>
    ...
    ```

## Cleaning up

Once you are done, you can destroy all of the resources, and the stack:

```bash
pulumi destroy
pulumi stack rm
rm kubeconfig.yaml
```
