|
| 1 | +# `deploy` Command |
| 2 | + |
| 3 | +The `deploy` command imports workspace items from a local source into a target Fabric workspace. |
| 4 | + |
| 5 | +You can deploy: |
| 6 | + |
| 7 | +- all items from the source workspace |
| 8 | +- specific folders that contain items |
| 9 | +- specific items |
| 10 | + |
| 11 | +**Supported Types:** |
| 12 | + |
| 13 | +- All Fabric workspace item types that support definition import (e.g., `.Notebook`, `.DataPipeline`, `.Report` ) |
| 14 | + |
| 15 | +**Usage:** |
| 16 | + |
| 17 | +``` |
| 18 | +fab deploy --config <config_file> [--target_env <environment>] [--params <parameters>] [--force] |
| 19 | +``` |
| 20 | + |
| 21 | +**Parameters:** |
| 22 | + |
| 23 | +- `--config <file>`: Path to the deployment configuration YAML file. **Required**. |
| 24 | +- `--target_env, -tenv <env>`: Environment name used to select environment-specific settings from the configuration file and the parameter file (if present). Optional. |
| 25 | +- `--params, -P <params>`: JSON-formatted parameters provided to the deployment process at runtime. Optional. |
| 26 | +- `--force, -f`: Run the deployment without interactive confirmation prompts. Optional. |
| 27 | + |
| 28 | +**Example:** |
| 29 | + |
| 30 | +``` |
| 31 | +fab deploy --config config.yml --target_env dev |
| 32 | +``` |
| 33 | + |
| 34 | +--- |
| 35 | + |
| 36 | +### Deployment Behavior |
| 37 | + |
| 38 | +The scope of the deployment, its operations (e.g., publish, unpublish), and settings are defined entirely by the configurations set in a YAML file. |
| 39 | + |
| 40 | +During execution, the command: |
| 41 | + |
| 42 | +- publishes items found in the source into the target workspace |
| 43 | +- resolves dependencies between items automatically when logical IDs are present |
| 44 | +- unpublishes items from the target workspace that no longer exist in the source |
| 45 | + |
| 46 | +By default, **both publish and unpublish operations are enabled and executed**. |
| 47 | +To disable either operation for a specific environment, it must be explicitly skipped in the configuration file. |
| 48 | + |
| 49 | +The deployment to the Fabric workspaces is executed via the Fabric REST APIs. |
| 50 | + |
| 51 | +--- |
| 52 | + |
| 53 | +### Configuration Behavior |
| 54 | + |
| 55 | +- The configuration file controls what is published and unpublished. |
| 56 | +- Publish and unpublish operations are enabled by default. |
| 57 | +- Skipping publish or unpublish must be explicitly defined per environment. |
| 58 | +- Target Environment selection is resolved only when environment mappings are present in the configuration. |
| 59 | +- If `--target_env` is not specified, the configuration fields must not contain environment-mappings. |
| 60 | + |
| 61 | +--- |
| 62 | + |
| 63 | +### Configuration File |
| 64 | + |
| 65 | +#### Minimal Configuration (No Environment Mappings) |
| 66 | + |
| 67 | +```yaml |
| 68 | +core: |
| 69 | + workspace_id: "12345678-1234-1234-1234-123456789abc" |
| 70 | + repository_directory: "." |
| 71 | +``` |
| 72 | +
|
| 73 | +#### Configuration Fields |
| 74 | +
|
| 75 | +| Field | Description | Mandatory | |
| 76 | +|------|------------|-----------| |
| 77 | +| `core.workspace_id` | Target workspace ID (GUID). Takes precedence over `workspace`. | ✅ Yes | |
| 78 | +| `core.workspace` | Target workspace name. Alternative to `workspace_id`. | ❌ No | |
| 79 | +| `core.repository_directory` | Path to local directory containing item files. | ✅ Yes | |
| 80 | +| `core.item_types_in_scope` | List of item types included in deployment. | ❌ No | |
| 81 | +| `core.parameter` | Path to parameter file. | ❌ No | |
| 82 | +| `publish` | Controls publishing behavior. | ❌ No | |
| 83 | +| `unpublish` | Controls unpublishing behavior. | ❌ No | |
| 84 | +| `features` | Set feature flags. | ❌ No | |
| 85 | +| `constants` | Override constant values. | ❌ No | |
| 86 | + |
| 87 | +Relative paths for `repository_directory` and `parameter` fields are resolved relative to the configuration file location. |
| 88 | + |
| 89 | +--- |
| 90 | + |
| 91 | +### Publish and Unpublish Settings |
| 92 | + |
| 93 | +#### Publish |
| 94 | + |
| 95 | +```yaml |
| 96 | +publish: |
| 97 | + exclude_regex: "^DONT_DEPLOY.*" # Excludes items matching this pattern from publishing |
| 98 | + folder_exclude_regex: "^/legacy" # Excludes items under matching folders from publishing (requires feature flags) |
| 99 | + folder_path_to_include: # Publishes only the specified items under matching folder (requires feature flags) |
| 100 | + - /subfolder_1 |
| 101 | + items_to_include: # Publishes only the specified items (requires feature flags) |
| 102 | + - "MainNotebook.Notebook" |
| 103 | + skip: # Skips publishing per environment |
| 104 | + dev: true |
| 105 | + test: false |
| 106 | + prod: false |
| 107 | +``` |
| 108 | + |
| 109 | +#### Unpublish |
| 110 | + |
| 111 | +```yaml |
| 112 | +unpublish: |
| 113 | + exclude_regex: "^DEBUG.*" # Prevents matching items from being removed |
| 114 | + items_to_include: # Unpublishes only the specified items (requires feature flags) |
| 115 | + - "OldPipeline.DataPipeline" |
| 116 | + skip: # Skips unpublishing per environment |
| 117 | + dev: true |
| 118 | + test: false |
| 119 | + prod: false |
| 120 | +``` |
| 121 | + |
| 122 | +> **Note** |
| 123 | +> While selective deployment is supported, it is not recommended due to potential issues with dependency management. Use selective deployment options with caution. |
| 124 | + |
| 125 | +--- |
| 126 | + |
| 127 | +### Parameter File |
| 128 | + |
| 129 | +The parameter file enables environment‑specific transformations by applying targeted replacements within deployed content. |
| 130 | + |
| 131 | +It can be used to: |
| 132 | + |
| 133 | +- replace workspace and item identifiers |
| 134 | +- replace connection strings and URLs |
| 135 | +- update embedded values inside item definitions |
| 136 | +- parameterize environment-specific configuration values |
| 137 | + |
| 138 | +The parameter file is optional and is applied only when specified in the configuration. |
| 139 | + |
| 140 | +When deploying item files that were not created via Git Integration but instead exported (for example, using the Fabric CLI export command), parameterization should be used to resolve dependencies. Otherwise, items will reference the original item. |
| 141 | + |
| 142 | +#### Example |
| 143 | + |
| 144 | +```yaml |
| 145 | +find_replace: |
| 146 | + - find_value: "dev-connection-string" |
| 147 | + replace_value: |
| 148 | + dev: "dev-connection-string" |
| 149 | + test: "test-connection-string" |
| 150 | + prod: "prod-connection-string" |
| 151 | +``` |
| 152 | + |
| 153 | +#### Supported `replace_value` Variables |
| 154 | + |
| 155 | +- `$workspace.$id` — resolves to the target workspace ID |
| 156 | +- `$items.<ItemType>.<ItemName>.$id` — resolves to the deployed item ID |
| 157 | + |
| 158 | +Parameterization behavior follows the documented model described here: |
| 159 | + |
| 160 | +https://microsoft.github.io/fabric-cicd/latest/how_to/parameterization |
| 161 | + |
| 162 | +--- |
| 163 | + |
| 164 | +### More Examples |
| 165 | + |
| 166 | +#### Deployment to a Specific Environment |
| 167 | + |
| 168 | +```bash |
| 169 | +fab deploy --config config.yml --target_env prod |
| 170 | +``` |
| 171 | + |
| 172 | +#### Deployment with Runtime Parameters |
| 173 | + |
| 174 | +```bash |
| 175 | +fab deploy --config config.yml --target_env test -P config_override='{"core":{"item_types_in_scope":["Notebook"]}}' |
| 176 | +``` |
| 177 | + |
| 178 | +--- |
| 179 | + |
| 180 | +### Preparing Source Content |
| 181 | + |
| 182 | +#### Using Git Integration |
| 183 | + |
| 184 | +If the workspace is connected to Git, clone the repository locally: |
| 185 | + |
| 186 | +```bash |
| 187 | +git clone <git-repository-url>.git |
| 188 | +``` |
| 189 | + |
| 190 | +Use the cloned repository as the deployment source. |
| 191 | + |
| 192 | +#### Using `fab export` |
| 193 | + |
| 194 | +`fab export` exports one item at a time and does not include logical IDs. |
| 195 | + |
| 196 | +```bash |
| 197 | +fab export ws.Workspace/MyDataPipeline.DataPipeline -o C:\Users\myuser |
| 198 | +``` |
| 199 | + |
| 200 | +--- |
| 201 | + |
| 202 | +### Additional Notes |
| 203 | + |
| 204 | +- The deploy command can be applied to Fabric item files created via Git integration or using the `export` command (utilizes Get Item Definition API). |
| 205 | +- `fab deploy` does not require items to be created via Git integration prior to deployment; however, using Git integration is strongly recommended for dependency resolution with minimal parameterization. |
| 206 | +- Parameterization is optional and can be applied in any deployment scenario. |
| 207 | + |
| 208 | +--- |
| 209 | + |
| 210 | +### Usfull links |
| 211 | + |
| 212 | +- [Fabric cicd lib](https://microsoft.github.io/fabric-cicd/latest/) |
0 commit comments