dataverse-sdk-dev

作者: microsoft

为PowerPlatform Dataverse Client Python SDK仓库贡献的开发指南。用于处理SDK开发任务,如添加…

npx skills add https://github.com/microsoft/powerplatform-dataverseclient-python --skill dataverse-sdk-dev

Dataverse SDK Development Guide

Overview

This skill provides guidance for developers working on the PowerPlatform Dataverse Client Python SDK repository itself (not using the SDK).

Best Practices

API Design

  1. Public methods in operation namespaces - New public methods go in the appropriate namespace module under src/PowerPlatform/Dataverse/operations/ (records.py, query.py, tables.py, batch.py). The client.py file exposes these via namespace properties (client.records, client.query, client.tables, client.batch). Public types and constants live in their own modules (e.g., models/metadata.py, models/batch.py, common/constants.py)
  2. Every public method needs README example - Public API methods must have examples in README.md
  3. Reuse existing APIs - Always check if an existing method can be used before making direct Web API calls
  4. Update documentation when adding features - Keep README and SKILL files (both copies) in sync
  5. Consider backwards compatibility - Avoid breaking changes
  6. Internal vs public naming - Modules, files, and functions not meant to be part of the public API must use a _ prefix (e.g., _odata.py, _relationships.py). Files without the prefix (e.g., constants.py, metadata.py) are public and importable by SDK consumers
  7. Async client - The SDK ships a full async client (AsyncDataverseClient) under src/PowerPlatform/Dataverse/aio/. When adding a feature to the sync client, add it to the async client too. The async operation namespaces mirror the sync ones: aio/operations/async_records.py, async_query.py, async_tables.py, async_batch.py, async_files.py. Pure logic (payload builders, URL construction) goes in data/_odata_base.py — inherited by both _ODataClient and _AsyncODataClient — so it only needs to be written once; HTTP-calling code goes in data/_odata.py (sync) or aio/data/_async_odata.py (async). Async tests live in tests/unit/aio/ and async examples in examples/aio/. The aiohttp dependency is an optional extra (pip install "PowerPlatform-Dataverse-Client[async]") — do not move it into the required dependencies list in pyproject.toml.

Dataverse Property Naming Rules

Dataverse uses two different naming conventions for properties. Getting this wrong causes 400 errors that are hard to debug.

Property typeName conventionExampleWhen used
Structural (columns)LogicalName (always lowercase)new_name, new_priority$select, $filter, $orderby, record payload keys
Navigation (relationships / lookups)Navigation Property Name (usually SchemaName, PascalCase, case-sensitive)new_CustomerId, new_AgentId$expand, @odata.bind annotation keys

Navigation property names are case-sensitive and must match the entity's $metadata. Using the logical name instead of the navigation property name results in 400 Bad Request errors.

Critical rule: The OData parser validates @odata.bind property names case-sensitively against declared navigation properties. Lowercasing new_CustomerId@odata.bind to new_customerid@odata.bind causes: ODataException: An undeclared property 'new_customerid' which only has property annotations...

SDK implementation:

  • _lowercase_keys() lowercases all keys EXCEPT those containing @odata. (preserves navigation property casing in @odata.bind keys)
  • _lowercase_list() lowercases $select and $orderby params (structural properties)
  • $expand params are passed as-is (navigation properties, PascalCase)
  • _convert_labels_to_ints() skips @odata. keys entirely (they are annotations, not attributes)

When adding new code that processes record dicts or builds query parameters:

  • Always use _lowercase_keys() for record payloads. Never manually call .lower() on all keys
  • Never lowercase $expand values or @odata.bind key prefixes
  • If iterating record keys, skip keys containing @odata. when doing attribute-level operations

Code Style

  1. No emojis - Do not use emoji in code, comments, or output
  2. Standardize output format - Use [INFO], [WARN], [ERR], [OK] prefixes for console output
  3. No noqa comments - Do not add # noqa: BLE001 or similar linter suppression comments
  4. Document public APIs - Add Sphinx-style docstrings with examples for public methods
  5. Define all in module files - Each module declares its own exports via __all__ (e.g., errors.py defines __all__ = ["HttpError", ...]). Package __init__.py files should not re-export or redefine another module's __all__; they use __all__ = [] to indicate no star-import exports.
  6. Run black before committing - Always run python -m black <changed files> before committing. CI will reject unformatted code. Config is in pyproject.toml under [tool.black].

Docstring Type Annotations (Microsoft Learn Compatibility)

This SDK's API reference is published on Microsoft Learn. The Learn doc pipeline parses :type: and :rtype: directives differently from standard Sphinx -- every word between :class: references is treated as a separate cross-reference (<xref:word>). Using Sphinx-style :class:\list` of :class:`str`produces brokenxref:of` links on Learn.

Rules for :type: and :rtype: directives:

  • Use Python bracket notation for generic types: list[str], dict[str, typing.Any], list[dict]
  • Use or (without :class:) for union types: str or None, dict or list[dict]
  • Use bracket nesting for complex types: collections.abc.Iterable[list[dict]]
  • Use ~ prefix for SDK types to show short name: list[~PowerPlatform.Dataverse.models.record.Record]
  • :class: is fine for single standalone types: :class:\str`, :class:`bool``

Never use :class:\X` of :class:`Y`or:class:`X` mapping :class:`Y` to :class:`Z`-- the wordsof, mapping, tobecome brokenxref:` links.

Correct examples:

:type data: dict or list[dict]
:rtype: list[str]
:rtype: collections.abc.Iterable[list[~PowerPlatform.Dataverse.models.record.Record]]
:type select: list[str] or None
:type columns: dict[str, typing.Any]

Wrong examples (NEVER use):

:type data: :class:`dict` or :class:`list` of :class:`dict`
:rtype: :class:`list` of :class:`str`
:type columns: :class:`dict` mapping :class:`str` to :class:`typing.Any`

来自 microsoft 的更多技能

oss-growth
microsoft
OSS增长黑客角色
agent-framework-azure-ai-py
microsoft
使用Microsoft Agent Framework Python SDK(agent-framework-azure-ai)构建Azure AI Foundry代理。在创建使用AzureAIAgentsProvider的持久化代理、使用托管工具(代码解释器、文件搜索、网络搜索)、集成MCP服务器、管理对话线程或实现流式响应时使用。涵盖函数工具、结构化输出和多工具代理。
development
airunway-aks-setup
microsoft
在AKS上设置AI Runway——从裸集群到运行模型。涵盖集群验证、控制器安装、GPU评估、提供商设置和首次部署。适用场景:“设置AI Runway”、“接入AKS集群”、“安装AI Runway”、“airunway设置”、“将模型部署到AKS”、“在AKS上进行GPU推理”、“在AKS上配置KAITO”、“在AKS上运行LLM”、“在AKS上使用vLLM”、“在AKS上设置模型服务”、“AI Runway控制器”。
devops
appinsights-instrumentation
microsoft
使用Azure Application Insights对Web应用进行插桩的指南。提供遥测模式、SDK设置和配置参考。适用场景:如何对应用进行插桩、App Insights SDK、遥测模式、什么是App Insights、Application Insights指南、插桩示例、APM最佳实践。
devops
applicationinsights-web-ts
microsoft
使用Application Insights JavaScript SDK(@microsoft/applicationinsights-web)为浏览器/Web应用添加检测。用于真实用户监控(RUM)——页面视图、点击、AJAX/fetch依赖项、异常、自定义事件,以及与后端OpenTelemetry追踪关联的浏览器端GenAI代理追踪。涵盖SDK加载器脚本和npm设置、框架扩展(React、React Native、Angular)、点击分析、遥测初始化器,以及从浏览器发出的代理/工具/模型跨度所遵循的OTel GenAI语义约定。
devops
azure-ai-anomalydetector-java
microsoft
使用适用于 Java 的 Azure AI 异常检测器 SDK 构建异常检测应用程序。在实现单变量/多变量异常检测、时间序列分析或 AI 驱动的监控时使用。
development
azure-ai-language-conversations-py
microsoft
使用azure-ai-language-conversations Python SDK实现对话语言理解(CLU)。当使用ConversationAnalysisClient分析对话意图和实体、构建NLP功能或将语言理解集成到应用程序中时使用。
development
azure-ai-ml-py
microsoft
Azure Machine Learning SDK v2 for Python。用于机器学习工作区、作业、模型、数据集、计算资源和管道。 触发词:“azure-ai-ml”、“MLClient”、“工作区”、“模型注册表”、“训练作业”、“数据集”。
development