Exercise - Build a protected deployment workflow
In this exercise, you build the deployment workflow in a GitHub repository, configure its secrets and production approval, and review it for safe handling of credentials and destructive changes.
Prerequisites
You need a GitHub repository that holds your Fabric Apps project, and a Microsoft Entra app registration with a client secret to use as a service principal. A Fabric administrator must allow service principals to use Fabric APIs, and the service principal needs the Contributor role on the development and production workspaces from the previous exercise. Never paste a secret value into a file, a prompt, or an issue.
If you don't already have an app registration, use the following commands to create one. You need the Azure CLI installed and permission to register applications in your tenant. Run the commands in the same Bash terminal session.
Sign in to the tenant that contains your Fabric workspaces. Replace
<tenant-id>with that tenant's ID. An Azure subscription isn't required for these commands.az login --tenant "<tenant-id>" --allow-no-subscriptionsCreate a single-tenant app registration, and save its application ID in a shell variable.
APP_ID=$(az ad app create \ --display-name "adventure-release-lab-deploy" \ --sign-in-audience AzureADMyOrg \ --query appId --output tsv)Create the service principal that represents this application in your tenant.
az ad sp create --id "$APP_ID"Create a client secret that expires after one year. The
--appendoption preserves existing credentials.az ad app credential reset \ --id "$APP_ID" \ --append \ --display-name "github-actions" \ --years 1 \ --query password --output tsvThis command prints the secret value. Enter it directly into the GitHub environment secrets when you configure them later in this exercise. Don't share the terminal output or save it in the repository. Use the application ID stored in
APP_IDforFABRIC_CLIENT_ID, the printed secret forFABRIC_CLIENT_SECRET, and the tenant ID from your sign-in command forFABRIC_TENANT_ID.In the Fabric portal, grant adventure-release-lab-deploy the Contributor role on both workspaces. Ask your Fabric administrator to enable service principal access to Fabric APIs if it isn't already enabled. Creating the app registration doesn't grant these permissions.
Create the workflow
- In the repository, create
.github/workflows/deploy.yml. - Add the workflow from the previous unit.
- Confirm each protection:
workflow_dispatchis the only trigger, and theforceinput defaults tofalse.- The
concurrencygroup includesinputs.target, andcancel-in-progressisfalse. environment: ${{ inputs.target }}selects a GitHub environment.actions/setup-nodeuses Node.js 24.- Only the sign-in step reads the three service principal secrets.
- The sign-in command includes
--encryption-fallback-enabledfor the disposable GitHub-hosted Ubuntu runner. Your security policy permits unencrypted local token storage, and the workflow doesn't cache or upload authentication files.
- The sign-in command includes
- The sign-in command has a
\at the end of every line except the last, and each variable reference starts with$.
Configure environments, secrets, and variables
- In the repository settings, create two GitHub environments named
developmentandproduction. - In the
productionenvironment, add required reviewers, and limit deployments to themainbranch. - In each environment, add the secrets
FABRIC_CLIENT_ID,FABRIC_CLIENT_SECRET, andFABRIC_TENANT_ID. Enter the values in the GitHub interface only. - In each environment, add a variable named
FABRIC_WORKSPACE_IDwith that environment's workspace GUID. It's an identifier, not a secret.
The production environment now requires an approval before any job that targets it starts, and each environment resolves its own workspace.
Review the workflow
Review the file without running it. Answer each question in a sentence.
- Which setting prevents two deployments from running against production at the same time, and why doesn't it block a development deployment?
- Which step stops a deployment that targets the wrong workspace?
- What must a person do before a destructive schema change can deploy to production?
- Where could a secret leak if you moved the service principal values from the sign-in step to the job
env?
Compare your answers with these:
- The
concurrencygroup serializes runs perinputs.target, so production runs queue behind each other while development runs use a different group. - The dry-run step prints the resolved target before the deploy step changes anything.
- A person must set the
forceinput to true and approve theproductionenvironment. - The values would reach every step, including
npm ciand its install scripts, and a mistake could write them into logs.
Run the workflow safely
If your tenant is ready, run the workflow manually with target set to development and force cleared. In the run log, confirm that the sign-in step succeeds, the preview names the development workspace, and the verify step reports a healthy deployment. Don't run it against production in this exercise. If your tenant isn't ready for service principal sign-in, skip the run.
Explain the result
- Why does the workflow use
--yesand--workspace-id? - Why is
forcea manual input and not a default?
A workflow can't answer prompts, and the explicit target prevents it from depending on a local default. A destructive change needs a conscious decision on each run.