-
Notifications
You must be signed in to change notification settings - Fork 35
Expand file tree
/
Copy pathazure.yaml
More file actions
106 lines (98 loc) · 4.23 KB
/
azure.yaml
File metadata and controls
106 lines (98 loc) · 4.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# yaml-language-server: $schema=https://raw.githubusercontent.com/Azure/azure-dev/main/schemas/v1.0/azure.yaml.json
name: cosmicworks
metadata:
template: [email protected]
pipeline:
provider: github
hooks:
preprovision:
windows:
shell: pwsh
continueOnError: false
interactive: true
run: |
# Set OWNER_EMAIL from the signed-in Azure CLI identity
$currentUser = (az account show --query user.name -o tsv 2>$null)
if ([string]::IsNullOrWhiteSpace($currentUser)) {
Write-Error "Unable to determine signed-in user via 'az account show'. Run 'az login' and retry."
exit 1
}
Write-Host "Setting OWNER_EMAIL to: $currentUser"
azd env set OWNER_EMAIL "$currentUser" | Out-Null
$env:OWNER_EMAIL = $currentUser
posix:
shell: sh
continueOnError: false
interactive: true
run: |
# Set OWNER_EMAIL from the signed-in Azure CLI identity
CURRENT_USER=$(az account show --query user.name -o tsv 2>/dev/null)
if [ -z "$CURRENT_USER" ]; then
echo "ERROR: Unable to determine signed-in user via 'az account show'. Run 'az login' and retry." 1>&2
exit 1
fi
echo "Setting OWNER_EMAIL to: $CURRENT_USER"
azd env set OWNER_EMAIL "$CURRENT_USER" >/dev/null
export OWNER_EMAIL="$CURRENT_USER"
postdeploy:
windows:
shell: pwsh
run: |
Write-Host "Setting up appsettings.development.json"
$subscriptionId = $env:AZURE_SUBSCRIPTION_ID
$resourceGroup = $env:AZURE_RESOURCE_GROUP
$location = $env:AZURE_LOCATION
$endpoint = $env:AZURE_COSMOSDB_ENDPOINT
$accountName = $env:AZURE_COSMOSDB_ACCOUNT_NAME
if ([string]::IsNullOrWhiteSpace($subscriptionId) -or
[string]::IsNullOrWhiteSpace($resourceGroup) -or
[string]::IsNullOrWhiteSpace($location) -or
[string]::IsNullOrWhiteSpace($endpoint) -or
[string]::IsNullOrWhiteSpace($accountName)) {
Write-Error "Missing required AZD IaC outputs. Re-run 'azd provision' (or 'azd up') so infra/main.bicep outputs are available: AZURE_SUBSCRIPTION_ID, AZURE_RESOURCE_GROUP, AZURE_LOCATION, AZURE_COSMOSDB_ENDPOINT, AZURE_COSMOSDB_ACCOUNT_NAME."
exit 1
}
$appSettingsContent = @{
SUBSCRIPTION_ID = $subscriptionId
RESOURCE_GROUP = $resourceGroup
LOCATION = $location
ACCOUNT_NAME = $accountName
ACCOUNT_ENDPOINT = $endpoint
} | ConvertTo-Json -Depth 5
$projectPath = "./src"
$appSettingsPath = "$projectPath/appsettings.development.json"
New-Item -ItemType Directory -Path $projectPath -Force | Out-Null
Set-Content -Path $appSettingsPath -Value $appSettingsContent
Write-Host "Created appsettings.development.json in $projectPath"
continueOnError: false
interactive: true
posix:
shell: sh
run: |
echo "Setting up appsettings.development.json"
subscriptionId="${AZURE_SUBSCRIPTION_ID}"
resourceGroup="${AZURE_RESOURCE_GROUP}"
location="${AZURE_LOCATION}"
endpoint="${AZURE_COSMOSDB_ENDPOINT}"
accountName="${AZURE_COSMOSDB_ACCOUNT_NAME}"
if [ -z "$subscriptionId" ] || [ -z "$resourceGroup" ] || [ -z "$location" ] || [ -z "$endpoint" ] || [ -z "$accountName" ]; then
echo "ERROR: Missing required AZD IaC outputs. Re-run 'azd provision' (or 'azd up') so infra/main.bicep outputs are available: AZURE_SUBSCRIPTION_ID, AZURE_RESOURCE_GROUP, AZURE_LOCATION, AZURE_COSMOSDB_ENDPOINT, AZURE_COSMOSDB_ACCOUNT_NAME." 1>&2
exit 1
fi
appSettingsContent=$(cat <<EOF
{
"SUBSCRIPTION_ID": "${subscriptionId}",
"RESOURCE_GROUP": "${resourceGroup}",
"LOCATION": "${location}",
"ACCOUNT_NAME": "${accountName}",
"ACCOUNT_ENDPOINT": "${endpoint}"
}
EOF
)
projectPath="./src"
appSettingsPath="$projectPath/appsettings.development.json"
mkdir -p "$projectPath"
printf '%s\n' "$appSettingsContent" > "$appSettingsPath"
echo "Created appsettings.development.json in $projectPath"
continueOnError: false
interactive: true