Dataverse Python use case builder
Transform a Dataverse business need into a production-ready Python architecture with table design, pattern selection, SDK code, performance guidance, error handling, monitoring, and tests.
When to invoke
- "Build a Python Dataverse solution for this use case."
- "Design tables and code for a Dataverse document workflow."
- "Generate PowerPlatform-Dataverse-Client SDK code for bulk sync."
- "Create a Dataverse scheduled job in Python."
- "Recommend Dataverse architecture for this business process."
Prerequisites and context
- Target Python 3.10+ and PEP 8 style.
- Use
PowerPlatform.Dataverse.client.DataverseClient, PowerPlatform.Dataverse.core.config.DataverseConfig, and azure.identity.ClientSecretCredential when authentication is needed.
- Use Dataverse table logical names, relationship names, choice values, and file columns supplied by the user or discovered from metadata. Do not invent production schema names without labeling them as proposed.
Procedure
- Analyze requirements: operations, data volume, frequency, performance, error tolerance, and audit needs.
- Design the data model: tables, columns, relationships, lookups, files, and option sets.
- Select the implementation pattern from the pattern table.
- Generate complete Python code with configuration, service class, operations, error handling, logging, and usage examples.
- Add optimization recommendations for the expected volume and latency.
- Document monitoring, metrics, test strategy, and recovery behavior.
Requirement analysis questions
| Area |
Ask or infer |
| Operations |
Create, Read, Update, Delete, Bulk, Query, file upload, or delete. |
| Volume |
Record count, file sizes, page sizes, and batch sizes. |
| Frequency |
One-time, batch, real-time, scheduled, daily, weekly, monthly. |
| Performance |
Response time, throughput, timeout tolerance. |
| Error tolerance |
Retry strategy, idempotency, partial success handling, resume behavior. |
| Audit |
Logging, history, compliance, privacy, user activity tracking. |
Data model design
Use proposed schema blocks like this when the real schema is not provided:
tables = {
"account": {
"custom_fields": ["new_documentcount", "new_lastdocumentdate"]
},
"new_document": {
"primary_key": "new_documentid",
"columns": {
"new_name": "string",
"new_documenttype": "enum",
"new_parentaccount": "lookup(account)",
"new_uploadedby": "lookup(user)",
"new_uploadeddate": "datetime",
"new_documentfile": "file"
}
}
}
Pattern selection
| Pattern |
Use when |
Examples |
| Transactional CRUD Operations |
Single record creation/update, immediate consistency, relationships, lookups. |
Order management, invoice creation. |
| Batch Processing |
Bulk create/update/delete, performance priority, partial failure acceptable. |
Data migration, daily sync. |
| Query & Analytics |
Complex filtering, aggregation, pagination, optimized reads. |
Reporting, dashboards. |
| File Management |
Document upload/storage, chunked transfers, audit trail. |
Contract management, media library. |
| Scheduled Jobs |
Recurring operations, external synchronization, resumable cleanup. |
Nightly syncs, cleanup tasks. |
| Real-time Integration |
Event-driven low-latency processing with status tracking. |
Order processing, approval workflows. |
Implementation skeleton
import logging
from enum import IntEnum
from typing import Optional, List, Dict, Any
from datetime import datetime
from pathlib import Path
from PowerPlatform.Dataverse.client import DataverseClient
from PowerPlatform.Dataverse.core.config import DataverseConfig
from PowerPlatform.Dataverse.core.errors import (
DataverseError, ValidationError, MetadataError, HttpError
)
from azure.identity import ClientSecretCredential
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
class Status(IntEnum):
DRAFT = 1
ACTIVE = 2
ARCHIVED = 3
class DataverseService:
_instance = None
def __new__(cls):
if cls._instance is None:
cls._instance = super().__new__(cls)
cls._instance._initialize()
return cls._instance
def _initialize(self):
config = DataverseConfig()
credential = ClientSecretCredential(
tenant_id=config.tenant_id,
client_id=config.client_id,
client_secret=config.client_secret,
)
self.client = DataverseClient(config=config, credential=credential)
Include CRUD, bulk, query, file, or scheduled methods after this skeleton based on the selected pattern.
Optimization rules
| Scenario |
Pattern |
| High-volume create/update |
Use batch operations: client.create("table", [record1, record2, record3]); avoid one network call per row. |
| Bulk load |
Chunk input and track successful IDs: client.create("table", [record] * 1000). |
| Complex query |
Use filter, select, orderby, and top=500; process pages instead of materializing all results. |
| Large file transfer |
Use chunked upload with chunk_size=4 * 1024 * 1024 for 4 MB chunks. |
| Recovery |
Store checkpoints, retry transient HttpError, and treat validation failures as data-quality records. |
for page in client.get(
"table",
filter="status eq 1",
select=["id", "name", "amount"],
orderby="name",
top=500
):
pass
client.upload_file(
table_name="table",
record_id=id,
file_column_name="new_file",
file_path=path,
chunk_size=4 * 1024 * 1024
)
Use case categories
| Category |
Typical cases |
| Customer Relationship Management |
Lead management, account hierarchy, contact tracking, opportunity pipeline, activity history. |
| Document Management |
Storage and retrieval, version control, access control, audit trails, compliance tracking. |
| Data Integration |
ETL, data synchronization, external system integration, migration, backup/restore. |
| Business Process |
Order management, approval workflows, project tracking, inventory, resource allocation. |
| Reporting & Analytics |
Aggregation, historical analysis, KPI tracking, dashboard data, export functionality. |
| Compliance & Audit |
Change tracking, user activity logging, governance, retention policies, privacy management. |
Dataverse implementation labels
Use these labels when structuring generated code and architecture notes: Backup/restore, CLASS, CONFIGURATION, CONSTANTS, ENUMS, ERROR, EXAMPLE, HANDLING, OPERATIONS, PATTERN, RECOVERY, SERVICE, SETUP, SINGLETON, SPECIFIC, USAGE, Upload/store, and relationships/lookups.
Output template
## Dataverse Python solution - <use case>
**Status:** complete | needs details | blocked
**Pattern:** Transactional CRUD Operations | Batch Processing | Query & Analytics | File Management | Scheduled Jobs | Real-time Integration
### Architecture overview
<2-3 sentence design summary>
### Data model
| Table | Relationship | Key columns | Notes |
| --- | --- | --- | --- |
| `<logical name>` | `<relationship>` | `<columns>` | `<constraints>` |
### Implementation code
```python
<complete Python 3.10+ code>
Usage instructions
Performance notes
- <throughput, batch, paging, or chunking guidance>
Error handling
| Failure |
Recovery |
<failure> |
<retry, skip, compensate, or alert> |
Monitoring
Testing
## Quality gate
- [ ] The solution states operations, volume, frequency, performance, error tolerance, and audit assumptions.
- [ ] Proposed table and column names are labeled when not user-provided.
- [ ] Code includes all imports, type hints, logging, and Dataverse error handling.
- [ ] The selected pattern matches the use case category and volume.
- [ ] Bulk, paging, or chunking is used for high-volume records or files.
- [ ] Usage, monitoring, and testing guidance are included.
1---2name: dataverse-python-usecase-builder3description: Generate complete Python solutions for Microsoft Dataverse SDK business use cases, including architecture, table design, CRUD, batch, query, file, scheduled, or real-time patterns. Use this skill when the user describes a Dataverse business need and asks for production-ready Python code, PowerPlatform-Dataverse-Client guidance, or Dataverse solution architecture.4---56<!-- Generated from harness/github-copilot/skills/dataverse-python-usecase-builder/SKILL.md by harness/claude-code/scripts/convert_from_copilot.py. Edit the source, not this file. -->78# Dataverse Python use case builder910Transform a Dataverse business need into a production-ready Python architecture with table design, pattern selection, SDK code, performance guidance, error handling, monitoring, and tests.1112## When to invoke1314- "Build a Python Dataverse solution for this use case."15- "Design tables and code for a Dataverse document workflow."16- "Generate PowerPlatform-Dataverse-Client SDK code for bulk sync."17- "Create a Dataverse scheduled job in Python."18- "Recommend Dataverse architecture for this business process."1920## Prerequisites and context2122- Target Python 3.10+ and PEP 8 style.23- Use `PowerPlatform.Dataverse.client.DataverseClient`, `PowerPlatform.Dataverse.core.config.DataverseConfig`, and `azure.identity.ClientSecretCredential` when authentication is needed.24- Use Dataverse table logical names, relationship names, choice values, and file columns supplied by the user or discovered from metadata. Do not invent production schema names without labeling them as proposed.2526## Procedure27281. Analyze requirements: operations, data volume, frequency, performance, error tolerance, and audit needs.292. Design the data model: tables, columns, relationships, lookups, files, and option sets.303. Select the implementation pattern from the pattern table.314. Generate complete Python code with configuration, service class, operations, error handling, logging, and usage examples.325. Add optimization recommendations for the expected volume and latency.336. Document monitoring, metrics, test strategy, and recovery behavior.3435## Requirement analysis questions3637| Area | Ask or infer |38| --- | --- |39| Operations | Create, Read, Update, Delete, Bulk, Query, file upload, or delete. |40| Volume | Record count, file sizes, page sizes, and batch sizes. |41| Frequency | One-time, batch, real-time, scheduled, daily, weekly, monthly. |42| Performance | Response time, throughput, timeout tolerance. |43| Error tolerance | Retry strategy, idempotency, partial success handling, resume behavior. |44| Audit | Logging, history, compliance, privacy, user activity tracking. |4546## Data model design4748Use proposed schema blocks like this when the real schema is not provided:4950```python51tables = {52 "account": {53 "custom_fields": ["new_documentcount", "new_lastdocumentdate"]54 },55 "new_document": {56 "primary_key": "new_documentid",57 "columns": {58 "new_name": "string",59 "new_documenttype": "enum",60 "new_parentaccount": "lookup(account)",61 "new_uploadedby": "lookup(user)",62 "new_uploadeddate": "datetime",63 "new_documentfile": "file"64 }65 }66}67```6869## Pattern selection7071| Pattern | Use when | Examples |72| --- | --- | --- |73| Transactional CRUD Operations | Single record creation/update, immediate consistency, relationships, lookups. | Order management, invoice creation. |74| Batch Processing | Bulk create/update/delete, performance priority, partial failure acceptable. | Data migration, daily sync. |75| Query & Analytics | Complex filtering, aggregation, pagination, optimized reads. | Reporting, dashboards. |76| File Management | Document upload/storage, chunked transfers, audit trail. | Contract management, media library. |77| Scheduled Jobs | Recurring operations, external synchronization, resumable cleanup. | Nightly syncs, cleanup tasks. |78| Real-time Integration | Event-driven low-latency processing with status tracking. | Order processing, approval workflows. |7980## Implementation skeleton8182```python83import logging84from enum import IntEnum85from typing import Optional, List, Dict, Any86from datetime import datetime87from pathlib import Path88from PowerPlatform.Dataverse.client import DataverseClient89from PowerPlatform.Dataverse.core.config import DataverseConfig90from PowerPlatform.Dataverse.core.errors import (91 DataverseError, ValidationError, MetadataError, HttpError92)93from azure.identity import ClientSecretCredential9495logging.basicConfig(level=logging.INFO)96logger = logging.getLogger(__name__)9798class Status(IntEnum):99 DRAFT = 1100 ACTIVE = 2101 ARCHIVED = 3102103class DataverseService:104 _instance = None105106 def __new__(cls):107 if cls._instance is None:108 cls._instance = super().__new__(cls)109 cls._instance._initialize()110 return cls._instance111112 def _initialize(self):113 config = DataverseConfig()114 credential = ClientSecretCredential(115 tenant_id=config.tenant_id,116 client_id=config.client_id,117 client_secret=config.client_secret,118 )119 self.client = DataverseClient(config=config, credential=credential)120```121122Include CRUD, bulk, query, file, or scheduled methods after this skeleton based on the selected pattern.123124## Optimization rules125126| Scenario | Pattern |127| --- | --- |128| High-volume create/update | Use batch operations: `client.create("table", [record1, record2, record3])`; avoid one network call per row. |129| Bulk load | Chunk input and track successful IDs: `client.create("table", [record] * 1000)`. |130| Complex query | Use `filter`, `select`, `orderby`, and `top=500`; process pages instead of materializing all results. |131| Large file transfer | Use chunked upload with `chunk_size=4 * 1024 * 1024` for 4 MB chunks. |132| Recovery | Store checkpoints, retry transient `HttpError`, and treat validation failures as data-quality records. |133134```python135for page in client.get(136 "table",137 filter="status eq 1",138 select=["id", "name", "amount"],139 orderby="name",140 top=500141):142 pass143144client.upload_file(145 table_name="table",146 record_id=id,147 file_column_name="new_file",148 file_path=path,149 chunk_size=4 * 1024 * 1024150)151```152153## Use case categories154155| Category | Typical cases |156| --- | --- |157| Customer Relationship Management | Lead management, account hierarchy, contact tracking, opportunity pipeline, activity history. |158| Document Management | Storage and retrieval, version control, access control, audit trails, compliance tracking. |159| Data Integration | ETL, data synchronization, external system integration, migration, backup/restore. |160| Business Process | Order management, approval workflows, project tracking, inventory, resource allocation. |161| Reporting & Analytics | Aggregation, historical analysis, KPI tracking, dashboard data, export functionality. |162| Compliance & Audit | Change tracking, user activity logging, governance, retention policies, privacy management. |163164## Dataverse implementation labels165166Use these labels when structuring generated code and architecture notes: `Backup/restore`, `CLASS`, `CONFIGURATION`, `CONSTANTS`, `ENUMS`, `ERROR`, `EXAMPLE`, `HANDLING`, `OPERATIONS`, `PATTERN`, `RECOVERY`, `SERVICE`, `SETUP`, `SINGLETON`, `SPECIFIC`, `USAGE`, `Upload/store`, and `relationships/lookups`.167168## Output template169170```markdown171## Dataverse Python solution - <use case>172173**Status:** complete | needs details | blocked174**Pattern:** Transactional CRUD Operations | Batch Processing | Query & Analytics | File Management | Scheduled Jobs | Real-time Integration175176### Architecture overview177<2-3 sentence design summary>178179### Data model180| Table | Relationship | Key columns | Notes |181| --- | --- | --- | --- |182| `<logical name>` | `<relationship>` | `<columns>` | `<constraints>` |183184### Implementation code185```python186<complete Python 3.10+ code>187```188189### Usage instructions1901. <configuration step>1912. <run command or entry point>192193### Performance notes194- <throughput, batch, paging, or chunking guidance>195196### Error handling197| Failure | Recovery |198| --- | --- |199| `<failure>` | `<retry, skip, compensate, or alert>` |200201### Monitoring202- <metric to track>203204### Testing205- <unit or integration test pattern>206```207208## Quality gate209210- [ ] The solution states operations, volume, frequency, performance, error tolerance, and audit assumptions.211- [ ] Proposed table and column names are labeled when not user-provided.212- [ ] Code includes all imports, type hints, logging, and Dataverse error handling.213- [ ] The selected pattern matches the use case category and volume.214- [ ] Bulk, paging, or chunking is used for high-volume records or files.215- [ ] Usage, monitoring, and testing guidance are included.