This repository contains two PowerShell scripts used in the Skillable lab (LAB520) lifecycle:
- Install the Azure Developer CLI (azd)
- Deploy resources, assign RBAC roles, and configure hosted agent identities — all in one combined script
Note:
azd_deployment.ps1,rbac_bootstrap.ps1, andhosted_agent_fix.ps1are superseded bydeploy.ps1and are retained for reference only.
It includes execution order, configuration details, logging behavior, and setup instructions.
- Purpose: Installs or upgrades the Azure Developer CLI (
azd) toC:\utils\azdon the Windows VM. Ensures thatazdis available and waits for the command to be usable. - Configuration:
- Blocking: Yes
- Timeout: 15 minutes
- Logging:
- Desktop log file:
azd-install.log(fallback to%TEMP%if Desktop is unavailable) - Uses
Start-Transcriptand a customLogfunction to write timestamped output.
- Desktop log file:
- Setup Instructions:
- Configure as a Blocking VM script in Skillable with a 15-minute timeout.
- The script begins a transcript to the Desktop log file.
- It downloads and runs the azd installer to
C:\utils\azd. - It updates the PATH and loops to validate
azd versionis available. - The script stops transcription at the end.
- Purpose: All-in-one lifecycle script. Authenticates, runs
azd up, then applies all required RBAC role assignments for the lab user, project managed identity, deployment service principal, and hosted agent identities. - Configuration:
- Blocking: Yes
- Timeout: 90 minutes
- Logging:
- Desktop log file:
lifecycle-165767.log - Uses
Start-Transcript.
- Desktop log file:
- Features:
- Authenticates to Az PowerShell (
Connect-AzAccount) using the lab service principal. - Resolves the lab user object ID with a retry loop (10 attempts, 15 s gap).
- Resolves the deployment service principal object ID (
Get-AzADServicePrincipal). - Adds
C:\utils\azd\binto$env:PATHat runtime (required becauseazd_install.ps1modifies the machine PATH, which isn't inherited by a new session). - Changes directory to
C:\Users\LabUser\Desktop\Build26-LAB520-main; fails early if the folder is missing. - Runs
azd auth login,azd env new, setsAZURE_PRINCIPAL_ID,AZURE_PRINCIPAL_TYPE,AZURE_TENANT_ID, thenazd up --no-prompt. - After deployment, uses
Invoke-WithRetry(up to 12 attempts, 15 s gap) to wait for the Foundry Cognitive Services account and project managed identity to be available in ARM. - Applies Foundry RBAC roles idempotently (
Grant-Rolehelper skipsRoleAssignmentExists):- Foundry User to the deployment service principal
- Foundry User to the lab user
- Foundry Project Manager to the lab user
- Foundry User to the project managed identity
- Polls up to 5 minutes for agent service identities (
*-AgentIdentity) and grants each Foundry User. - Waits 120 seconds for RBAC propagation before completing.
- Authenticates to Az PowerShell (
- Setup Instructions:
- Ensure
azd_install.ps1has completed first (installs azd toC:\utils\azd). - Configure as a Blocking VM script with a 90-minute timeout.
- The lab project folder
C:\Users\LabUser\Desktop\Build26-LAB520-mainmust containazure.yaml.
- Ensure
- Resource Provider Registration (system-owned)
- AZD Install Script (
azd_install.ps1) — Blocking, 15 min - Deploy Script (
deploy.ps1) — Blocking, 90 min - Teardown (system-owned)
- Both scripts use
Start-Transcriptto Desktop log files. deploy.ps1logs toC:\Users\LabUser\Desktop\lifecycle-165767.log.azd_install.ps1logs toC:\Users\LabUser\Desktop\azd-install.log.- All retry attempts and RBAC grant outcomes are written to the transcript.
| Script | Timeout | Blocking | Notes |
|---|---|---|---|
| azd_install.ps1 | 15 minutes | Yes | Must complete before deploy.ps1 |
| deploy.ps1 | 90 minutes | Yes | Includes azd up + all RBAC setup |
azd_install.ps1must be blocking soazdis present beforedeploy.ps1runs.deploy.ps1addsC:\utils\azd\binto$env:PATHat runtime — do not rely on the machine PATH being inherited.- Wrap PowerShell variable references that are followed by
:or other delimiter characters in${}(e.g.${maxAttempts}) to avoid scope-qualifier parse errors. - Adjust the 90-minute timeout upward for slower Azure regions if
azd upconsistently times out.
If issues occur, review C:\Users\LabUser\Desktop\lifecycle-165767.log. The log includes every retry attempt, RBAC grant result, and the full stack trace of any fatal error. Verify service principal credentials, that the lab project folder exists, and that Cognitive Services resources are present in the resource group.