使用 Azure DevOps 生成安全应用程序

Azure DevOps Services |Azure DevOps Server |Azure DevOps Server 2022 |Azure DevOps Server 2020

构建与 Azure DevOps 集成的安全、可缩放的应用程序和服务,以编程方式访问用户资源和自动化流程。 无论是创建内部自动化工具还是构建商业产品,Azure DevOps 都提供可靠的 API 和新式身份验证选项来支持集成需求。

为什么与 Azure DevOps 集成?

Azure DevOps 集成使你能够:

🔧 自动化工作流

  • 根据客户报告自动创建和跟踪错误
  • 监视工作项 并在自定义仪表板上显示状态
  • 在 Azure DevOps 与外部系统之间同步数据
  • 从 Azure DevOps 数据生成报表和分析

🏗️ 构建商业解决方案

  • 为 Azure DevOps 客户开发市场扩展
  • 创建与 Azure DevOps 集成的 SaaS 产品
  • 生成连接到 Azure DevOps 服务的移动应用
  • 将 Azure DevOps 与企业系统集成

入门:选择路径

🚀 快速入门选项

需求 推荐的方法 最适用于
简单自动化 具有个人访问令牌(PAT)的 REST API 脚本,个人工具
生产应用程序 具有托管标识的 .NET 客户端库 企业应用、Azure 托管服务
交互式应用程序 Microsoft Entra 身份验证 面向用户的应用、桌面工具
自定义 UI 组件 Azure DevOps 扩展 团队自定义和商城产品

🔐 身份验证:安全性首先

选择正确的身份验证方法:

✅ 推荐用于生产:

⚡ 快速开发:

❌ 避免用于生产:

  • 用户名/密码身份验证(已弃用)
  • 源代码中的硬编码凭据
  • 权限范围过宽

开发方法

🔌 REST API 集成

最适合: 直接 HTTP 调用,与平台无关的开发,简单的自动化

**Key benefits:**
- Works with any programming language
- Full control over HTTP requests and responses
- Lightweight integration for simple scenarios
- Easy to debug and test

**Get started:**
- [Learn REST API basics](./how-to/call-rest-api.md)
- [Browse API reference](/rest/api/azure/devops/)
- [Try APIs in the browser](https://docs.microsoft.com/rest/api/azure/devops/)

📚 .NET 客户端库

最适合: C# 应用程序,企业开发,复杂的集成

**Key benefits:**
- Strongly typed APIs with IntelliSense support
- Built-in retry logic and error handling
- Async/await patterns for better performance
- Production-ready authentication options

**Get started:**
- [.NET client library samples](./get-started/client-libraries/samples.md)
- [Authentication guidance](./get-started/authentication/authentication-guidance.md)
- [Client library concepts](./concepts/dotnet-client-libraries.md)

🔔 事件驱动的集成

最适合: 实时响应、基于 Webhook 的自动化、外部系统同步

**Key benefits:**
- Real-time event notifications
- Reduced polling and improved efficiency
- Support for multiple event types
- Easy integration with external services

**Get started:**
- [Service hooks overview](../service-hooks/overview.md)
- [Webhook configuration guide](../service-hooks/services/webhooks.md)
- [Event reference documentation](../service-hooks/events.md)

🧩 平台扩展

最适合: 自定义 UI 组件, 团队特定的功能, 市场产品

**Key benefits:**
- Native integration with Azure DevOps UI
- Access to platform APIs and services
- Distribution through Visual Studio Marketplace
- Rich customization capabilities

**Get started:**
- [Extension development overview](../extend/overview.md)
- [Extension samples and tutorials](../extend/develop/samples-overview.md)
- [Marketplace publishing guide](../extend/publish/overview.md)

体系结构模式

微服务集成:

Azure Function/App Service → Managed Identity → Azure DevOps APIs
- Secure, serverless integration
- Automatic credential management
- Scalable and cost-effective

企业应用程序:

On-premises App → Service Principal → Azure DevOps REST APIs
- Certificate-based authentication
- Centralized credential management
- Audit logging and compliance

面向用户的应用程序:

Web/Mobile App → Microsoft Entra OAuth → Azure DevOps on behalf of user
- User consent flows
- Secure token management
- Granular permission control

安全性和合规性

🛡️ 安全最佳做法

身份验证安全性:

  • ✅ 尽可能使用托管标识
  • ✅ 实现正确的令牌刷新逻辑
  • ✅ 应用最低特权原则
  • ✅ 为所有 API 调用启用审核日志记录
  • ❌ 从不将凭据提交到版本控制系统
  • ❌ 不要使用过度广泛的 PAT 范围

应用程序安全性:

  • 实现正确的错误处理和日志记录
  • 对所有通信使用 HTTPS
  • 验证所有输入数据
  • 正常处理速率限制
  • 在 Azure Key Vault 中存储敏感数据

合规性注意事项:

  • 查看 Azure DevOps 安全概述
  • 了解数据驻留要求
  • 实现适当的访问控制和审核
  • 遵循行业特定的合规性准则

资源和后续步骤

📖 基本文档

核心概念:

API 参考:

代码示例:

🎯 快速操作

立即开始构建:

  1. 设置身份验证 - 选择身份验证方法
  2. 试用 REST API - 进行第一次 API 调用
  3. 运行客户端库示例 - 请参阅工作代码示例
  4. 查看安全做法 - 从一开始就安全地生成

需要帮助?

小窍门

Azure DevOps 集成新手?身份验证指南 开始,了解选项,然后尝试 REST API 快速入门 以成功调用 API。