1. Packages
  2. Azure Native
  3. How-to Guides
  4. Azure Cosmos DB, an API Connection, and a Logic App
This is the latest version of Azure Native. Use the Azure Native v1 docs if using the v1 version of this package.
Azure Native v2.66.0 published on Wednesday, Oct 9, 2024 by Pulumi

Azure Cosmos DB, an API Connection, and a Logic App

azure-native logo
This is the latest version of Azure Native. Use the Azure Native v1 docs if using the v1 version of this package.
Azure Native v2.66.0 published on Wednesday, Oct 9, 2024 by Pulumi

    View Code Deploy this example with Pulumi

    With the native Azure provider we can directly use the Azure resource manager API to define API connections and linking it to a logic app. The resulting experience is much faster in comparison to performing the same operation through ARM templates.

    Prerequisites

    1. Install Pulumi
    2. Configure Pulumi for Azure
    3. Configure Pulumi for Python

    Running the App

    1. Create a new stack:

      $ pulumi stack init dev
      
    2. Create a Python virtualenv, activate it, and install dependencies:

      This installs the dependent packages needed for our Pulumi program.

      $ python3 -m venv venv
      $ source venv/bin/activate
      $ pip3 install -r requirements.txt
      
    3. Set the required configuration variables for this program, and log into Azure:

      $ pulumi config set azure-native:location westeurope
      $ az login
      
    4. Perform the deployment:

      $ pulumi up
      
           Type                                                        Name                         Status
       +   pulumi:pulumi:Stack                                         azure-cosmosdb-logicapp-dev  created
       +   ├─ azure-native:resources:ResourceGroup                     logicappdemo-rg              created
       +   ├─ azure-native:storage:StorageAccount                      logicappdemosa               created
       +   ├─ azure-native:documentdb:DatabaseAccount                  logicappdemo-cdb             created
       +   ├─ azure-native:documentdb:SqlResourceSqlDatabase           db                           created
       +   ├─ azure-native:web:Connection                              cosmosdbConnection           created
       +   ├─ azure-native:documentdb:SqlResourceSqlContainer          container                    created
       +   └─ azure-native:logic:Workflow                              workflow                     created
      
      Resources:
          + 8 created
      
      Duration: 3m16s
      
    5. At this point, you have a Cosmos DB collection and a Logic App listening to HTTP requests. You can trigger the Logic App with a curl command:

      $ curl -X POST "$(pulumi stack output endpoint)" -d '"Hello World"' -H 'Content-Type: application/json'
      

      The POST body will be saved into a new document in the Cosmos DB collection.

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

      $ pulumi destroy
      $ pulumi stack rm
      
    azure-native logo
    This is the latest version of Azure Native. Use the Azure Native v1 docs if using the v1 version of this package.
    Azure Native v2.66.0 published on Wednesday, Oct 9, 2024 by Pulumi