AI 技能AI 插件人工智能【免费下载链接】agentic-awesome-skillsAAS Core is the local, agent-first control plane for complete catalog discovery, agent-owned selection, stack validation, and planning, backed by 2,600+ agentic skills. Includes CLI, local MCP, catalog, plugins, and Workbench.项目地址:https://gitcode.com/GitHub_Trending/an/agentic-awesome-skills点击查看免费下载本篇文章围绕 agentic-awesome-skills 仓库中azure-mgmt-apimanagement-py技能文档展开,系统讲解如何用 Azure API Management SDK for Python(azure-mgmt-apimanagement)完成 APIM 服务的全生命周期管理:从环境准备、身份认证、创建服务实例,到导入 OpenAPI、组织产品与订阅、下发策略、维护后端与密钥。读完本文,你将获得一套可直接复制运行的 Python 脚本模板,以及每个操作背后的资源模型与调用链理解,可直接用于 Agent 自动化编排或日常运维脚本开发。技能文档定位与适用场景该技能文档位于仓库两个位置,内容一致:skills/azure-mgmt-apimanagement-py/SKILL.md(技能集合主目录)plugins/agentic-awesome-skills-claude/skills/azure-mgmt-apimanagement-py/SKILL.md(Claude 插件分发的同名技能)技能元数据(frontmatter)标明:name: azure-mgmt-apimanagement-py,description明确其用途为"管理 APIM 服务、API、产品、订阅与策略",risk: critical提示该技能涉及对生产级云资源的写操作,source: community表明它来自社区贡献,date_added: '2026-02-27'记录了入库时间。仓库中还存在同主题的 .NET 版本 skills/azure-mgmt-apimanagement-dotnet/SKILL.md,可互为参照。在 agentic-awesome-skills 的目录体系下,这类 skill 就是"面向 Agent 的、可执行具体云端工作流的最小知识单元"——本文即把它转化为可落地的工程实践。该技能适合以下场景:初始化 APIM 实例并批量导入已有 OpenAPI 定义、以代码方式维护产品/订阅/API 的访问关系、把限流与 Header 注入等策略纳入 Git 化配置、将密钥与后端地址抽象为命名值和 Backend 资源。环境准备:安装依赖与环境变量技能文档给出的安装命令只需两个包:pip install azure-mgmt-apimanagement pip install azure-identityazure-mgmt-apimanagement:APIM 资源管理客户端 SDK,提供ApiManagementClient及全部资源模型;azure-identity:提供DefaultAzureCredential等统一认证实现,负责从环境变量、托管身份、Azure CLI 登录态等来源按序获取凭据。随后在运行环境中声明订阅 ID:AZURE_SUBSCRIPTION_ID=your-subscription-id该变量会被下面的客户端初始化代码读取,用于确定所有资源操作所归属的 Azure 订阅。若要开箱即用,通常还需为DefaultAzureCredential提供登录凭据(例如已执行az login或配置了服务主体的环境变量),技能文档假设这些前置条件已具备。初始化客户端:DefaultAzureCredential 认证技能文档给出了标准的客户端初始化模式:from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient import os client = ApiManagementClient( credential=DefaultAzureCredential(), subscription_id=os.environ["AZURE_SUBSCRIPTION_ID"] )ApiManagementClient的所有后续操作都通过client.<operation_group>暴露,这与文档末尾"Operation Groups"表格一一对应。DefaultAzureCredential会按顺序尝试环境变量凭据、托管身份、Visual Studio / Azure CLI 等登录态,适合本地脚本与云上托管执行两种环境,无需在代码中硬编码密钥。创建 APIM 服务实例创建一个 APIM 服务需要指定位置、发布者信息与 SKU:from azure.mgmt.apimanagement.models import ( ApiManagementServiceResource, ApiManagementServiceSkuProperties, SkuType ) service = client.api_management_service.begin_create_or_update( resource_group_name="my-resource-group", service_name="my-apim", parameters=ApiManagementServiceResource( location="eastus", publisher_email="admin@example.com", publisher_name="My Organization", sku=ApiManagementServiceSkuProperties( name=SkuType.DEVELOPER, capacity=1 ) ) ).result() print(f"Created APIM: {service.name}")要点说明:该方法以begin_前缀表示长时运行操作(LRO),需调用.result()等待部署完成——APIM 实例创建通常需要数分钟;SkuType可选值包括DEVELOPER、BASIC、STANDARD、PREMIUM等,capacity对应各 SKU 的容量单位(Developer 为 1 个单元,PREMIUM可扩展多个单元以支持高可用与更多区域);技能示例选用DEVELOPER适合开发验证;publisher_email/publisher_name会展示在开发者门户中,属于必填的发布者信息。导入 API:OpenAPI 内联与 URL 两种方式内联 JSON 导入from azure.mgmt.apimanagement.models import ( ApiCreateOrUpdateParameter, ContentFormat, Protocol ) api = client.api.begin_create_or_update( resource_group_name="my-resource-group", service_name="my-apim", api_id="my-api", parameters=ApiCreateOrUpdateParameter( display_name="My API", path="myapi", protocols=[Protocol.HTTPS], format=ContentFormat.OPENAPI_JSON, value='{"openapi": "3.0.0", "info": {"title": "My API", "version": "1.0"}, "paths": {"/health": {"get": {"responses": {"200": {"description": "OK"}}}}}}' ) ).result() print(f"Imported API: {api.display_name}")api_id是 APIM 内部的 API 标识(URL 中可见);path决定 API 在 APIM 网关下的 URL 前缀(如/myapi/...);protocols限定HTTP/HTTPS;format=ContentFormat.OPENAPI_JSON配合value内联传入 OpenAPI 3.0 的 JSON 文档,适合将定义作为代码资产随仓库版本化。从 URL 导入api = client.api.begin_create_or_update( resource_group_name="my-resource-group", service_name="my-apim", api_id="petstore", parameters=ApiCreateOrUpdateParameter( display_name="Petstore API", path="petstore", protocols=[Protocol.HTTPS], format=ContentFormat.OPENAPI_LINK, value="https://petstore.swagger.io/v2/swagger.json" ) ).result()区别仅在format与value:ContentFormat.OPENAPI_LINK表示value是可供 APIM 抓取的 OpenAPI 文档 URL。两种方式都会自动把文档中的端点解析为api_operation下的操作列表。列出服务下的全部 APIapis = client.api.list_by_service( resource_group_name="my-resource-group", service_name="my-apim" ) for api in apis: print(f"{api.name}: {api.display_name} - {api.path}")list_by_service返回可迭代的分页集合,直接遍历即可拿到每个 API 的名称、显示名与 URL 路径,适合核对导入结果。组织访问:产品、订阅与用户创建产品产品用于将一组 API 打包成可订阅的访问单位:from azure.mgmt.apimanagement.models import ProductContract product = client.product.create_or_update( resource_group_name="my-resource-group", service_name="my-apim", product_id="premium", parameters=ProductContract( display_name="Premium", description="Premium tier with unlimited access", subscription_required=True, approval_required=False, state="published" ) ) print(f"Created product: {product.display_name}")字段语义:subscription_required=True:消费者必须持有订阅密钥才能调用该产品下的 API;approval_required=False:订阅申请无需管理员审批,自动生效;state="published":产品对开发者门户可见且可订阅(unpublished则不可见)。将 API 关联到产品client.product_api.create_or_update( resource_group_name="my-resource-group", service_name="my-apim", product_id="premium", api_id="my-api" )product_api操作组专门维护"产品 ↔ API"的多对多关联,一个产品可挂多个 API,一个 API 也可属于多个产品。创建订阅并获取密钥from azure.mgmt.apimanagement.models import SubscriptionCreateParameters subscription = client.subscription.create_or_update( resource_group_name="my-resource-group", service_name="my-apim", sid="my-subscription", parameters=SubscriptionCreateParameters( display_name="My Subscription", scope=f"/products/premium", state="active" ) ) print(f"Subscription key: {subscription.primary_key}")scope指向订阅的产品路径(/products/premium),也可以指向/apis/<api-id>或/apis/<api-id>/releases/<release-id>实现 API 级订阅;state="active"使订阅立即可用;返回的primary_key(以及成对的secondary_key)就是调用方发起请求时通过Ocp-Apim-Subscription-Key头携带的密钥,请妥善保管,避免写入日志或版本库。创建用户from azure.mgmt.apimanagement.models import UserCreateParameters user = client.user.create_or_update( resource_group_name="my-resource-group", service_name="my-apim", user_id="newuser", parameters=UserCreateParameters( email="user@example.com", first_name="John", last_name="Doe" ) )用户是订阅的主体(也可归属组),示例中仅提供基本身份信息;实际接入时还可以通过client.group_user等操作组把用户加入组以继承组级策略。治理与安全:策略、命名值与后端设置 API 级策略APIM 的策略是 XML 声明式管道,技能文档给出了包含限流与 Header 注入的完整示例:from azure.mgmt.apimanagement.models import PolicyContract policy_xml = """ <policies> <inbound> <rate-limit calls="100" renewal-period="60" /> <set-header name="X-Custom-Header" exists-action="override"> <value>CustomValue</value> </set-header> </inbound> <backend> <forward-request /> </backend> <outbound /> <on-error /> </policies> """ client.api_policy.create_or_update( resource_group_name="my-resource-group", service_name="my-apim", api_id="my-api", policy_id="policy", parameters=PolicyContract( value=policy_xml, format="xml" ) )<rate-limit calls="100" renewal-period="60" />:对每个订阅密钥施加"每 60 秒最多 100 次调用"的限流;<set-header ... exists-action="override">:在请求转发前强制注入或覆盖X-Custom-Header;策略可作用在四个层级——全局、产品、API、操作(文档 Best Practices 第 2 条),api_policy对应 API 级,其余层级分别由policy(全局,client.policy)、product_policy、api_operation_policy等操作组管理。创建命名值(密钥抽象)from azure.mgmt.apimanagement.models import NamedValueCreateContract named_value = client.named_value.begin_create_or_update( resource_group_name="my-resource-group", service_name="my-apim", named_value_id="backend-api-key", parameters=NamedValueCreateContract( display_name="Backend API Key", value="secret-key-value", secret=True ) ).result()secret=True会把该值作为加密密钥存储,策略中通过{{backend-api-key}}语法引用;密钥与配置由此从代码/XML 中剥离,符合文档 Best Practices 第 1 条。创建后端(后端抽象)from azure.mgmt.apimanagement.models import BackendContract backend = client.backend.create_or_update( resource_group_name="my-resource-group", service_name="my-apim", backend_id="my-backend", parameters=BackendContract( url="https://api.backend.example.com", protocol="http", description="My backend service" ) )Backend 将真实上游地址、协议与凭据封装为独立资源,策略中以<set-backend-service backend-id="my-backend" />引用,实现"API 定义与后端拓扑解耦"(对应 Best Practices 第 5 条)。文档中的url指向示例域,实际使用请替换为真实后端。操作组全景:SDK 能力地图技能文档以表格形式给出了 SDK 的主要操作组,这是理解客户端能力边界的核心索引:GroupPurposeapi_management_serviceAPIM instance managementapiAPI operationsapi_operationAPI operation detailsapi_policyAPI-level policiesproductProduct managementproduct_apiProduct-API associationssubscriptionSubscription managementuserUser managementnamed_valueNamed values/secretsbackendBackend servicescertificateCertificatesgatewaySelf-hosted gateways在此基础上可延伸理解:api_operation对应 OpenAPI 导入后解析出的每个端点(可单独配置操作级策略与重写);certificate用于管理网关 TLS 证书;gateway面向自托管(self-hosted)网关的部署管理。日常开发中,绝大多数"创建 API → 打产品 → 发订阅 → 挂策略 → 接后端"的闭环都能仅凭上表完成。最佳实践与使用边界技能文档给出的六条实践Use named valuesfor secrets and configuration —— 密钥与可变配置一律走命名值,避免散落于策略 XML;Apply policies at appropriate scopes(global, product, API, operation) —— 按最小必要范围放置策略,例如全局放安全头、API 级放限流;Use products to bundle APIs and manage access—— 用产品统一管理 API 分组与订阅准入;Enable Application Insights for monitoring—— 在 APIM 诊断设置中对接 Application Insights,获取调用量、延迟、失败率等可观测数据;Use backends to abstract backend services—— 用 Backend 资源屏蔽上游地址变化;Version your APIsusing APIM's versioning features —— 利用 APIM 的版本集(versioning)能力做不破坏兼容的演进。When to Use 与 Limitations技能元数据中description明确该技能"用于管理 APIM 服务、API、产品、订阅与策略",因此:仅当任务清晰落在上述范围内时才应启用本技能;涉及其他云资源(如 AKS、存储、函数)应选择仓库中对应的azure-*-py系列技能;该技能输出不替代环境相关的验证、测试与专家评审——risk: critical意味着begin_create_or_update、create_or_update会对真实云资源产生变更,执行前应确认资源组、命名与 SKU 选择;若缺少必要输入(订阅 ID、资源组、权限边界、成功标准),应停止并请求澄清,而不是盲目执行写操作。小结azure-mgmt-apimanagement-py技能文档覆盖了 APIM 管理中最核心的九类操作:客户端认证、服务创建、双通道 API 导入、产品/订阅/用户组织、策略下发、命名值与后端抽象,并提供了完整的可运行代码与操作组索引。结合 agentic-awesome-skills 的技能组织方式,这套脚本可以直接封装为 Agent 可调用的工作流——无论是 CI 中自动同步 OpenAPI 定义,还是按产品维度批量开通订阅,都能以本文的代码骨架为起点落地。动手前请记住两条铁律:密钥只走命名值,写操作前先核对作用域与权限。赞分享AI 技能AI 插件人工智能【免费下载链接】agentic-awesome-skillsAAS Core is the local, agent-first control plane for complete catalog discovery, agent-owned selection, stack validation, and planning, backed by 2,600+ agentic skills. Includes CLI, local MCP, catalog, plugins, and Workbench.项目地址:https://gitcode.com/GitHub_Trending/an/agentic-awesome-skills点击查看免费下载相关推荐agentic-awesome-skills 实战:用 azure-mgmt-apicenter Python SDK 管理 Azure API Center 的 API 资产与治理agentic awesome skills 实战:用 azure mgmt apicenter Python SDK 管理 Azure API CenterAI 技能AI 插件人工智能Agentic Awesome Skills 实战:用 azure-containerregistry-py 管理 Azure 容器镜像与制品仓库Agentic Awesome Skills 实战:用 azure containerregistry py 管理 Azure 容器镜像与制品仓库 导读 本指南AI 技能AI 插件人工智能agentic-awesome-skills 实战:用 azure-storage-blob-py 技能驾驭 Azure Blob Storage 全生命周期agentic awesome skills 实战:用 azure storage blob py 技能驾驭 Azure Blob Storage 全生命周期AI 技能AI 插件人工智能上一篇:开源项目OpenStack-Ansible指南及问题解决方案下一篇:开源项目解析:Flask 视频流直播平台入门指南创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考
AI 技能AI 插件人工智能【免费下载链接】agentic-awesome-skillsAAS Core is the local, agent-first control plane for complete catalog discovery, agent-owned selection, stack validation, and planning, backed by 2,600+ agentic skills. Includes CLI, local MCP, catalog, plugins, and Workbench.项目地址:https://gitcode.com/GitHub_Trending/an/agentic-awesome-skills点击查看免费下载本篇文章围绕 agentic-awesome-skills 仓库中azure-mgmt-apimanagement-py技能文档展开,系统讲解如何用 Azure API Management SDK for Python(azure-mgmt-apimanagement)完成 APIM 服务的全生命周期管理:从环境准备、身份认证、创建服务实例,到导入 OpenAPI、组织产品与订阅、下发策略、维护后端与密钥。读完本文,你将获得一套可直接复制运行的 Python 脚本模板,以及每个操作背后的资源模型与调用链理解,可直接用于 Agent 自动化编排或日常运维脚本开发。技能文档定位与适用场景该技能文档位于仓库两个位置,内容一致:skills/azure-mgmt-apimanagement-py/SKILL.md(技能集合主目录)plugins/agentic-awesome-skills-claude/skills/azure-mgmt-apimanagement-py/SKILL.md(Claude 插件分发的同名技能)技能元数据(frontmatter)标明:name: azure-mgmt-apimanagement-py,description明确其用途为"管理 APIM 服务、API、产品、订阅与策略",risk: critical提示该技能涉及对生产级云资源的写操作,source: community表明它来自社区贡献,date_added: '2026-02-27'记录了入库时间。仓库中还存在同主题的 .NET 版本 skills/azure-mgmt-apimanagement-dotnet/SKILL.md,可互为参照。在 agentic-awesome-skills 的目录体系下,这类 skill 就是"面向 Agent 的、可执行具体云端工作流的最小知识单元"——本文即把它转化为可落地的工程实践。该技能适合以下场景:初始化 APIM 实例并批量导入已有 OpenAPI 定义、以代码方式维护产品/订阅/API 的访问关系、把限流与 Header 注入等策略纳入 Git 化配置、将密钥与后端地址抽象为命名值和 Backend 资源。环境准备:安装依赖与环境变量技能文档给出的安装命令只需两个包:pip install azure-mgmt-apimanagement pip install azure-identityazure-mgmt-apimanagement:APIM 资源管理客户端 SDK,提供ApiManagementClient及全部资源模型;azure-identity:提供DefaultAzureCredential等统一认证实现,负责从环境变量、托管身份、Azure CLI 登录态等来源按序获取凭据。随后在运行环境中声明订阅 ID:AZURE_SUBSCRIPTION_ID=your-subscription-id该变量会被下面的客户端初始化代码读取,用于确定所有资源操作所归属的 Azure 订阅。若要开箱即用,通常还需为DefaultAzureCredential提供登录凭据(例如已执行az login或配置了服务主体的环境变量),技能文档假设这些前置条件已具备。初始化客户端:DefaultAzureCredential 认证技能文档给出了标准的客户端初始化模式:from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient import os client = ApiManagementClient( credential=DefaultAzureCredential(), subscription_id=os.environ["AZURE_SUBSCRIPTION_ID"] )ApiManagementClient的所有后续操作都通过client.<operation_group>暴露,这与文档末尾"Operation Groups"表格一一对应。DefaultAzureCredential会按顺序尝试环境变量凭据、托管身份、Visual Studio / Azure CLI 等登录态,适合本地脚本与云上托管执行两种环境,无需在代码中硬编码密钥。创建 APIM 服务实例创建一个 APIM 服务需要指定位置、发布者信息与 SKU:from azure.mgmt.apimanagement.models import ( ApiManagementServiceResource, ApiManagementServiceSkuProperties, SkuType ) service = client.api_management_service.begin_create_or_update( resource_group_name="my-resource-group", service_name="my-apim", parameters=ApiManagementServiceResource( location="eastus", publisher_email="admin@example.com", publisher_name="My Organization", sku=ApiManagementServiceSkuProperties( name=SkuType.DEVELOPER, capacity=1 ) ) ).result() print(f"Created APIM: {service.name}")要点说明:该方法以begin_前缀表示长时运行操作(LRO),需调用.result()等待部署完成——APIM 实例创建通常需要数分钟;SkuType可选值包括DEVELOPER、BASIC、STANDARD、PREMIUM等,capacity对应各 SKU 的容量单位(Developer 为 1 个单元,PREMIUM可扩展多个单元以支持高可用与更多区域);技能示例选用DEVELOPER适合开发验证;publisher_email/publisher_name会展示在开发者门户中,属于必填的发布者信息。导入 API:OpenAPI 内联与 URL 两种方式内联 JSON 导入from azure.mgmt.apimanagement.models import ( ApiCreateOrUpdateParameter, ContentFormat, Protocol ) api = client.api.begin_create_or_update( resource_group_name="my-resource-group", service_name="my-apim", api_id="my-api", parameters=ApiCreateOrUpdateParameter( display_name="My API", path="myapi", protocols=[Protocol.HTTPS], format=ContentFormat.OPENAPI_JSON, value='{"openapi": "3.0.0", "info": {"title": "My API", "version": "1.0"}, "paths": {"/health": {"get": {"responses": {"200": {"description": "OK"}}}}}}' ) ).result() print(f"Imported API: {api.display_name}")api_id是 APIM 内部的 API 标识(URL 中可见);path决定 API 在 APIM 网关下的 URL 前缀(如/myapi/...);protocols限定HTTP/HTTPS;format=ContentFormat.OPENAPI_JSON配合value内联传入 OpenAPI 3.0 的 JSON 文档,适合将定义作为代码资产随仓库版本化。从 URL 导入api = client.api.begin_create_or_update( resource_group_name="my-resource-group", service_name="my-apim", api_id="petstore", parameters=ApiCreateOrUpdateParameter( display_name="Petstore API", path="petstore", protocols=[Protocol.HTTPS], format=ContentFormat.OPENAPI_LINK, value="https://petstore.swagger.io/v2/swagger.json" ) ).result()区别仅在format与value:ContentFormat.OPENAPI_LINK表示value是可供 APIM 抓取的 OpenAPI 文档 URL。两种方式都会自动把文档中的端点解析为api_operation下的操作列表。列出服务下的全部 APIapis = client.api.list_by_service( resource_group_name="my-resource-group", service_name="my-apim" ) for api in apis: print(f"{api.name}: {api.display_name} - {api.path}")list_by_service返回可迭代的分页集合,直接遍历即可拿到每个 API 的名称、显示名与 URL 路径,适合核对导入结果。组织访问:产品、订阅与用户创建产品产品用于将一组 API 打包成可订阅的访问单位:from azure.mgmt.apimanagement.models import ProductContract product = client.product.create_or_update( resource_group_name="my-resource-group", service_name="my-apim", product_id="premium", parameters=ProductContract( display_name="Premium", description="Premium tier with unlimited access", subscription_required=True, approval_required=False, state="published" ) ) print(f"Created product: {product.display_name}")字段语义:subscription_required=True:消费者必须持有订阅密钥才能调用该产品下的 API;approval_required=False:订阅申请无需管理员审批,自动生效;state="published":产品对开发者门户可见且可订阅(unpublished则不可见)。将 API 关联到产品client.product_api.create_or_update( resource_group_name="my-resource-group", service_name="my-apim", product_id="premium", api_id="my-api" )product_api操作组专门维护"产品 ↔ API"的多对多关联,一个产品可挂多个 API,一个 API 也可属于多个产品。创建订阅并获取密钥from azure.mgmt.apimanagement.models import SubscriptionCreateParameters subscription = client.subscription.create_or_update( resource_group_name="my-resource-group", service_name="my-apim", sid="my-subscription", parameters=SubscriptionCreateParameters( display_name="My Subscription", scope=f"/products/premium", state="active" ) ) print(f"Subscription key: {subscription.primary_key}")scope指向订阅的产品路径(/products/premium),也可以指向/apis/<api-id>或/apis/<api-id>/releases/<release-id>实现 API 级订阅;state="active"使订阅立即可用;返回的primary_key(以及成对的secondary_key)就是调用方发起请求时通过Ocp-Apim-Subscription-Key头携带的密钥,请妥善保管,避免写入日志或版本库。创建用户from azure.mgmt.apimanagement.models import UserCreateParameters user = client.user.create_or_update( resource_group_name="my-resource-group", service_name="my-apim", user_id="newuser", parameters=UserCreateParameters( email="user@example.com", first_name="John", last_name="Doe" ) )用户是订阅的主体(也可归属组),示例中仅提供基本身份信息;实际接入时还可以通过client.group_user等操作组把用户加入组以继承组级策略。治理与安全:策略、命名值与后端设置 API 级策略APIM 的策略是 XML 声明式管道,技能文档给出了包含限流与 Header 注入的完整示例:from azure.mgmt.apimanagement.models import PolicyContract policy_xml = """ <policies> <inbound> <rate-limit calls="100" renewal-period="60" /> <set-header name="X-Custom-Header" exists-action="override"> <value>CustomValue</value> </set-header> </inbound> <backend> <forward-request /> </backend> <outbound /> <on-error /> </policies> """ client.api_policy.create_or_update( resource_group_name="my-resource-group", service_name="my-apim", api_id="my-api", policy_id="policy", parameters=PolicyContract( value=policy_xml, format="xml" ) )<rate-limit calls="100" renewal-period="60" />:对每个订阅密钥施加"每 60 秒最多 100 次调用"的限流;<set-header ... exists-action="override">:在请求转发前强制注入或覆盖X-Custom-Header;策略可作用在四个层级——全局、产品、API、操作(文档 Best Practices 第 2 条),api_policy对应 API 级,其余层级分别由policy(全局,client.policy)、product_policy、api_operation_policy等操作组管理。创建命名值(密钥抽象)from azure.mgmt.apimanagement.models import NamedValueCreateContract named_value = client.named_value.begin_create_or_update( resource_group_name="my-resource-group", service_name="my-apim", named_value_id="backend-api-key", parameters=NamedValueCreateContract( display_name="Backend API Key", value="secret-key-value", secret=True ) ).result()secret=True会把该值作为加密密钥存储,策略中通过{{backend-api-key}}语法引用;密钥与配置由此从代码/XML 中剥离,符合文档 Best Practices 第 1 条。创建后端(后端抽象)from azure.mgmt.apimanagement.models import BackendContract backend = client.backend.create_or_update( resource_group_name="my-resource-group", service_name="my-apim", backend_id="my-backend", parameters=BackendContract( url="https://api.backend.example.com", protocol="http", description="My backend service" ) )Backend 将真实上游地址、协议与凭据封装为独立资源,策略中以<set-backend-service backend-id="my-backend" />引用,实现"API 定义与后端拓扑解耦"(对应 Best Practices 第 5 条)。文档中的url指向示例域,实际使用请替换为真实后端。操作组全景:SDK 能力地图技能文档以表格形式给出了 SDK 的主要操作组,这是理解客户端能力边界的核心索引:GroupPurposeapi_management_serviceAPIM instance managementapiAPI operationsapi_operationAPI operation detailsapi_policyAPI-level policiesproductProduct managementproduct_apiProduct-API associationssubscriptionSubscription managementuserUser managementnamed_valueNamed values/secretsbackendBackend servicescertificateCertificatesgatewaySelf-hosted gateways在此基础上可延伸理解:api_operation对应 OpenAPI 导入后解析出的每个端点(可单独配置操作级策略与重写);certificate用于管理网关 TLS 证书;gateway面向自托管(self-hosted)网关的部署管理。日常开发中,绝大多数"创建 API → 打产品 → 发订阅 → 挂策略 → 接后端"的闭环都能仅凭上表完成。最佳实践与使用边界技能文档给出的六条实践Use named valuesfor secrets and configuration —— 密钥与可变配置一律走命名值,避免散落于策略 XML;Apply policies at appropriate scopes(global, product, API, operation) —— 按最小必要范围放置策略,例如全局放安全头、API 级放限流;Use products to bundle APIs and manage access—— 用产品统一管理 API 分组与订阅准入;Enable Application Insights for monitoring—— 在 APIM 诊断设置中对接 Application Insights,获取调用量、延迟、失败率等可观测数据;Use backends to abstract backend services—— 用 Backend 资源屏蔽上游地址变化;Version your APIsusing APIM's versioning features —— 利用 APIM 的版本集(versioning)能力做不破坏兼容的演进。When to Use 与 Limitations技能元数据中description明确该技能"用于管理 APIM 服务、API、产品、订阅与策略",因此:仅当任务清晰落在上述范围内时才应启用本技能;涉及其他云资源(如 AKS、存储、函数)应选择仓库中对应的azure-*-py系列技能;该技能输出不替代环境相关的验证、测试与专家评审——risk: critical意味着begin_create_or_update、create_or_update会对真实云资源产生变更,执行前应确认资源组、命名与 SKU 选择;若缺少必要输入(订阅 ID、资源组、权限边界、成功标准),应停止并请求澄清,而不是盲目执行写操作。小结azure-mgmt-apimanagement-py技能文档覆盖了 APIM 管理中最核心的九类操作:客户端认证、服务创建、双通道 API 导入、产品/订阅/用户组织、策略下发、命名值与后端抽象,并提供了完整的可运行代码与操作组索引。结合 agentic-awesome-skills 的技能组织方式,这套脚本可以直接封装为 Agent 可调用的工作流——无论是 CI 中自动同步 OpenAPI 定义,还是按产品维度批量开通订阅,都能以本文的代码骨架为起点落地。动手前请记住两条铁律:密钥只走命名值,写操作前先核对作用域与权限。赞分享AI 技能AI 插件人工智能【免费下载链接】agentic-awesome-skillsAAS Core is the local, agent-first control plane for complete catalog discovery, agent-owned selection, stack validation, and planning, backed by 2,600+ agentic skills. Includes CLI, local MCP, catalog, plugins, and Workbench.项目地址:https://gitcode.com/GitHub_Trending/an/agentic-awesome-skills点击查看免费下载相关推荐agentic-awesome-skills 实战:用 azure-mgmt-apicenter Python SDK 管理 Azure API Center 的 API 资产与治理agentic awesome skills 实战:用 azure mgmt apicenter Python SDK 管理 Azure API CenterAI 技能AI 插件人工智能Agentic Awesome Skills 实战:用 azure-containerregistry-py 管理 Azure 容器镜像与制品仓库Agentic Awesome Skills 实战:用 azure containerregistry py 管理 Azure 容器镜像与制品仓库 导读 本指南AI 技能AI 插件人工智能agentic-awesome-skills 实战:用 azure-storage-blob-py 技能驾驭 Azure Blob Storage 全生命周期agentic awesome skills 实战:用 azure storage blob py 技能驾驭 Azure Blob Storage 全生命周期AI 技能AI 插件人工智能上一篇:开源项目OpenStack-Ansible指南及问题解决方案下一篇:开源项目解析:Flask 视频流直播平台入门指南创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考