Skip to main content
skill

azure-mgmt-apicenter-py — Claude Code skill: what it does

This skill guides Python work with Azure API Center, from API inventory and metadata to versions, environments, and deployments.

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

What azure-mgmt-apicenter-py does

The skill covers azure-mgmt-apicenter and ApiCenterMgmtClient. It gives the agent patterns for creating an API Center, listing services, registering APIs and versions, adding definitions, importing specifications, and managing environments and deployments.

A project needs azure-mgmt-apicenter and azure-identity. Authentication uses DefaultAzureCredential; production use can be constrained with AZURE_TOKEN_CREDENTIALS=prod. The examples also keep the client and credentials inside context managers so resources are released. Client creation fails without AZURE_SUBSCRIPTION_ID.

The skill targets Claude Code and GitHub Copilot. Its examples use Azure SDK for Python models such as Service, Api, ApiVersion, ApiDefinition, Environment, and Deployment.

What it helps with

  • create an API Center in Azure
  • register APIs and their versions
  • add or import an OpenAPI specification
  • list API Centers and APIs
  • describe an API environment and deployment

Example prompts for the agent

  • Create an API Center in my-resource-group with ApiCenterMgmtClient.
  • Register my-api, add version v1, and attach the openapi definition.
  • Import the supplied API specification into API Center and create a production deployment.

How to install azure-mgmt-apicenter-py

1Skills CLI (Vercel)

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

2Manually: put the files in place

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

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

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

Questions about azure-mgmt-apicenter-py

How do I install azure-mgmt-apicenter-py in Claude Code?

Run npx skills add microsoft/skills --skill azure-mgmt-apicenter-py -a claude-code, then check ~/.claude/skills/azure-mgmt-apicenter-py/SKILL.md.

What does azure-mgmt-apicenter-py do?

It provides Python guidance for Azure API Center management, including API inventory, metadata, versions, definitions, environments, and deployments.

What is required for authentication?

Install azure-mgmt-apicenter and azure-identity, set AZURE_SUBSCRIPTION_ID, and use DefaultAzureCredential. For production with that credential, set AZURE_TOKEN_CREDENTIALS=prod.

Source text

SKILL.md · MIT
---
name: azure-mgmt-apicenter-py
description: |
  Azure API Center Management SDK for Python. Use for managing API inventory, metadata, and governance across your organization.
  Triggers: "azure-mgmt-apicenter", "ApiCenterMgmtClient", "API Center", "API inventory", "API governance".
license: MIT
metadata:
  author: Microsoft
  version: "1.0.0"
  package: azure-mgmt-apicenter
---

# Azure API Center Management SDK for Python

Manage API inventory, metadata, and governance in Azure API Center.

## Installation

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

## Environment Variables

```bash
AZURE_SUBSCRIPTION_ID=your-subscription-id  # 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.apicenter import ApiCenterMgmtClient
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 ApiCenterMgmtClient(
    credential=credential,
    subscription_id=os.environ["AZURE_SUBSCRIPTION_ID"]
) as client:
    # Use `client` for all subsequent operations (see examples below)
    ...
```

## Create API Center

```python
from azure.mgmt.apicenter.models import Service

api_center = client.services.create_or_update(
    resource_group_name="my-resource-group",
    service_name="my-api-center",
    resource=Service(
        location="eastus",
        tags={"environment": "production"}
    )
)

print(f"Created API Center: {api_center.name}")
```

## List API Centers

```python
api_centers = client.services.list_by_subscription()

for api_center in api_centers:
    print(f"{api_center.name} - {api_center.location}")
```

## Register an API

```python
from azure.mgmt.apicenter.models import Api, ApiKind, ApiProperties

api = client.apis.create_or_update(
    resource_group_name="my-resource-group",
    service_name="my-api-center",
    workspace_name="default",
    api_name="my-api",
    resource=Api(
        properties=ApiProperties(
            title="My API",
            description="A sample API for demonstration",
            kind=ApiKind.REST,
            terms_of_service={"url": "https://example.com/terms"},
            contacts=[{"name": "API Team", "email": "[email protected]"}],
        )
    ),
)

print(f"Registered API: {api.properties.title}")
```

## Create API Version

```python
from azure.mgmt.apicenter.models import ApiVersion, ApiVersionProperties, LifecycleStage

version = client.api_versions.create_or_update(
    resource_group_name="my-resource-group",
    service_name="my-api-center",
    workspace_name="default",
    api_name="my-api",
    version_name="v1",
    resource=ApiVersion(
        properties=ApiVersionProperties(
            title="Version 1.0",
            lifecycle_stage=LifecycleStage.PRODUCTION,
        )
    ),
)

print(f"Created version: {version.properties.title}")
```

## Add API Definition

```python
from azure.mgmt.apicenter.models import ApiDefinition, ApiDefinitionProperties

definition = client.api_definitions.create_or_update(
    resource_group_name="my-resource-group",
    service_name="my-api-center",
    workspace_name="default",
    api_name="my-api",
    version_name="v1",
    definition_name="openapi",
    resource=ApiDefinition(
        properties=ApiDefinitionProperties(
            title="OpenAPI Definition",
            description="OpenAPI 3.0 specification",
        )
    ),
)
```

## Import API Specification

```python
from azure.mgmt.apicenter.models import ApiSpecImportRequest, ApiSpecImportSourceFormat

# Import from inline content
client.api_definitions.begin_import_specification(
    resource_group_name="my-resource-group",
    service_name="my-api-center",
    workspace_name="default",
    api_name="my-api",
    version_name="v1",
    definition_name="openapi",
    body=ApiSpecImportRequest(
        format=ApiSpecImportSourceFormat.INLINE,
        value='{"openapi": "3.0.0", "info": {"title": "My API", "version": "1.0"}, "paths": {}}',
    )
).result()
```

## List APIs

```python
apis = client.apis.list(
    resource_group_name="my-resource-group",
    service_name="my-api-center",
    workspace_name="default"
)

for api in apis:
    print(f"{api.name}: {api.title} ({api.kind})")
```

## Create Environment

```python
from azure.mgmt.apicenter.models import Environment, EnvironmentKind, EnvironmentProperties

environment = client.environments.create_or_update(
    resource_group_name="my-resource-group",
    service_name="my-api-center",
    workspace_name="default",
    environment_name="production",
    resource=Environment(
        properties=EnvironmentProperties(
            title="Production",
            description="Production environment",
            kind=EnvironmentKind.PRODUCTION,
            server={"type": "Azure API Management", "management_portal_uri": ["https://portal.azure.com"]},
        )
    ),
)
```

## Create Deployment

```python
from azure.mgmt.apicenter.models import Deployment, DeploymentProperties, DeploymentState

deployment = client.deployments.create_or_update(
    resource_group_name="my-resource-group",
    service_name="my-api-center",
    workspace_name="default",
    api_name="my-api",
    deployment_name="prod-deployment",
    resource=Deployment(
        properties=DeploymentProperties(
            title="Production Deployment",
            description="Deployed to production APIM",
            environment_id="/workspaces/default/environments/production",
            definition_id="/workspaces/default/apis/my-api/versions/v1/definitions/openapi",
            state=DeploymentState.ACTIVE,
            server={"runtime_uri": ["https://api.example.com"]},
        )
    ),
)
```

## Define Custom Metadata

```python
from azure.mgmt.apicenter.models import MetadataSchema, MetadataSchemaProperties

metadata = client.metadata_schemas.create_or_update(
    resource_group_name="my-resource-group",
    service_name="my-api-center",
    metadata_schema_name="data-classification",
    resource=MetadataSchema(
        properties=MetadataSchemaProperties(
            schema='{"type": "string", "title": "Data Classification", "enum": ["public", "internal", "confidential"]}'
        )
    ),
)
```

## Client Types

| Client | Purpose |
|--------|---------|
| `ApiCenterMgmtClient` | Main client for all operations |

## Operations

| Operation Group | Purpose |
|----------------|---------|
| `services` | API Center service management |
| `workspaces` | Workspace management |
| `apis` | API registration and management |
| `api_versions` | API version management |
| `api_definitions` | API definition management |
| `deployments` | Deployment tracking |
| `environments` | Environment management |
| `metadata_schemas` | Custom metadata definitions |

## 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 workspaces** to organize APIs by team or domain
4. **Define metadata schemas** for consistent governance
5. **Track deployments** to understand where APIs are running
6. **Import specifications** to enable API analysis and linting
7. **Use lifecycle stages** to track API maturity
8. **Add contacts** for API ownership and support

## 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 set143

The whole set →
azure-ai-contentsafety-ts Use this skill to add Azure AI Content Safety checks to TypeScript projects, including text and image analysis and custom blocked-term lists. 1installs azure-storage-file-datalake-py This skill guides Python work with Azure Data Lake Storage Gen2, from file-system setup to file and directory operations. Use it when building or updating ADLS Gen2 code. 1installs azure-servicebus-py This skill guides Python work with Azure Service Bus queues, topics, and subscriptions. Use it when adding message-based communication to an application. 1installs azure-monitor-opentelemetry-exporter-py A skill for low-level OpenTelemetry export of traces, metrics and logs to Application Insights from Python. Useful when you run a custom telemetry pipeline. 1installs azure-messaging-webpubsubservice-py A Python SDK skill for Azure Web PubSub Service: WebSocket messaging, groups, access tokens and connection management. 1installs azure-ai-language-conversations-py A skill for Conversational Language Understanding with the Python SDK: intent and entity analysis for dialog. Useful when you build NLP features on Azure. 1installs microsoft-azure-webjobs-extensions-authentication-events-dotnet A skill for handling Microsoft Entra ID custom authentication events in .NET: token claims, attribute collection, OTP delivery. 1installs azure-security-keyvault-keys-dotnet A skill for managing Azure Key Vault and Managed HSM keys from .NET: creation, rotation, encryption, signing. Useful when your agent writes C#. 1installs

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor