Skip to content

Commit faaced3

Browse files
Merge pull request #133 from Harmanpreet-Microsoft/fabric-byo-enhancements
chore: Enhance deployment guides and improve OneLake data source creation
2 parents d2232a2 + fe1b0dc commit faaced3

5 files changed

Lines changed: 130 additions & 6 deletions

File tree

docs/deploymentguide.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,42 @@ Edit `infra/main.bicepparam` or set environment variables:
191191
# var fabricWorkspacePreset = 'none'
192192
```
193193

194+
#### Reusing an Existing Fabric Capacity and Workspace (BYO mode)
195+
196+
If you already have a Fabric capacity and workspace, set `byo` mode so the deployment skips creating new ones. The bicepparam variables are driven by environment variables, so the recommended approach is to set them with `azd env set` before running `azd up`:
197+
198+
**Step 1 — Set the mode in `infra/main.bicepparam`** (or leave the default `byo` unchanged):
199+
200+
```bicep
201+
// infra/main.bicepparam
202+
var fabricCapacityPreset = readEnvironmentVariable('fabricCapacityMode', 'byo')
203+
```
204+
205+
The `fabricCapacityMode` env variable controls both capacity and workspace preset (they are tied together). Set it explicitly if the checked-in default has been changed:
206+
207+
```powershell
208+
azd env set fabricCapacityMode byo
209+
```
210+
211+
**Step 2 — Supply the existing resource identifiers:**
212+
213+
```powershell
214+
# ARM resource ID of the existing Fabric capacity
215+
azd env set fabricCapacityResourceId "/subscriptions/<sub-id>/resourceGroups/<rg>/providers/Microsoft.Fabric/capacities/<capacity-name>"
216+
217+
# GUID of the existing Fabric workspace (from the workspace URL or Fabric portal)
218+
azd env set FABRIC_WORKSPACE_ID "<workspace-guid>"
219+
220+
# Display name of the existing workspace (used for naming/UX; optional but recommended)
221+
azd env set FABRIC_WORKSPACE_NAME "<workspace-display-name>"
222+
```
223+
224+
> **How to find the workspace GUID:** Open the workspace in [app.fabric.microsoft.com](https://app.fabric.microsoft.com), copy the URL. The segment after `/groups/` is the workspace GUID (e.g., `https://app.fabric.microsoft.com/groups/e9c7ed61-0cdc-4356-a239-9d49cc755fe0/...``e9c7ed61-0cdc-4356-a239-9d49cc755fe0`).
225+
226+
> **How to find the capacity resource ID:** In Azure Portal, open the Fabric capacity resource → **Properties** → copy **Resource ID**. It follows the pattern `/subscriptions/.../providers/Microsoft.Fabric/capacities/<name>`.
227+
228+
After setting these variables, run `azd up` normally. The deployment will attach to your existing capacity and workspace instead of creating new ones.
229+
194230
</details>
195231

196232
<details>

docs/parameter_guide.md

Lines changed: 71 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,80 @@ This guide focuses on configuration concepts for the **AI Landing Zone**.
88
> - AI Landing Zone submodule parameters file (if you deploy it directly): `submodules/ai-landing-zone/main.parameters.json`
99
>
1010
> **Fabric options in this repo** are configured in `infra/main.bicepparam` via:
11-
> - `fabricCapacityPreset` (`create` | `byo` | `none`)
12-
> - `fabricWorkspacePreset` (`create` | `byo` | `none`)
13-
> - BYO inputs: `fabricCapacityResourceId`, `fabricWorkspaceId`, `fabricWorkspaceName`
11+
> - `fabricCapacityPreset` (`create` | `byo` | `none`) — driven by the `fabricCapacityMode` env variable
12+
> - `fabricWorkspacePreset` (`create` | `byo` | `none`) — mirrors `fabricCapacityPreset` by default
13+
> - BYO inputs: `fabricCapacityResourceId` (env), `FABRIC_WORKSPACE_ID` (env), `FABRIC_WORKSPACE_NAME` (env)
1414
1515
> **Deployment flow**: This repo deploys the AI Landing Zone submodule from `submodules/ai-landing-zone/main.bicep` during the preprovision hook. The single source of truth for parameters is `infra/main.bicepparam`.
1616
17+
## Fabric Configuration
18+
19+
### Modes: create, byo, none
20+
21+
| Mode | Description |
22+
|------|-------------|
23+
| `create` | Provisions a new Fabric capacity (Bicep) and workspace (postprovision script) |
24+
| `byo` | Reuses an existing Fabric capacity and workspace — no new resources created |
25+
| `none` | Disables all Fabric automation; OneLake indexing will be skipped |
26+
27+
Both capacity and workspace modes are controlled by the same `fabricCapacityMode` environment variable (they are tied together in `infra/main.bicepparam`).
28+
29+
### Setting Mode via azd env
30+
31+
The recommended way to configure Fabric mode is with `azd env set` — these values are read directly by `infra/main.bicepparam` at provision time:
32+
33+
```powershell
34+
# Choose one:
35+
azd env set fabricCapacityMode create # create new capacity + workspace
36+
azd env set fabricCapacityMode byo # reuse existing capacity + workspace (default)
37+
azd env set fabricCapacityMode none # disable all Fabric automation
38+
```
39+
40+
### Reusing Existing Fabric Resources (BYO)
41+
42+
When `fabricCapacityMode` is `byo`, supply the identifiers of your existing resources:
43+
44+
```powershell
45+
# ARM resource ID of the existing Fabric capacity
46+
azd env set fabricCapacityResourceId "/subscriptions/<sub-id>/resourceGroups/<rg>/providers/Microsoft.Fabric/capacities/<capacity-name>"
47+
48+
# GUID of the existing Fabric workspace (from the workspace URL)
49+
azd env set FABRIC_WORKSPACE_ID "<workspace-guid>"
50+
51+
# Display name of the existing workspace (optional, used for naming/UX)
52+
azd env set FABRIC_WORKSPACE_NAME "<workspace-display-name>"
53+
```
54+
55+
> **How to find the workspace GUID:** Open the workspace in [app.fabric.microsoft.com](https://app.fabric.microsoft.com). The URL segment after `/groups/` is the GUID (e.g., `https://app.fabric.microsoft.com/groups/e9c7ed61-0cdc-4356-a239-9d49cc755fe0/...`).
56+
>
57+
> **How to find the capacity resource ID:** Azure Portal → Fabric capacity resource → **Properties****Resource ID**.
58+
59+
You can also set these directly in `infra/main.bicepparam` if you prefer source-controlled values:
60+
61+
```bicep
62+
// infra/main.bicepparam
63+
var fabricCapacityPreset = 'byo'
64+
param fabricCapacityResourceId = '/subscriptions/<sub-id>/resourceGroups/<rg>/providers/Microsoft.Fabric/capacities/<name>'
65+
param fabricWorkspaceId = '<workspace-guid>'
66+
param fabricWorkspaceName = '<workspace-display-name>'
67+
```
68+
69+
> **Note:** Values set via `azd env set` take precedence over hardcoded bicepparam values because `readEnvironmentVariable(...)` is evaluated at deploy time.
70+
71+
### Creating New Fabric Resources
72+
73+
When `fabricCapacityMode` is `create`, you must provide at least one admin principal:
74+
75+
```bicep
76+
// infra/main.bicepparam
77+
param fabricCapacityAdmins = ['user@contoso.com']
78+
param fabricCapacitySku = 'F2' // adjust SKU as needed
79+
```
80+
81+
> **Permission requirement:** The identity running `azd` must have the **Fabric Administrator** role (or Power BI tenant admin) to call the workspace admin APIs used during postprovision.
82+
83+
---
84+
1785
## Table of Contents
1886
1. [Basic Parameters](#basic-parameters)
1987
2. [Deployment Toggles](#deployment-toggles)

infra/main.bicepparam

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -236,11 +236,11 @@ var fabricWorkspacePreset = fabricCapacityPreset
236236
param deployFabricCapacity = fabricCapacityPreset != 'none'
237237

238238
param fabricCapacityMode = fabricCapacityPreset
239-
param fabricCapacityResourceId = '' // required when fabricCapacityPreset='byo'
239+
param fabricCapacityResourceId = readEnvironmentVariable('fabricCapacityResourceId', '') // required when fabricCapacityPreset='byo'
240240

241241
param fabricWorkspaceMode = fabricWorkspacePreset
242-
param fabricWorkspaceId = '' // required when fabricWorkspacePreset='byo'
243-
param fabricWorkspaceName = '' // optional (helpful for naming/UX)
242+
param fabricWorkspaceId = readEnvironmentVariable('FABRIC_WORKSPACE_ID', readEnvironmentVariable('fabricWorkspaceId', '')) // required when fabricWorkspacePreset='byo'
243+
param fabricWorkspaceName = readEnvironmentVariable('FABRIC_WORKSPACE_NAME', readEnvironmentVariable('fabricWorkspaceName', '')) // optional (helpful for naming/UX)
244244

245245
// Fabric capacity SKU.
246246
param fabricCapacitySku = 'F8'

scripts/automationScripts/FabricWorkspace/CreateWorkspace/create_lakehouses.ps1

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,13 @@ if ($names -contains "bronze") {
302302
} else {
303303
Set-Content -Path $workspaceEnvPath -Value $lakehouseExports
304304
}
305+
306+
# Persist lakehouse IDs in azd env so downstream hooks and reruns can find them
307+
try { azd env set FABRIC_LAKEHOUSE_ID $bronzeLakehouse.id } catch {}
308+
foreach ($lakehouse in $existingLakehouses.value) {
309+
$lhName = if ($null -ne $lakehouse.PSObject.Properties['displayName']) { $lakehouse.displayName } else { $lakehouse.name }
310+
try { azd env set "FABRIC_LAKEHOUSE_${lhName}_ID" $lakehouse.id } catch {}
311+
}
305312

306313
} catch {
307314
Warn "Failed to export lakehouse IDs: $($_.Exception.Message)"

scripts/automationScripts/OneLakeIndex/04_create_onelake_datasource.ps1

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,19 @@ if (-not $subscription) { $subscription = $env:AZURE_SUBSCRIPTION_ID }
8686
if (-not $workspaceId) { $workspaceId = $env:FABRIC_WORKSPACE_ID }
8787
if (-not $lakehouseId) { $lakehouseId = $env:FABRIC_LAKEHOUSE_ID }
8888

89+
# Try azd outputs (Bicep emits fabricWorkspaceIdOut for BYO mode)
90+
if (-not $workspaceId -and $outputs) {
91+
if ($outputs.fabricWorkspaceIdOut -and $outputs.fabricWorkspaceIdOut.value) { $workspaceId = $outputs.fabricWorkspaceIdOut.value }
92+
elseif ($outputs.fabricWorkspaceId -and $outputs.fabricWorkspaceId.value) { $workspaceId = $outputs.fabricWorkspaceId.value }
93+
}
94+
if (-not $lakehouseId -and $outputs) {
95+
if ($outputs.fabricLakehouseId -and $outputs.fabricLakehouseId.value) { $lakehouseId = $outputs.fabricLakehouseId.value }
96+
}
97+
98+
# Try azd env store (persisted by create_lakehouses.ps1)
99+
if (-not $workspaceId) { try { $val = & azd env get-value FABRIC_WORKSPACE_ID 2>$null; if ($val) { $workspaceId = $val.ToString().Trim() } } catch {} }
100+
if (-not $lakehouseId) { try { $val = & azd env get-value FABRIC_LAKEHOUSE_ID 2>$null; if ($val) { $lakehouseId = $val.ToString().Trim() } } catch {} }
101+
89102
# Try temp fabric_workspace.env (from create_fabric_workspace.ps1)
90103
if ((-not $workspaceId -or -not $lakehouseId) -and (Test-Path (Join-Path ([IO.Path]::GetTempPath()) 'fabric_workspace.env'))) {
91104
Get-Content (Join-Path ([IO.Path]::GetTempPath()) 'fabric_workspace.env') | ForEach-Object {

0 commit comments

Comments
 (0)