microsoft-code-reference
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseMicrosoft Code Reference
Microsoft Code Reference
Tools
工具
| Need | Tool | Example |
|---|---|---|
| API method/class lookup | | |
| Working code sample | | |
| Full API reference | | Fetch URL from |
| 需求 | 工具 | 示例 |
|---|---|---|
| API方法/类查询 | | |
| 可用代码示例 | | |
| 完整API参考 | | 从 |
Finding Code Samples
查找代码示例
Use to get official, working examples:
microsoft_code_sample_searchmicrosoft_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_searchmicrosoft_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查询
undefinedundefinedVerify 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 to find working code samples and compare with your implementation. For specific errors, use and :
microsoft_code_sample_searchmicrosoft_docs_searchmicrosoft_docs_fetch| Error Type | Query |
|---|---|
| Method not found | |
| Type not found | |
| Wrong signature | |
| Deprecated warning | |
| Auth failure | |
| 403 Forbidden | |
使用查找可用代码示例,并与你的实现进行对比。对于特定错误,使用和:
microsoft_code_sample_searchmicrosoft_docs_searchmicrosoft_docs_fetch| 错误类型 | 查询语句 |
|---|---|
| 方法未找到 | |
| 类型未找到 | |
| 签名错误 | |
| 已弃用警告 | |
| 认证失败 | |
| 403 禁止访问 | |
When to Verify
验证时机
Always verify when:
- Method name seems "too convenient" (vs actual
UploadFile)Upload - Mixing SDK versions (v11 vs v12
CloudBlobClient)BlobServiceClient - Package name doesn't follow conventions (for .NET,
Azure.*for Python)azure-* - Using an API for the first time
在以下场景中务必进行验证:
- 方法名称看起来“过于便捷”(如与实际的
UploadFile)Upload - 混合使用不同版本的SDK(如v11的与v12的
CloudBlobClient)BlobServiceClient - 包名称不符合规范(.NET使用,Python使用
Azure.*)azure-* - 首次使用某一API
Validation Workflow
验证工作流
Before generating code using Microsoft SDKs, verify it's correct:
- Confirm method or package exists —
microsoft_docs_search(query: "[ClassName] [MethodName] [Namespace]") - Fetch full details (for overloads/complex params) —
microsoft_docs_fetch(url: "...") - 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生成代码前,验证其正确性:
- 确认方法或包存在 ——
microsoft_docs_search(query: "[ClassName] [MethodName] [Namespace]") - 获取完整详情(针对重载方法/复杂参数) ——
microsoft_docs_fetch(url: "...") - 查找可用示例 ——
microsoft_code_sample_search(query: "[task]", language: "[lang]")
对于简单查询,仅步骤1即可满足需求。对于复杂API的使用,需完成全部三个步骤。