---
title: "Azure Bot Service with Application Insights"
description: "Creates Azure Bot Service with Application Insights"
url: "https://www.pulumi.com/dev/examples/classic-azure-cs-botservice/"
image: "https://www.pulumi.com/assets/og/dev/examples/classic-azure-cs-botservice.png"
---

# Azure Bot Service with Application Insights

Creates Azure Bot Service with Application Insights

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

## Get started with this example

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

Starting point for building Azure Bot Service hosted in Azure App Service.

Provisions Azure Bot Service, Azure Bot Channel registration and Azure Application Insights to be used in combination
with App Service - registering Azure AD Microsoft Application with secret.

This will deploy the echo bot code within the ~/bot directory - you can tweak the contents or replace the contents with your own bot.  Please ensure you publish the bot first to the ~/bot/publish subfolder - following the instructions for `Publish Bot Steps`.

## Deploying the App

To deploy your infrastructure, follow the below steps.

### Prerequisites

* [Install Pulumi](https://www.pulumi.com/docs/get-started/install/)
* [Install .NET Core 3.0+](https://dotnet.microsoft.com/download)

### Publish Bot Steps

1. Within the **/bot** subfolder, publish the bot to subfolder called publish:

    ```bash
    dotnet publish -o publish
    ```

### Pulumi Steps

1. Within the **azure-cs-botservice** folder, create a new stack:

    ```bash
    pulumi stack init dev
    ```

1. Login to Azure CLI (you will be prompted to do this during deployment if you forget this step):

    ```bash
    az login
    ```

1. Configure the location to deploy the resources to:

    ```bash
    pulumi config set azure:location "North Europe"
    pulumi config set azure:subscriptionId <YOUR_SUBSCRIPTION_ID>
    ```

1. Configure the Bot Name:

    ```bash
    pulumi config set botName PulumiBot1
    ```

1. Run `pulumi up` to preview and deploy changes:

    ```console
    $ pulumi up
    Previewing changes:
    ...

    Performing changes:
    ...
    info: 14 changes performed:
        + 14 resources created
    Update duration: 1m22s
    ```

1. Check the deployed bot using either:

    * Azure Portal Azure Bot Service - [Test in Webchat feature](https://docs.microsoft.com/en-us/azure/bot-service/abs-quickstart?view=azure-bot-service-4.0#test-the-bot)
    * [Bot Framework Emulator](https://github.com/Microsoft/BotFramework-Emulator) pointing to the output bot endpoint and Microsoft Application Id and the secret you supplied:

        ```yaml
        BotEndpoint: "https://app8asdf.azurewebsites.net/api/messages"
        MicrosoftAppId: "b5e65403-923c-4568-z2f6-a6f41b258azz"
        MicrosoftAppPassword: "<secret>"
        ```

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

    ```bash
    pulumi destroy -y
    pulumi stack rm -y
    ```
