Skip to content

Commit a9743e7

Browse files
authored
Fix defects for mac, make files executable in mac (#156)
* Fix defects for mac * specify azd verion req and verify az login
1 parent ac1d46f commit a9743e7

File tree

6 files changed

+53
-7
lines changed

6 files changed

+53
-7
lines changed

azure.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
name: azd-get-started-with-ai-agents
66
metadata:
77
8+
requiredVersions:
9+
azd: ">=1.14.0"
810

911
hooks:
1012
preup:

scripts/resolve_model_quota.sh

100644100755
File mode changed.

scripts/set_default_models.sh

100644100755
File mode changed.

scripts/setup_credential.ps1

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,23 @@
1+
# Check Azure login status
2+
$azAccount = az account show 2>$null
3+
4+
if (-not $azAccount) {
5+
6+
Write-Host "🔐 Not logged in to Azure. Attempting to login..." -ForegroundColor Yellow
7+
$azureTenantId = azd env get-value AZURE_TENANT_ID
8+
az login --tenant $azureTenantId | Out-Null
9+
10+
if ($LASTEXITCODE -ne 0) {
11+
Write-Host "❌ Azure login failed. Exiting script." -ForegroundColor Red
12+
exit 1
13+
}
14+
15+
Write-Host "✅ Logged in to Azure successfully." -ForegroundColor Green
16+
} else {
17+
$accountInfo = $azAccount | ConvertFrom-Json
18+
Write-Host "✅ Already logged in as: $($accountInfo.user.name)" -ForegroundColor Green
19+
}
20+
121
# Prompt for username with validation
222
do {
323
$username = Read-Host -Prompt '👤 Create a new username for the web app (no spaces, at least 1 character)'

scripts/setup_credential.sh

100644100755
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,29 @@
11
#!/bin/bash
22

3+
set -e
4+
5+
# Check if already logged in
6+
if ! az account show &>/dev/null; then
7+
echo -e "🔐 Not logged in to Azure. Attempting to login..."
8+
9+
azureTenantId=$(azd env get-value AZURE_TENANT_ID)
10+
if [[ -z "$azureTenantId" ]]; then
11+
echo "❌ AZURE_TENANT_ID is not set in the environment. Exiting."
12+
exit 1
13+
fi
14+
15+
az login --tenant "$azureTenantId" > /dev/null
16+
if [[ $? -ne 0 ]]; then
17+
echo "❌ Azure login failed. Exiting script."
18+
exit 1
19+
fi
20+
21+
echo "✅ Logged in to Azure successfully."
22+
else
23+
user=$(az account show --query user.name -o tsv)
24+
echo "✅ Already logged in as: $user"
25+
fi
26+
327
templateValidationMode="${TEMPLATE_VALIDATION_MODE}"
428

529
if [[ "$templateValidationMode" == true ]]; then

scripts/validate_env_vars.sh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
#!/bin/bash
22

3-
# Define environment variables and their regex patterns
4-
declare -A envValidationRules=(
5-
["AZURE_EXISTING_AIPROJECT_RESOURCE_ID"]='^/subscriptions/[0-9a-fA-F-]{36}/resourceGroups/[^/]+/providers/Microsoft\.CognitiveServices/accounts/[^/]+/projects/[^/]+$'
6-
)
3+
# Define environment variable names and their regex patterns
4+
envVars=("AZURE_EXISTING_AIPROJECT_RESOURCE_ID")
5+
patterns=('^/subscriptions/[0-9a-fA-F-]{36}/resourceGroups/[^/]+/providers/Microsoft\.CognitiveServices/accounts/[^/]+/projects/[^/]+$')
76

87
hasError=0
98

10-
for envVar in "${!envValidationRules[@]}"; do
11-
pattern="${envValidationRules[$envVar]}"
9+
for i in "${!envVars[@]}"; do
10+
envVar="${envVars[$i]}"
11+
pattern="${patterns[$i]}"
1212
value="${!envVar}"
1313

1414
if [[ -n "$value" ]]; then
15-
if ! echo "$value" | grep -Eq "$pattern"; then
15+
if [[ ! "$value" =~ $pattern ]]; then
1616
echo "❌ Invalid value for '$envVar'. Expected pattern: $pattern" >&2
1717
hasError=1
1818
fi

0 commit comments

Comments
 (0)