Skip to content

Add Microsoft Dataverse (commondataservice) trigger + action sample#8

Open
manvkaur wants to merge 4 commits into
mainfrom
manvkaur-add-dataverse-connector-sample
Open

Add Microsoft Dataverse (commondataservice) trigger + action sample#8
manvkaur wants to merge 4 commits into
mainfrom
manvkaur-add-dataverse-connector-sample

Conversation

@manvkaur

@manvkaur manvkaur commented Jul 16, 2026

Copy link
Copy Markdown

Summary

Adds a new self-contained dataverseApp/ sample demonstrating the Microsoft Dataverse (commondataservice) connector on Azure Functions (Flex Consumption, Python 3.13) via azd + Bicep + Connector Namespace.

Function Type Connector operation
OnDataverseRowChanged Trigger GetOnNewItems_V2 — fires when a new row is added
ListDataverseRows Action (HTTP) GetItems_V2 — List rows, called on demand

Highlights

  • Configurable environment (friendly name auto-resolved to org URL, or explicit URL) and table via azd env set — no code edits.
  • Auth (no DefaultAzureCredential, no client id): system-assigned managed identity in Azure (ManagedIdentityCredential), az login user identity locally (AzureCliCredential), selected via IDENTITY_ENDPOINT. README documents why IDENTITY_ENDPOINT (with the Microsoft Learn reference), its host-scope caveat, and production guidance to use a single credential.
  • Infra: Connector Namespace, OAuth connection, and access policies. The function-app MI access policy lives in a separate functionAccessPolicy.bicep module (applied after the app) to break the connection↔app dependency cycle.
  • Post-deploy scripts (.ps1 + .sh): interactive OAuth consent, trigger-config creation against the function's connector webhook, resolve the org URL via Global Discovery and persist it as DATAVERSE_ENVIRONMENT_URL, and read the app's real defaultHostName (no hardcoded .azurewebsites.net, so custom domains / sovereign clouds work).
  • Root README.md updated to list the new sample (count Seven → Eight).

Documented notes

  • Connector choice: deliberately targets legacy commondataservice; its successor commondataserviceforapps is Power Automate–only and not yet available for Logic Apps / Connector Namespaces.
  • Known issue: SubscribeWebhookTrigger ("When a row is added, modified or deleted") returns HTTP 500 (Regex.Match null-ref) via Connector Namespace; the connector namespace team is working on support. This sample uses the GetOnNewItems_V2 new-row trigger meanwhile.

Verification

Provisioned to a live test subscription; ListDataverseRows returned HTTP 200 with account rows via the function's MSI + functionapp-msi access policy.

Notes for reviewers

  • local.settings.json is committed with placeholder values only (no secrets), matching the ask to include it.
  • .func/config.json for Functions CLI v5.

Marked as draft pending review.

New self-contained dataverseApp/ sample: OnDataverseRowChanged trigger (GetOnNewItems_V2) plus ListDataverseRows HTTP action calling the connector's List rows operation. Auth uses system-assigned MI in Azure (ManagedIdentityCredential, no client id) and az login identity locally (AzureCliCredential), selected via IDENTITY_ENDPOINT. Includes azd/Bicep infra with Connector Namespace, connection, and access policies, post-deploy consent + trigger-config scripts, and README documenting the connector choice, known SubscribeWebhookTrigger 500, and identity guidance.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 87bf03da-21a5-421b-b57a-fe347876f141
@manvkaur
manvkaur marked this pull request as ready for review July 16, 2026 04:27
…es in README

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 87bf03da-21a5-421b-b57a-fe347876f141
Comment thread dataverseApp/function_app.py Outdated
Comment thread dataverseApp/function_app.py Outdated
)

# Table and row count are overridable per request; fall back to app settings.
table = req.params.get("table") or os.environ.get(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same nit here for runtime_url, dataset, and table - any constants can be moved to global variables.

Comment thread dataverseApp/README.md Outdated
Comment thread dataverseApp/requirements.txt Outdated
hallvictoria
hallvictoria previously approved these changes Jul 16, 2026
Replace the hand-crafted urllib call to the GetItems_V2 dataset path with the
typed CommondataserviceClient.list_records_async from azure-connectors 0.3.0b2.
The action is now async and passes explicit per-environment async credentials
(ManagedIdentityCredential in Azure, AzureCliCredential locally) via
AzureIdentityTokenProvider, so no DefaultAzureCredential or client id is used.
The connection runtime URL identifies the environment, so the action no longer
needs the org URL/dataset. Updates requirements.txt and README accordingly.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 87bf03da-21a5-421b-b57a-fe347876f141
- Hoist startup constants (environment, table, runtime URL, IN_AZURE) to
  module globals; keep per-request table/top overrides on the action.
- README: Python 3.13+, drop azure-functions beta pin (stable ships the
  connector decorator), condense the action/IDENTITY_ENDPOINT and top notes,
  and correct the portal-visibility caveat (runs are viewable once created via
  ARM/CLI; create/update still CLI-only).
- Simplify inline comments and wrap all lines to satisfy flake8 (E501).

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 87bf03da-21a5-421b-b57a-fe347876f141
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants