Terraform Provider for Microsoft Fabric: #2 Using MCP servers and Fabric CLI to help define your fabric resources
After the first blog post you now have a simple starter config, and you can work successfully in the user context having authenticated to your new app registration. This post will explore some of the various resources available to you as you start to expand your config.
This post is the second in the series.
- Accelerating first steps using the CLIs.
- Using MCP servers and Fabric CLI to help define your fabric resources.
- Creating a workload identity with Fabric permissions.
- Deploying a fabric config with Terraform in GitHub Actions.
First we will look at some of the standard public documentation and samples, before moving on to how to configure the Terraform and Microsoft Learn MCP servers, and then how to interrogate manually created resources using the Fabric CLI.
Using these tools will help you get a better understanding of how to define more complex Fabric resources in Terraform.
Standard resources
The official Terraform Provider for Fabric documentation is your first port of call to help you to build out your config. However, the provider is relatively new and therefore the documentation, blogs and samples will naturally evolve and improve as the provider matures.
The Fabric Rest API documentation is an invaluable resource to more fully understand the properties and permitted values expected in your Terraform resources. (Terraform providers use the Go SDK to call the underlying REST APIs directly.)
There are also official quickstart samples for you to explore. Refer to my reference repo.
Most of the time these resources will be all that you need. When configuring more complex resources then the MCP servers and Fabric CLI can provide greater insight.
Problem statement
It is difficult to define the more complex Terraform resources without detailed documentation and samples to reference.
As an example, the documentation for the fabric_copy_job resource requires a source file for the definition—essentially a full JSON object with handlebar templates for the tokens—but gives little idea on how to configure that file.

Working out the correct way to define resources such as this can be a challenge, so let’s work through this as an example, using the MCP servers and Fabric CLI.
Note that whether it makes sense to configure workspace level resources such as Copy Jobs within Terraform is a decision point; one argument is to use a split configuration, with Terraform declaring the Fabric Administration resources such as capacities, domains, workspaces, RBAC, workload identities, data lakes, connections, shortcuts etc., whilst using the workspace level Git integration to capture the configuration for Data Engineer / Analyst resources. Regardless, the fabric_copy_job is an example of a complex resource type and a useful test case.
MCP servers
MCP servers improve the responses that GitHub Copilot provides for information and code creation.
This section will show you how to configure MCP servers in Visual Studio Code, using both the Microsoft Learn MCP server and the Terraform MCP server (beta). The servers will provide fully up-to-date information grounded directly from the Terraform Registry and Microsoft Learn documentation respectively, rather than potentially stale LLM responses, and can help you to more quickly generate resource definitions.
MCP Servers became first class resources in v1.102.1 so check it is up to date.
Microsoft Learn Docs
The Microsoft Docs MCP server is a remote https server, and it is very simple to set up.
- Extensions (
CTRL+SHIFT+X) > MCP Servers > MCP Servers for agent mode.

- Select Install Microsoft Docs.
- Select Install in the Extension pane.

This is configured in the roaming user session so will be available whenever you use vscode.
Terraform MCP Server
The Terraform MCP server requires docker to be running. The following steps will configure it within the workspace.
Use CTRL+D to exit and remove the container, and the configure it properly within vscode.
- Open the Explorer tab in Visual Studio Code (
CTRL+SHIFT+E). - Create a .vscode/mcp.json file.
- Add the following JSON.
{
"servers": {
"terraform": {
"type": "stdio",
"command": "docker",
"args": [
"run",
"--interactive",
"--rm",
"hashicorp/terraform-mcp-server"
]
}
}
}
Select the Start above each server. You can check that the servers are running with the Command Palette (CTRL+SHIFT+P) and selecting the MCP: List servers command. You can also view the MCP server tools available to GitHub Copilot, by clicking on the Tools icon in the GitHub Copilot chat window when in Agent mode.
Example prompts
You are now ready to use the MCP server right within the IDE. The example prompts can be used to test with.
Describe the fabric_copy_job resource in the microsoft/fabric provider
You may have to approve the use of the MCP server first time round and then you should have a similar response to the following screenshot example.

Use Microsoft Learn to describe a valid definition for this resource
Add in the Microsoft Learn MCP server to get more definition.

The MCP server has linked to an anchor within the copy job documentation for more detail.
Generate a valid copyjob-content.json template including the token handlebars
Agent mode can go further, generating files for you. In the following screenshot, it is creating an example template file for you to use as a starting point.

Using GitHub Copilot Agent mode in combination with the MCP servers is a powerful combination to get you working faster.
Using the Fabric CLI to query Microsoft Fabric resources
Another approach to constructing more complicated Terraform resources for the first time is to create an example manually via the portal and then use terraform import (or a data source) to get an insight on the expected format of the argument values.
The Fabric CLI allows us to achieve a similar result by querying those manually created resources.
This example set of commands to get the definition value from a copy job called aidwCopySilverActivity that was manually defined in a workspace called aidwiotfactory.
fab ls -l fab ls -l aidwiotfactory.Workspace fab ls -l aidwiotfactory.Workspace/aidwCopySilverActivity.CopyJob fab get aidwiotfactory.Workspace/aidwCopySilverActivity.CopyJob -fq definition | grep -v '^[!?]' | jq .

A few notes on the final command:
- The
-f/--forceswitch bypasses a warning prompt about sensitivity labels. - The warning is removed from the stdout by grep to make the JSON syntactically valid.
- The jq command colorizes the output and converts the end of line from CRLF to LF.
- Colors have been matched to Azure CLI’s jsonc output using
export JQ_COLORS="1;90:1;34:0;34:1;36:0;33:1;37:1;37". - The query only returns the definition object. Use
-q/--query .instead to return the full JSON output.
The output from Fabric CLI is a fantastic reference to help you correctly define your more complex resources.
Summary
The resources and techniques on this page are very useful when expanding your Terraform config to administer your Microsoft Fabric environment. Remember to expand iteratively and test as you go to ensure your config is working correctly.
In the next two blog posts we will cover how to move to production, by creating a workload identity that can be used in your CI/CD pipelines then finish up with an example deployment pipeline using GitHub Actions.