Skip to content

Commit 88e45b6

Browse files
authored
Merge pull request #333 from nekdima/fix/azure-copilot-cross-platform-deploy
Fix cross-platform deploy issues in Azure Copilot MicroHack
2 parents 4cc7f4e + c8b7573 commit 88e45b6

File tree

11 files changed

+39
-21
lines changed

11 files changed

+39
-21
lines changed

03-Azure/01-03-Infrastructure/12_Azure_Copilot/Readme.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,15 @@ In order to use the MicroHack time most effectively, the following tasks should
7575
3. **Agents (Preview) access** — Your tenant must have access to Agents (preview) in Azure Copilot. Access is managed at the tenant level and rolled out gradually. Check with your tenant administrator, or [request access](https://aka.ms/azurecopilot/agents/feedbackprogram).
7676
4. **WebSocket connections** — Your organization must allow WebSocket connections to `https://directline.botframework.com`. Ask your network administrator to enable this if blocked.
7777
5. [Azure CLI](https://learn.microsoft.com/cli/azure/install-azure-cli) installed and logged in (`az login`). **Hint:** Make sure to use the latest version available.
78+
6. [PowerShell 7+](https://learn.microsoft.com/powershell/scripting/install/installing-powershell) (pwsh) — required for all deployment and test scripts. **Hint:** On macOS install via `brew install powershell/tap/powershell`.
7879

7980
In summary:
8081

8182
- Azure Subscription (Contributor role)
8283
- Azure Copilot enabled for your tenant
8384
- Agents (Preview) enabled for your tenant
8485
- Azure CLI installed
86+
- PowerShell 7+ (pwsh) installed
8587
- WebSocket connectivity to `directline.botframework.com`
8688

8789
Permissions for the deployment:
@@ -145,4 +147,4 @@ Running all resources for one day costs approximately **$11.50–14**. For a 2-d
145147
146148
## Contributors
147149

148-
- Dmitriy Nekrasov [GitHub](https://github.com/nekdima); [LinkedIn](https://www.linkedin.com/in/inthedark/)
150+
- Dmitriy Nekrasov [GitHub](https://github.com/nekdima); [LinkedIn](https://www.linkedin.com/in/dmne/)

03-Azure/01-03-Infrastructure/12_Azure_Copilot/app/app.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@
88
- / -> healthy endpoint (200 OK)
99
- /health -> health check
1010
"""
11+
import os
1112
import time
1213
import logging
1314
from flask import Flask, jsonify
1415
from azure.monitor.opentelemetry import configure_azure_monitor
1516

16-
configure_azure_monitor()
17+
if os.environ.get("APPLICATIONINSIGHTS_CONNECTION_STRING"):
18+
configure_azure_monitor()
1719

1820
app = Flask(__name__)
1921
logging.basicConfig(level=logging.INFO)
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
flask>=3.0
2-
gunicorn>=21.2
3-
azure-monitor-opentelemetry>=1.6.0
1+
flask>=3.0,<4.0
2+
gunicorn>=21.2,<26.0
3+
azure-monitor-opentelemetry>=1.6.0,<2.0

03-Azure/01-03-Infrastructure/12_Azure_Copilot/challenges/challenge-06.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,9 @@ Simulate a Cosmos DB connection issue investigation:
113113

114114
### Task 3: Troubleshoot AKS Cluster Issues (10 min)
115115

116+
> [!NOTE]
117+
> No AKS cluster is deployed as part of the lab. This task is exploratory — you can select an existing AKS cluster in your subscription, or simply follow the prompts to see what guidance Azure Copilot provides without a specific resource selected.
118+
116119
Investigate Kubernetes cluster problems:
117120

118121
1. Start a new conversation with agent mode enabled

03-Azure/01-03-Infrastructure/12_Azure_Copilot/challenges/challenge-07.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Challenge 7 - Capstone Multi-Agent Scenario
22

3-
**[Home](../Readme.md)** - [Previous Challenge](challenge-06.md)
3+
**[Home](../Readme.md)** - [Previous Challenge](challenge-06.md) - [Finish](finish.md)
44

55
## Goal
66

03-Azure/01-03-Infrastructure/12_Azure_Copilot/challenges/finish.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
## Congratulations
66

7-
Congratulations! :partying_face: You finished the MicroHack for Azure Copilot.
7+
Congratulations! 🥳 You finished the MicroHack for Azure Copilot.
88

99
We hope you've had the opportunity to experience Azure Copilot and its five specialized agents — Deployment, Observability, Optimization, Resiliency, and Troubleshooting.
1010

03-Azure/01-03-Infrastructure/12_Azure_Copilot/lab/Deploy-Lab.ps1

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#!/usr/bin/env pwsh
12
<#
23
.SYNOPSIS
34
Deploys the Azure Copilot Workshop lab resources (HackboxConsole entry-point).
@@ -50,10 +51,9 @@ $Location = if ([string]::IsNullOrEmpty($PreferredLocation)) { "francecentral" }
5051
# Helper
5152
# ──────────────────────────────────────────────
5253
function Invoke-Az {
53-
& az $args
54+
& az @args
5455
if ($LASTEXITCODE -ne 0) {
55-
Write-Error "Azure CLI command failed with exit code $LASTEXITCODE"
56-
exit $LASTEXITCODE
56+
throw "Azure CLI command failed with exit code $LASTEXITCODE"
5757
}
5858
}
5959

@@ -84,8 +84,7 @@ if (-not (Test-Path $sshPubKeyPath)) {
8484
$sshKeyPath = Join-Path $HOME ".ssh" "id_rsa"
8585
ssh-keygen -t rsa -b 4096 -f $sshKeyPath -q -N ""
8686
if ($LASTEXITCODE -ne 0) {
87-
Write-Error "Failed to generate SSH key pair."
88-
exit 1
87+
throw "Failed to generate SSH key pair. ssh-keygen exited with code $LASTEXITCODE"
8988
}
9089
}
9190
$sshPublicKey = (Get-Content $sshPubKeyPath -Raw).Trim()
@@ -96,7 +95,7 @@ $sshPublicKey = (Get-Content $sshPubKeyPath -Raw).Trim()
9695
Write-Host "`n[1/3] Deploying infrastructure (Bicep)..." -ForegroundColor Yellow
9796
$mainBicep = Join-Path $scriptPath "..\iac\main.bicep"
9897
$timestamp = Get-Date -Format "yyyyMMddHHmmss"
99-
$paramsFile = Join-Path $env:TEMP "copilot-workshop-params-$timestamp.json"
98+
$paramsFile = Join-Path ([System.IO.Path]::GetTempPath()) "copilot-workshop-params-$timestamp.json"
10099

101100
@{
102101
'`$schema' = 'https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#'
@@ -127,10 +126,10 @@ Write-Host " ✓ Infrastructure deployed" -ForegroundColor Green
127126
Write-Host "`n[2/3] Deploying buggy Flask app (Ch02)..." -ForegroundColor Yellow
128127
$webAppName = "app-copilot-buggy-$suffix"
129128
$appDir = Join-Path $scriptPath "..\app"
130-
$zipPath = Join-Path $env:TEMP "$webAppName.zip"
129+
$zipPath = Join-Path ([System.IO.Path]::GetTempPath()) "$webAppName.zip"
131130
if (Test-Path $zipPath) { Remove-Item $zipPath -Force }
132131
Compress-Archive -Path (Join-Path $appDir "*") -DestinationPath $zipPath -Force
133-
Invoke-Az webapp deploy --resource-group "rg-copilot-$suffix-ch02" --name $webAppName --src-path $zipPath --type zip --track-status false -o none
132+
Invoke-Az webapp deploy --resource-group "rg-copilot-$suffix-ch02" --name $webAppName --src-path $zipPath --type zip --track-status false --timeout 600 -o none
134133
Remove-Item $zipPath -Force
135134
Write-Host " ✓ Flask app deployed to $webAppName" -ForegroundColor Green
136135

@@ -154,9 +153,10 @@ if ($DeploymentType -in @('resourcegroup','resourcegroup-with-subscriptionowner'
154153
if ($AllowedEntraUserIds.Count -gt 0) {
155154
foreach ($userId in $AllowedEntraUserIds) {
156155
$scope = "/subscriptions/$SubscriptionId/resourceGroups/$rg"
157-
if (-not (Get-AzRoleAssignment -ObjectId $userId -RoleDefinitionName "Owner" -Scope $scope -ErrorAction SilentlyContinue)) {
156+
$existing = az role assignment list --assignee $userId --role "Owner" --scope $scope -o json 2>$null | ConvertFrom-Json
157+
if (-not $existing -or $existing.Count -eq 0) {
158158
Write-Host "Assigning Owner role to $userId on $rg"
159-
New-AzRoleAssignment -ObjectId $userId -RoleDefinitionName "Owner" -Scope $scope -ErrorAction Stop | Out-Null
159+
Invoke-Az role assignment create --assignee $userId --role "Owner" --scope $scope -o none
160160
}
161161
}
162162
}

03-Azure/01-03-Infrastructure/12_Azure_Copilot/scripts/Remove-CopilotWorkshop.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env pwsh
1+
#!/usr/bin/env pwsh
22
<#
33
.SYNOPSIS
44
Tears down all Azure resources created for the Azure Copilot Workshop.

03-Azure/01-03-Infrastructure/12_Azure_Copilot/scripts/Send-CopilotTraffic.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env pwsh
1+
#!/usr/bin/env pwsh
22
<#
33
.SYNOPSIS
44
Generates error traffic against the Ch02 buggy app to trigger alerts.

03-Azure/01-03-Infrastructure/12_Azure_Copilot/scripts/Test-CopilotWorkshop.ps1

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env pwsh
1+
#!/usr/bin/env pwsh
22
<#
33
.SYNOPSIS
44
Tests all deployed Azure resources for the Copilot Workshop.
@@ -18,6 +18,9 @@ param(
1818
$ErrorActionPreference = "Continue"
1919
Set-StrictMode -Version Latest
2020

21+
# Ensure required CLI extensions are installed (application-insights is needed for Ch02 tests)
22+
az extension add --name application-insights --yes 2>$null
23+
2124
$passed = 0
2225
$failed = 0
2326
$warnings = 0
@@ -51,7 +54,12 @@ Write-Host "`n========================================" -ForegroundColor Cyan
5154
Write-Host " Azure Copilot Workshop - Test Suite" -ForegroundColor Cyan
5255
Write-Host "========================================`n" -ForegroundColor Cyan
5356

54-
$account = az account show -o json 2>&1 | ConvertFrom-Json
57+
$accountJson = az account show -o json 2>&1
58+
if ($LASTEXITCODE -ne 0) {
59+
Write-Host "ERROR: Not logged in to Azure CLI. Run 'az login' first." -ForegroundColor Red
60+
exit 1
61+
}
62+
$account = $accountJson | ConvertFrom-Json
5563
Write-Host "Subscription: $($account.name)`n" -ForegroundColor Green
5664

5765
# ──────────────────────────────────────────────

0 commit comments

Comments
 (0)