技能 Azure API Management SDK for Python
📦

Azure API Management SDK for Python

安全

使用 Python SDK 管理 Azure API

此技能帮助开发者使用 Python 集成和管理 Azure API 管理服务,实现自动化的 API 部署和管理流程。

支持: Claude Codex Code(CC)
🥉 73 青铜
1

下载技能 ZIP

2

在 Claude 中上传

前往 设置 → 功能 → 技能 → 上传技能

3

开启并开始使用

测试它

正在使用“Azure API Management SDK for Python”。 创建 API Management 服务实例

预期结果:

```python
from azure.mgmt.apimanagement import ApiManagementClient
from azure.identity import DefaultAzureCredential

# Initialize the client
credential = DefaultAzureCredential()
subscription_id = "your-subscription-id"
resource_group_name = "your-resource-group"
service_name = "your-api-service"

client = ApiManagementClient(credential, subscription_id)

# Create the API Management service
poller = client.api_management_service.begin_create_or_update(
resource_group_name,
service_name,
{
'location': 'eastus',
'publisher_name': 'Your Company',
'publisher_email': 'admin@company.com',
'sku_name': 'Developer',
'sku_capacity': 1
}
)
result = poller.result()
print(f"API Management service created: {result.name}")
```

正在使用“Azure API Management SDK for Python”。 注册新 API

预期结果:

```python
# Register a new API in API Management
api_id = "my-new-api"
client.api.begin_create_or_update(
resource_group_name,
service_name,
api_id,
{
'display_name': 'My New API',
'path': 'myapi',
'service_url': 'https://api.example.com',
'protocols': ['https']
}
)
```

正在使用“Azure API Management SDK for Python”。 配置 API 策略

预期结果:

```python
# Apply rate limiting policy
client.api_policy.create_or_update(
resource_group_name,
service_name,
api_id,
{
'format': 'xml',
'value': '<policies><inbound><rate-limit-by-key calls="100" renewal-period="60" counter-key="@(context.Request.IpAddress)" /></inbound></policies>'
}
)
```

安全审计

安全
v1 • 2/25/2026

This is a prompt-only skill containing documentation and guidance for the Azure API Management SDK for Python. The static analyzer scanned 0 files and detected 0 potential security issues. The skill provides educational content about Azure API Management without any executable code that could pose security risks.

0
已扫描文件
0
分析行数
0
发现项
1
审计总数
未发现安全问题
审计者: claude

质量评分

38
架构
100
可维护性
87
内容
50
社区
100
安全
83
规范符合性

你能构建什么

自动化 API 部署的 DevOps 工程师

使用 Python 脚本在 CI/CD 流程中自动化创建和配置 API 管理实例。

构建 API 网关的后端开发者

使用 SDK 以编程方式创建 API、配置速率限制并为后端服务设置身份验证。

管理 API 基础设施的平台工程师

跨不同环境管理多个 API 管理实例、产品和订阅。

试试这些提示

在 Azure API Management 中创建基本 API
展示如何使用 Python SDK 在 Azure API Management 中创建新 API。包括设置 API、添加操作和配置后端服务的代码。
配置 API 身份验证策略
如何使用 Python 在 Azure API Management 中为 API 配置 JWT 验证和 OAuth2 身份验证策略?
导入 OpenAPI 规范
编写 Python 代码将 OpenAPI 3.0 规范导入 Azure API Management 并生成文档。
设置速率限制和配额
展示如何使用 Azure API Management Python SDK 配置速率限制策略和产品订阅配额。

最佳实践

  • 使用托管标识进行身份验证,而不是在代码中存储凭据
  • 按产品组织 API,并使用订阅密钥进行访问控制
  • 从一开始就为 API 应用版本控制,以实现平滑更新

避免

  • 不要在源代码中硬编码订阅密钥或机密
  • 避免在未经测试的情况下直接在生产环境中配置策略
  • 不要在没有 API 管理层的情况下直接暴露后端服务

常见问题

什么是 Azure API Management?
Azure API Management 是一项云服务,帮助组织发布、管理、保护和分析 API。它为 API 流量提供网关、缓存、身份验证和日志记录功能。
我需要 Azure 订阅才能使用此技能吗?
您不需要 Azure 订阅即可通过此技能学习。但是,要执行生成的代码,您将需要有效的 Azure 订阅。
支持哪些 Python 版本?
用于 Python 的 Azure API Management SDK 支持 Python 3.7 及更高版本。
此技能可以帮助进行 API 版本控制吗?
是的,此技能包含有关使用 Azure API Management 设置和管理 API 版本的指导。
如何向 Azure 进行身份验证?
您可以使用 Azure Active Directory、托管标识或服务主体凭据。推荐的方法是使用 DefaultAzureCredential 进行本地开发。
我可以导入现有的 OpenAPI 规范吗?
是的,Azure API Management 支持导入 OpenAPI 2.0 和 3.0 规范,此技能涵盖如何以编程方式执行此操作。

开发者详情

文件结构

📄 SKILL.md