Skip to main content
skill CX Codex

azure-mgmt-botservice-py — Claude Code skill for Azure Bot Service

azure-mgmt-botservice-py — a skill for creating, configuring, and managing bots in Azure Bot Service via Python SDK. Connects Teams, Direct Line, and Web Chat channels, manages subscription resources.

MIT ★ 3,232 updated 2026-10-23

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add microsoft/skills --skill azure-mgmt-botservice-py -a claude-code
Open on GitHub

What azure-mgmt-botservice-py does

Uses azure-mgmt-botservice and azure-identity for bot operations: create, update, delete, list. Configures Teams, Direct Line, and Web Chat channels, sets endpoints and SKUs. Works via DefaultAzureCredential locally and in Azure, supports managed identity.

Requires AZURE_SUBSCRIPTION_ID and AZURE_RESOURCE_GROUP environment variables. Production needs AZURE_TOKEN_CREDENTIALS=prod. All SDK clients must be wrapped in context managers (with AzureBotService(...) as client:) to release HTTP transports and token caches.

Triggers on azure-mgmt-botservice, AzureBotService, bot management, conversational AI, bot channels. Documentation cuts off at channel key retrieval, but core operations are fully covered.

What it helps with

  • create a bot in Azure Bot Service and set the endpoint
  • connect Teams, Direct Line, or Web Chat channels to an existing bot
  • list all bots in a resource group or subscription
  • update bot display name and description
  • delete a bot and its channels from Azure

Example prompts for the agent

  • Create a bot named my-chat-bot in the resource group from the environment variable with endpoint https://my-bot-app.azurewebsites.net/api/messages
  • Add a Teams channel to bot my-chat-bot
  • Show all bots in the current resource group

How to install azure-mgmt-botservice-py

1Skills CLI (Vercel)

npx skills add microsoft/skills --skill azure-mgmt-botservice-py -a claude-code

2Manually: put the files in place

~/.claude/skills/azure-mgmt-botservice-py/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/azure-mgmt-botservice-py/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about azure-mgmt-botservice-py

How to install azure-mgmt-botservice-py in Claude Code?

Run npx skills add microsoft/skills --skill azure-mgmt-botservice-py -a claude-code, the skill will appear in ~/.claude/skills/azure-mgmt-botservice-py/SKILL.md.

What does azure-mgmt-botservice-py do?

Manages Azure Bot Service bots: creates, deletes, configures Teams and Direct Line channels, retrieves resource lists in the subscription via Python SDK.

What environment variables does azure-mgmt-botservice-py need?

Requires AZURE_SUBSCRIPTION_ID and AZURE_RESOURCE_GROUP for all authentication methods. For production, add AZURE_TOKEN_CREDENTIALS=prod to constrain the credential chain.

Source text

SKILL.md · MIT
---
name: azure-mgmt-botservice-py
description: |-
  Azure Bot Service Management SDK for Python. Use for creating, managing, and configuring Azure Bot Service resources.
  Triggers: "azure-mgmt-botservice", "AzureBotService", "bot management", "conversational AI", "bot channels".
license: MIT
metadata:
  author: Microsoft
  version: "1.0.0"
---

# Azure Bot Service Management SDK for Python

Manage Azure Bot Service resources including bots, channels, and connections.

## Installation

```bash
pip install azure-mgmt-botservice
pip install azure-identity
```

## Environment Variables

```bash
AZURE_SUBSCRIPTION_ID=<your-subscription-id>  # Required for all auth methods
AZURE_RESOURCE_GROUP=<your-resource-group>  # Required for all auth methods
AZURE_TOKEN_CREDENTIALS=prod # Required only if DefaultAzureCredential is used in production
```

## Authentication & Lifecycle

> **🔑 Two rules apply to every code sample below:**
>
> 1. **Prefer `DefaultAzureCredential`.** It works locally (Azure CLI / VS Code / Developer CLI) and in Azure (managed identity, workload identity) with no code change. Avoid connection strings, account/API keys — they bypass Entra audit and rotation.
>    - Local dev: `DefaultAzureCredential` works as-is.
>    - Production: set `AZURE_TOKEN_CREDENTIALS=prod` (or `AZURE_TOKEN_CREDENTIALS=<specific_credential>`) to constrain the credential chain to production-safe credentials.
> 2. **Wrap every client in a context manager** so HTTP transports, sockets, and token caches are released deterministically:
>    - Sync: `with <Client>(...) as client:`
>    - Async: `async with <Client>(...) as client:` **and** `async with DefaultAzureCredential() as credential:` (from `azure.identity.aio`)
>
> Snippets may abbreviate this setup, but production code should always follow both rules.

```python
from azure.identity import DefaultAzureCredential, ManagedIdentityCredential
from azure.mgmt.botservice import AzureBotService
import os

# Local dev: DefaultAzureCredential. Production: set AZURE_TOKEN_CREDENTIALS=prod or AZURE_TOKEN_CREDENTIALS=<specific_credential>
credential = DefaultAzureCredential(require_envvar=True)
# Or use a specific credential directly in production:
# See https://learn.microsoft.com/python/api/overview/azure/identity-readme?view=azure-python#credential-classes
# credential = ManagedIdentityCredential()

with AzureBotService(
    credential=credential,
    subscription_id=os.environ["AZURE_SUBSCRIPTION_ID"]
) as client:
    # Use `client` for all subsequent operations (see examples below)
    ...
```

## Create a Bot

```python
from azure.mgmt.botservice import AzureBotService
from azure.mgmt.botservice.models import Bot, BotProperties, Sku
from azure.identity import DefaultAzureCredential
import os

resource_group = os.environ["AZURE_RESOURCE_GROUP"]
bot_name = "my-chat-bot"

credential = DefaultAzureCredential()
with AzureBotService(
    credential=credential,
    subscription_id=os.environ["AZURE_SUBSCRIPTION_ID"]
) as client:
    bot = client.bots.create(
        resource_group_name=resource_group,
        resource_name=bot_name,
        parameters=Bot(
            location="global",
            sku=Sku(name="F0"),  # Free tier
            kind="azurebot",
            properties=BotProperties(
                display_name="My Chat Bot",
                description="A conversational AI bot",
                endpoint="https://my-bot-app.azurewebsites.net/api/messages",
                msa_app_id="<your-app-id>",
                msa_app_type="MultiTenant"
            )
        )
    )

print(f"Bot created: {bot.name}")
```

## Get Bot Details

```python
bot = client.bots.get(
    resource_group_name=resource_group,
    resource_name=bot_name
)

print(f"Bot: {bot.properties.display_name}")
print(f"Endpoint: {bot.properties.endpoint}")
print(f"SKU: {bot.sku.name}")
```

## List Bots in Resource Group

```python
bots = client.bots.list_by_resource_group(resource_group_name=resource_group)

for bot in bots:
    print(f"Bot: {bot.name} - {bot.properties.display_name}")
```

## List All Bots in Subscription

```python
all_bots = client.bots.list()

for bot in all_bots:
    print(f"Bot: {bot.name} in {bot.id.split('/')[4]}")
```

## Update Bot

```python
bot = client.bots.update(
    resource_group_name=resource_group,
    resource_name=bot_name,
    properties=BotProperties(
        display_name="Updated Bot Name",
        description="Updated description"
    )
)
```

## Delete Bot

```python
client.bots.delete(
    resource_group_name=resource_group,
    resource_name=bot_name
)
```

## Configure Channels

### Add Teams Channel

```python
from azure.mgmt.botservice.models import (
    BotChannel,
    MsTeamsChannel,
    MsTeamsChannelProperties
)

channel = client.channels.create(
    resource_group_name=resource_group,
    resource_name=bot_name,
    channel_name="MsTeamsChannel",
    parameters=BotChannel(
        location="global",
        properties=MsTeamsChannel(
            properties=MsTeamsChannelProperties(
                is_enabled=True
            )
        )
    )
)
```

### Add Direct Line Channel

```python
from azure.mgmt.botservice.models import (
    BotChannel,
    DirectLineChannel,
    DirectLineChannelProperties,
    DirectLineSite
)

channel = client.channels.create(
    resource_group_name=resource_group,
    resource_name=bot_name,
    channel_name="DirectLineChannel",
    parameters=BotChannel(
        location="global",
        properties=DirectLineChannel(
            properties=DirectLineChannelProperties(
                sites=[
                    DirectLineSite(
                        site_name="Default Site",
                        is_enabled=True,
                        is_v1_enabled=False,
                        is_v3_enabled=True
                    )
                ]
            )
        )
    )
)
```

### Add Web Chat Channel

```python
from azure.mgmt.botservice.models import (
    BotChannel,
    WebChatChannel,
    WebChatChannelProperties,
    WebChatSite
)

channel = client.channels.create(
    resource_group_name=resource_group,
    resource_name=bot_name,
    channel_name="WebChatChannel",
    parameters=BotChannel(
        location="global",
        properties=WebChatChannel(
            properties=WebChatChannelProperties(
                sites=[
                    WebChatSite(
                        site_name="Default Site",
                        is_enabled=True
                    )
                ]
            )
        )
    )
)
```

## Get Channel Details

```python
channel = client.channels.get(
    resource_group_name=resource_group,
    resource_name=bot_name,
    channel_name="DirectLineChannel"
)
```

## List Channel Keys

```python
keys = client.channels.list_with_keys(
    resource_group_name=resource_group,
    resource_name=bot_name,
    channel_name="DirectLineChannel"
)

# Access Direct Line keys
if hasattr(keys.properties, 'properties'):
    for site in keys.properties.properties.sites:
        print(f"Site: {site.site_name}")
        print(f"Key: {site.key}")
```

## Bot Connections (OAuth)

### Create Connection Setting

```python
from azure.mgmt.botservice.models import (
    ConnectionSetting,
    ConnectionSettingProperties
)

connection = client.bot_connection.create(
    resource_group_name=resource_group,
    resource_name=bot_name,
    connection_name="graph-connection",
    parameters=ConnectionSetting(
        location="global",
        properties=ConnectionSettingProperties(
            client_id="<oauth-client-id>",
            client_secret="<oauth-client-secret>",
            scopes="User.Read",
            service_provider_id="<service-provider-id>"
        )
    )
)
```

### List Connections

```python
connections = client.bot_connection.list_by_bot_service(
    resource_group_name=resource_group,
    resource_name=bot_name
)

for conn in connections:
    print(f"Connection: {conn.name}")
```

## Client Operations

| Operation | Method |
|-----------|--------|
| `client.bots` | Bot CRUD operations |
| `client.channels` | Channel configuration |
| `client.bot_connection` | OAuth connection settings |
| `client.direct_line` | Direct Line channel operations |
| `client.email` | Email channel operations |
| `client.operations` | Available operations |
| `client.host_settings` | Host settings operations |

## SKU Options

| SKU | Description |
|-----|-------------|
| `F0` | Free tier (limited messages) |
| `S1` | Standard tier (unlimited messages) |

## Channel Types

| Channel | Class | Purpose |
|---------|-------|---------|
| `MsTeamsChannel` | Microsoft Teams | Teams integration |
| `DirectLineChannel` | Direct Line | Custom client integration |
| `WebChatChannel` | Web Chat | Embeddable web widget |
| `SlackChannel` | Slack | Slack workspace integration |
| `FacebookChannel` | Facebook | Messenger integration |
| `EmailChannel` | Email | Email communication |

## Best Practices

1. **Pick sync OR async and stay consistent.** Do not mix `azure.xxx` sync clients with `azure.xxx.aio` async clients in the same call path. Choose one mode per module.
2. **Always use context managers for clients and async credentials.** Wrap every client in `with Client(...) as client:` (sync) or `async with Client(...) as client:` (async). For async `DefaultAzureCredential` from `azure.identity.aio`, also use `async with credential:` so tokens and transports are cleaned up.
3. **Use `DefaultAzureCredential`** for code that runs locally. Use a specific token credential for code that runs in Azure.
4. **Start with F0 SKU** for development, upgrade to S1 for production
5. **Store MSA App ID/Secret securely** — use Key Vault
6. **Enable only needed channels** — reduces attack surface
7. **Rotate Direct Line keys** periodically
8. **Use managed identity** when possible for bot connections
9. **Configure proper CORS** for Web Chat channel

## Reference Files

| File | Contents |
|------|----------|
| [references/capabilities.md](references/capabilities.md) | Additional non-hero capabilities, operation-group coverage, and production checklists. |
| [references/non-hero-scenarios.md](references/non-hero-scenarios.md) | Dedicated non-hero examples for secondary/advanced scenarios. |

© Microsoft · MIT · microsoft/skills

Similar skills

All skills for Cloud: AWS, Azure, GCP →

From the same set250

The whole set →
azure-servicebus-ts azure-servicebus-ts — a skill for Claude Code and GitHub Copilot that gives the agent TypeScript patterns for the Azure Service Bus SDK. It kicks in when you build queues, topics, subscriptions, message sessions, or dead-letter handling. CX Codex +1 ★ 3,232repo stars azure-storage-queue-rust azure-storage-queue-rust guides AI assistants in writing Rust code for Azure Queue Storage via azure_storage_queue. It helps send, read, and delete queue messages cleanly. CX Codex +1 ★ 3,232repo stars azure-storage-queue-py azure-storage-queue-py — a skill for Claude Code and GitHub Copilot that brings the Azure Queue Storage Python SDK into the agent's workflow. It kicks in for message queues, task distribution, and async processing code. CX Codex +1 ★ 3,232repo stars azure-mgmt-fabric-py azure-mgmt-fabric-py — a skill for Claude Code and GitHub Copilot that brings the Azure Fabric Management SDK for Python into your project. The agent writes code to manage Microsoft Fabric capacities: create, update, suspend, delete. CX Codex +1 ★ 3,232repo stars azure-storage-blob-java Supplies ready-to-use patterns for the Azure Storage Blob Java SDK, covering authentication, container administration, and file uploads. CX Codex +1 ★ 3,232repo stars azure-security-keyvault-secrets-java The azure-security-keyvault-secrets-java skill guides Java work with Azure Key Vault secrets, from client setup and retrieval to versioning, deletion, recovery, and backups. CX Codex +1 ★ 3,232repo stars azure-security-keyvault-keys-java azure-security-keyvault-keys-java — a skill for managing Azure Key Vault keys from Java: RSA and EC creation, encrypt, sign, HSM-backed keys. Useful when the agent writes Azure SDK code. CX Codex +1 ★ 3,232repo stars azure-monitor-query-java azure-monitor-query-java provides Java patterns for KQL queries in Log Analytics and Azure resource metrics. Helpful when maintaining projects on the com.azure:azure-monitor-query library. CX Codex +1 ★ 3,232repo stars

Project sponsors

Companies that keep this analytics open