microsoft-code-reference

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Microsoft Code Reference

Microsoft Code Reference

Tools

工具

NeedToolExample
API method/class lookup
microsoft_docs_search
"BlobClient UploadAsync Azure.Storage.Blobs"
Working code sample
microsoft_code_sample_search
query: "upload blob managed identity", language: "python"
Full API reference
microsoft_docs_fetch
Fetch URL from
microsoft_docs_search
(for overloads, full signatures)
需求工具示例
API方法/类查询
microsoft_docs_search
"BlobClient UploadAsync Azure.Storage.Blobs"
可用代码示例
microsoft_code_sample_search
query: "upload blob managed identity", language: "python"
完整API参考
microsoft_docs_fetch
microsoft_docs_search
获取URL(用于查看重载方法、完整签名)

Finding Code Samples

查找代码示例

Use
microsoft_code_sample_search
to get official, working examples:
microsoft_code_sample_search(query: "upload file to blob storage", language: "csharp")
microsoft_code_sample_search(query: "authenticate with managed identity", language: "python")
microsoft_code_sample_search(query: "send message service bus", language: "javascript")
When to use:
  • Before writing code—find a working pattern to follow
  • After errors—compare your code against a known-good sample
  • Unsure of initialization/setup—samples show complete context
使用
microsoft_code_sample_search
获取官方可用示例:
microsoft_code_sample_search(query: "upload file to blob storage", language: "csharp")
microsoft_code_sample_search(query: "authenticate with managed identity", language: "python")
microsoft_code_sample_search(query: "send message service bus", language: "javascript")
使用场景:
  • 编写代码前——找到可遵循的可用模式
  • 出现错误后——将你的代码与已知正确的示例进行对比
  • 不确定初始化/设置方式——示例展示完整上下文

API Lookups

API查询

undefined
undefined

Verify method exists (include namespace for precision)

验证方法是否存在(包含命名空间以提高精准度)

"BlobClient UploadAsync Azure.Storage.Blobs" "GraphServiceClient Users Microsoft.Graph"
"BlobClient UploadAsync Azure.Storage.Blobs" "GraphServiceClient Users Microsoft.Graph"

Find class/interface

查找类/接口

"DefaultAzureCredential class Azure.Identity"
"DefaultAzureCredential class Azure.Identity"

Find correct package

查找正确的包

"Azure Blob Storage NuGet package" "azure-storage-blob pip package"

Fetch full page when method has multiple overloads or you need complete parameter details.
"Azure Blob Storage NuGet package" "azure-storage-blob pip package"

当方法有多个重载或你需要完整的参数详情时,获取完整页面内容。

Error Troubleshooting

错误排查

Use
microsoft_code_sample_search
to find working code samples and compare with your implementation. For specific errors, use
microsoft_docs_search
and
microsoft_docs_fetch
:
Error TypeQuery
Method not found
"[ClassName] methods [Namespace]"
Type not found
"[TypeName] NuGet package namespace"
Wrong signature
"[ClassName] [MethodName] overloads"
→ fetch full page
Deprecated warning
"[OldType] migration v12"
Auth failure
"DefaultAzureCredential troubleshooting"
403 Forbidden
"[ServiceName] RBAC permissions"
使用
microsoft_code_sample_search
查找可用代码示例,并与你的实现进行对比。对于特定错误,使用
microsoft_docs_search
microsoft_docs_fetch
错误类型查询语句
方法未找到
"[ClassName] methods [Namespace]"
类型未找到
"[TypeName] NuGet package namespace"
签名错误
"[ClassName] [MethodName] overloads"
→ 获取完整页面
已弃用警告
"[OldType] migration v12"
认证失败
"DefaultAzureCredential troubleshooting"
403 禁止访问
"[ServiceName] RBAC permissions"

When to Verify

验证时机

Always verify when:
  • Method name seems "too convenient" (
    UploadFile
    vs actual
    Upload
    )
  • Mixing SDK versions (v11
    CloudBlobClient
    vs v12
    BlobServiceClient
    )
  • Package name doesn't follow conventions (
    Azure.*
    for .NET,
    azure-*
    for Python)
  • Using an API for the first time
在以下场景中务必进行验证:
  • 方法名称看起来“过于便捷”(如
    UploadFile
    与实际的
    Upload
  • 混合使用不同版本的SDK(如v11的
    CloudBlobClient
    与v12的
    BlobServiceClient
  • 包名称不符合规范(.NET使用
    Azure.*
    ,Python使用
    azure-*
  • 首次使用某一API

Validation Workflow

验证工作流

Before generating code using Microsoft SDKs, verify it's correct:
  1. Confirm method or package exists
    microsoft_docs_search(query: "[ClassName] [MethodName] [Namespace]")
  2. Fetch full details (for overloads/complex params) —
    microsoft_docs_fetch(url: "...")
  3. Find working sample
    microsoft_code_sample_search(query: "[task]", language: "[lang]")
For simple lookups, step 1 alone may suffice. For complex API usage, complete all three steps.
在使用Microsoft SDK生成代码前,验证其正确性:
  1. 确认方法或包存在 ——
    microsoft_docs_search(query: "[ClassName] [MethodName] [Namespace]")
  2. 获取完整详情(针对重载方法/复杂参数) ——
    microsoft_docs_fetch(url: "...")
  3. 查找可用示例 ——
    microsoft_code_sample_search(query: "[task]", language: "[lang]")
对于简单查询,仅步骤1即可满足需求。对于复杂API的使用,需完成全部三个步骤。