File tree Expand file tree Collapse file tree 2 files changed +44
-0
lines changed
Expand file tree Collapse file tree 2 files changed +44
-0
lines changed Original file line number Diff line number Diff line change 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
222do {
323 $username = Read-Host - Prompt ' 👤 Create a new username for the web app (no spaces, at least 1 character)'
Original file line number Diff line number Diff line change 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+
327templateValidationMode=" ${TEMPLATE_VALIDATION_MODE} "
428
529if [[ " $templateValidationMode " == true ]]; then
You can’t perform that action at this time.
0 commit comments