mirror of
https://github.com/microsoft/terraform-provider-fabric.git
synced 2026-11-04 12:02:31 +00:00
# 📥 Pull Request ## ❓ What are you trying to address Adds support for the Microsoft Fabric **User Data Function** item. - Closes #1132 (`fabric_user_data_function` resource) - Closes #1133 (`fabric_user_data_function` / `fabric_user_data_functions` data sources) ## ✨ Description of new changes - New service package `internal/services/userdatafunction`, built on the generic `fabricitem` **definition** archetype (SDK `fabric/userdatafunction`, v0.21.0). It is registered in `provider.go`. - Single definition format: `Default` (`fabricitem.DefinitionFormatDefault`, `API: ""`). Supported paths: `definition.json`, `function_app.py`, `resources/functions.json`, `privateLibraries/*.whl`. - `definition` is optional (`DefinitionRequired: false`). Creating without a definition is verified live by `TestAcc_UserDataFunctionResource_CRUD`. - Fake server handlers, fixtures and templates for unit tests. - Examples, generated docs and changelog entries for the resource and the data sources. - `tools/scripts/Set-WellKnown.ps1` now creates the well-known `UserDataFunction` item (endpoint `userDataFunctions`, naming suffix `udf`). ### Intentional divergences and known limitations - **Preview:** the item is marked preview (`IsPreview: true`), per guidance from the Eng lead and PM. - **Definition path validator:** uses `mapvalidator.SizeAtLeast(1)` + `KeysAre(PatternsIfAttributeIsOneOf(...))` instead of `SizeAtMost(N)`. `privateLibraries/*.whl` allows any number of files, matching other wildcard-path peers (report, semanticmodel, sqldatabase, variablelibrary, dataagent, ontology, …). - **`ItemDefinitionEmpty` includes the `fabric-user-data-functions` PyPI library.** Without it, later definition updates fail with `FabricUdfLibraryNotFoundInImportList`. - **Service-principal auth:** `IsSPNSupported: false`. The User Data Function API docs do not list SPN as supported. - **Deploy cooldown:** the service rejects a definition publish made within about 2 minutes of the previous one (`DeployCooldownBlock`). `TestAcc_UserDataFunctionDefinitionResource_CRUD` therefore waits 3 minutes in `PreConfig` before its update step. - **Read-back behaviour:** the service rewrites `definition.json` (it fills `functions` from the Python code) and does not return `resources/functions.json` from `getDefinition`. This is handled by the standard definition-hash behaviour, as in peers. - No `properties` attribute: the GET API returns none. ## ☑️ PR Checklist - [x] Link to the issue you are addressing is included above - [x] Ensure the PR description clearly describes the feature you're adding and any known limitations ## ☑️ Resources / Data Sources Checklist - [x] Production quality implementation of the resource or data-source in [./internal/services](./internal/services) - [x] Unit Tests and Acceptance Tests for your contribution in [./internal/services/<service_name>](./internal/services) - [x] Tests should pass and provide >80% coverage of your contribution - [x] Examples for your contribution in [./examples](./examples) - [x] Schema descriptions for your resource or data-source in [./internal/services](./internal/services) - [x] Docs templates in [./templates](./templates) (default templates; none needed) - [x] Updated auto-generated documentation in [./docs](./docs) ### Validation | Command | Result | | --- | --- | | `task docs` | ✅ passed, no stale docs | | `task golangci-lint` | ✅ passed, 0 issues | | `task lint:files` / `lint:tf` / `lint:md` | ✅ passed | | `task testunit -- UserDataFunction ./internal/services/userdatafunction/` | ✅ 5 tests, 100% coverage | | `task testacc -- UserDataFunction ./internal/services/userdatafunction/` | ✅ 4 tests passed (`Resource_CRUD`, `DefinitionResource_CRUD`, `DataSource`, `DataSources`) | | `task build` | ✅ passed | | `git diff --check` | ✅ clean | | `task lint` (full) | ⚠️ fails only at `govulncheck`, on existing Go stdlib / `x/crypto` / `x/mod` advisories that this change did not introduce | Note: the well-known UDF used by the acceptance tests (`testacc_*_udf` in WorkspaceDS) was created through the Fabric REST API, exactly as the updated `Set-WellKnown.ps1` would create it. A full script run needs an interactive Az PowerShell login. --------- Co-authored-by: Sabre Ammar <saammar@microsoft.com> Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>