|
1 | 1 | #!/bin/bash |
2 | 2 | # ============================================================================= |
3 | | -# Azure App Configuration – Sudoku Production Settings |
| 3 | +# Azure App Configuration – Sudoku Settings |
4 | 4 | # ============================================================================= |
5 | 5 | # Usage: |
6 | 6 | # chmod +x set-app-config.sh |
7 | | -# ./set-app-config.sh |
| 7 | +# ./set-app-config.sh # push both Development and Production |
| 8 | +# ./set-app-config.sh Development # push Development only |
| 9 | +# ./set-app-config.sh Production # push Production only |
8 | 10 | # |
9 | 11 | # Prerequisites: |
10 | 12 | # - Azure CLI installed and logged in (az login) |
11 | 13 | # - Contributor or App Configuration Data Owner role on the App Config store |
12 | 14 | # ============================================================================= |
13 | 15 |
|
14 | 16 | APP_CONFIG_NAME="appcs-xenobiasoft-prod" |
15 | | -LABEL="Production" |
16 | | - |
17 | | -echo "Setting App Configuration keys for: $APP_CONFIG_NAME (label: $LABEL)" |
18 | | -echo "---------------------------------------------------------------------" |
| 17 | +TARGET_LABEL=${1:-"both"} |
19 | 18 |
|
20 | 19 | set_key() { |
21 | | - local key=$1 |
22 | | - local value=$2 |
23 | | - echo "Setting: $key = $value" |
| 20 | + local label=$1 |
| 21 | + local key=$2 |
| 22 | + local value=$3 |
| 23 | + echo " [$label] $key = $value" |
24 | 24 | az appconfig kv set \ |
25 | 25 | --name "$APP_CONFIG_NAME" \ |
26 | 26 | --key "$key" \ |
27 | 27 | --value "$value" \ |
28 | | - --label "$LABEL" \ |
| 28 | + --label "$label" \ |
29 | 29 | --yes |
30 | 30 | } |
31 | 31 |
|
32 | | -# ----------------------------------------------------------------------------- |
33 | | -# Cosmos DB |
34 | | -# ----------------------------------------------------------------------------- |
35 | | -set_key "UseCosmosDb" "true" |
36 | | -set_key "CosmosDb:DatabaseName" "sudoku" |
37 | | -set_key "CosmosDb:ContainerName" "games" |
38 | | -set_key "CosmosDb:UseManagedIdentity" "true" |
39 | | -set_key "CosmosDb:AccountEndpoint" "https://cosmos-sudoku-prod.documents.azure.com:443/" |
40 | | -set_key "CosmosDb:ConnectionMode" "Direct" |
41 | | - |
42 | | -# ----------------------------------------------------------------------------- |
43 | | -# Azure Storage |
44 | | -# ----------------------------------------------------------------------------- |
45 | | -set_key "AzureStorage:ContainerName" "sudoku-games" |
46 | | -set_key "AzureStorage:UseManagedIdentity" "true" |
47 | | -set_key "AzureStorage:AccountName" "stxenobiasoftprod" |
48 | | - |
49 | | -# ----------------------------------------------------------------------------- |
50 | | -# API & CORS |
51 | | -# ----------------------------------------------------------------------------- |
52 | | -set_key "ApiBaseUrl" "https://xenobiasoftsudokuapi-prod.azurewebsites.net/" |
53 | | -set_key "AllowedHosts" "*" |
54 | | -set_key "Cors:AllowedOrigins:0" "https://sudoku.xenobiasoft.com" |
55 | | -set_key "Cors:AllowedOrigins:1" "https://xenobiasoftsudoku-prod.azurewebsites.net" |
56 | | - |
57 | | -# ----------------------------------------------------------------------------- |
58 | | -# Sudoku Game Settings |
59 | | -# ----------------------------------------------------------------------------- |
60 | | -set_key "Sudoku:Game:DefaultDifficulty" "Medium" |
61 | | -set_key "Sudoku:Game:MaxHintsPerGame" "3" |
62 | | -set_key "Sudoku:Game:AutoSaveIntervalSeconds" "30" |
63 | | -set_key "Sudoku:Game:EnableStatistics" "true" |
64 | | -set_key "Sudoku:UI:DefaultTheme" "Light" |
65 | | -set_key "Sudoku:UI:ShowTimer" "true" |
66 | | -set_key "Sudoku:UI:EnableAnimations" "true" |
67 | | -set_key "Sudoku:UI:CellSizePixels" "40" |
68 | | -set_key "Sudoku:Performance:GameStateCacheTimeoutSeconds" "300" |
69 | | -set_key "Sudoku:Performance:MaxConcurrentGamesPerUser" "5" |
70 | | -set_key "Sudoku:Performance:EnableResponseCompression" "true" |
71 | | - |
72 | | -# ----------------------------------------------------------------------------- |
73 | | -# Logging |
74 | | -# ----------------------------------------------------------------------------- |
75 | | -set_key "Logging:LogLevel:Default" "Information" |
76 | | -set_key "Logging:LogLevel:Microsoft.AspNetCore" "Warning" |
77 | | -set_key "Logging:ApplicationInsights:LogLevel:Default" "Information" |
78 | | -set_key "Logging:ApplicationInsights:LogLevel:Microsoft" "Warning" |
79 | | - |
80 | | -# ----------------------------------------------------------------------------- |
81 | | -# Swagger (temporary — disable when done testing) |
82 | | -# ----------------------------------------------------------------------------- |
83 | | -set_key "EnableSwagger" "false" |
| 32 | +# ============================================================================= |
| 33 | +# Production settings |
| 34 | +# ============================================================================= |
| 35 | +push_production() { |
| 36 | + local LABEL="Production" |
| 37 | + echo "" |
| 38 | + echo "Setting App Configuration keys (label: $LABEL)" |
| 39 | + echo "---------------------------------------------------------------------" |
| 40 | + |
| 41 | + # ------------------------------------------------------------------------- |
| 42 | + # Cosmos DB |
| 43 | + # ------------------------------------------------------------------------- |
| 44 | + set_key "$LABEL" "UseCosmosDb" "true" |
| 45 | + set_key "$LABEL" "CosmosDb:DatabaseName" "sudoku" |
| 46 | + set_key "$LABEL" "CosmosDb:ContainerName" "games" |
| 47 | + set_key "$LABEL" "CosmosDb:UseManagedIdentity" "true" |
| 48 | + set_key "$LABEL" "CosmosDb:AccountEndpoint" "https://cosmos-sudoku-prod.documents.azure.com:443/" |
| 49 | + set_key "$LABEL" "CosmosDb:ConnectionMode" "Direct" |
| 50 | + |
| 51 | + # ------------------------------------------------------------------------- |
| 52 | + # Azure Storage |
| 53 | + # ------------------------------------------------------------------------- |
| 54 | + set_key "$LABEL" "AzureStorage:ContainerName" "sudoku-games" |
| 55 | + set_key "$LABEL" "AzureStorage:UseManagedIdentity" "true" |
| 56 | + set_key "$LABEL" "AzureStorage:AccountName" "stxenobiasoftprod" |
| 57 | + |
| 58 | + # ------------------------------------------------------------------------- |
| 59 | + # API & CORS |
| 60 | + # ------------------------------------------------------------------------- |
| 61 | + set_key "$LABEL" "ApiBaseUrl" "https://xenobiasoftsudokuapi-prod.azurewebsites.net/" |
| 62 | + set_key "$LABEL" "AllowedHosts" "*" |
| 63 | + set_key "$LABEL" "Cors:AllowedOrigins:0" "https://sudoku.xenobiasoft.com" |
| 64 | + set_key "$LABEL" "Cors:AllowedOrigins:1" "https://xenobiasoftsudoku-prod.azurewebsites.net" |
| 65 | + |
| 66 | + # ------------------------------------------------------------------------- |
| 67 | + # Sudoku Game Settings |
| 68 | + # ------------------------------------------------------------------------- |
| 69 | + set_key "$LABEL" "Sudoku:Game:DefaultDifficulty" "Medium" |
| 70 | + set_key "$LABEL" "Sudoku:Game:MaxHintsPerGame" "3" |
| 71 | + set_key "$LABEL" "Sudoku:Game:AutoSaveIntervalSeconds" "30" |
| 72 | + set_key "$LABEL" "Sudoku:Game:EnableStatistics" "true" |
| 73 | + set_key "$LABEL" "Sudoku:UI:DefaultTheme" "Light" |
| 74 | + set_key "$LABEL" "Sudoku:UI:ShowTimer" "true" |
| 75 | + set_key "$LABEL" "Sudoku:UI:EnableAnimations" "true" |
| 76 | + set_key "$LABEL" "Sudoku:UI:CellSizePixels" "40" |
| 77 | + set_key "$LABEL" "Sudoku:Performance:GameStateCacheTimeoutSeconds" "300" |
| 78 | + set_key "$LABEL" "Sudoku:Performance:MaxConcurrentGamesPerUser" "5" |
| 79 | + set_key "$LABEL" "Sudoku:Performance:EnableResponseCompression" "true" |
| 80 | + |
| 81 | + # ------------------------------------------------------------------------- |
| 82 | + # Logging |
| 83 | + # ------------------------------------------------------------------------- |
| 84 | + set_key "$LABEL" "Logging:LogLevel:Default" "Information" |
| 85 | + set_key "$LABEL" "Logging:LogLevel:Microsoft.AspNetCore" "Warning" |
| 86 | + set_key "$LABEL" "Logging:ApplicationInsights:LogLevel:Default" "Information" |
| 87 | + set_key "$LABEL" "Logging:ApplicationInsights:LogLevel:Microsoft" "Warning" |
| 88 | + |
| 89 | + # ------------------------------------------------------------------------- |
| 90 | + # Swagger (disabled in production) |
| 91 | + # ------------------------------------------------------------------------- |
| 92 | + set_key "$LABEL" "EnableSwagger" "false" |
| 93 | + |
| 94 | + echo "" |
| 95 | + echo "Done! Production keys set in '$APP_CONFIG_NAME'." |
| 96 | +} |
| 97 | + |
| 98 | +# ============================================================================= |
| 99 | +# Development settings |
| 100 | +# ============================================================================= |
| 101 | +push_development() { |
| 102 | + local LABEL="Development" |
| 103 | + echo "" |
| 104 | + echo "Setting App Configuration keys (label: $LABEL)" |
| 105 | + echo "---------------------------------------------------------------------" |
| 106 | + |
| 107 | + # ------------------------------------------------------------------------- |
| 108 | + # Cosmos DB (same account as prod, separate container for dev data) |
| 109 | + # ------------------------------------------------------------------------- |
| 110 | + set_key "$LABEL" "UseCosmosDb" "true" |
| 111 | + set_key "$LABEL" "CosmosDb:DatabaseName" "sudoku" |
| 112 | + set_key "$LABEL" "CosmosDb:ContainerName" "games-dev" |
| 113 | + set_key "$LABEL" "CosmosDb:UseManagedIdentity" "true" |
| 114 | + set_key "$LABEL" "CosmosDb:AccountEndpoint" "https://cosmos-sudoku-prod.documents.azure.com:443/" |
| 115 | + set_key "$LABEL" "CosmosDb:ConnectionMode" "Direct" |
| 116 | + |
| 117 | + # ------------------------------------------------------------------------- |
| 118 | + # Azure Storage |
| 119 | + # ------------------------------------------------------------------------- |
| 120 | + set_key "$LABEL" "AzureStorage:ContainerName" "sudoku-games" |
| 121 | + set_key "$LABEL" "AzureStorage:UseManagedIdentity" "true" |
| 122 | + set_key "$LABEL" "AzureStorage:AccountName" "stxenobiasoftprod" |
| 123 | + |
| 124 | + # ------------------------------------------------------------------------- |
| 125 | + # API (no CORS restriction — API uses AllowAnyOrigin() in Development) |
| 126 | + # ------------------------------------------------------------------------- |
| 127 | + set_key "$LABEL" "ApiBaseUrl" "http://sudoku-api" |
| 128 | + set_key "$LABEL" "AllowedHosts" "*" |
| 129 | + |
| 130 | + # ------------------------------------------------------------------------- |
| 131 | + # Sudoku Game Settings (same as production) |
| 132 | + # ------------------------------------------------------------------------- |
| 133 | + set_key "$LABEL" "Sudoku:Game:DefaultDifficulty" "Medium" |
| 134 | + set_key "$LABEL" "Sudoku:Game:MaxHintsPerGame" "3" |
| 135 | + set_key "$LABEL" "Sudoku:Game:AutoSaveIntervalSeconds" "30" |
| 136 | + set_key "$LABEL" "Sudoku:Game:EnableStatistics" "true" |
| 137 | + set_key "$LABEL" "Sudoku:UI:DefaultTheme" "Light" |
| 138 | + set_key "$LABEL" "Sudoku:UI:ShowTimer" "true" |
| 139 | + set_key "$LABEL" "Sudoku:UI:EnableAnimations" "true" |
| 140 | + set_key "$LABEL" "Sudoku:UI:CellSizePixels" "40" |
| 141 | + set_key "$LABEL" "Sudoku:Performance:GameStateCacheTimeoutSeconds" "300" |
| 142 | + set_key "$LABEL" "Sudoku:Performance:MaxConcurrentGamesPerUser" "5" |
| 143 | + set_key "$LABEL" "Sudoku:Performance:EnableResponseCompression" "true" |
| 144 | + |
| 145 | + # ------------------------------------------------------------------------- |
| 146 | + # Logging (more verbose in development) |
| 147 | + # ------------------------------------------------------------------------- |
| 148 | + set_key "$LABEL" "Logging:LogLevel:Default" "Debug" |
| 149 | + set_key "$LABEL" "Logging:LogLevel:Microsoft.AspNetCore" "Information" |
| 150 | + set_key "$LABEL" "Logging:ApplicationInsights:LogLevel:Default" "Information" |
| 151 | + set_key "$LABEL" "Logging:ApplicationInsights:LogLevel:Microsoft" "Warning" |
| 152 | + |
| 153 | + # ------------------------------------------------------------------------- |
| 154 | + # Swagger (enabled in development) |
| 155 | + # ------------------------------------------------------------------------- |
| 156 | + set_key "$LABEL" "EnableSwagger" "true" |
| 157 | + |
| 158 | + echo "" |
| 159 | + echo "Done! Development keys set in '$APP_CONFIG_NAME'." |
| 160 | +} |
| 161 | + |
| 162 | +# ============================================================================= |
| 163 | +# Run |
| 164 | +# ============================================================================= |
| 165 | +case "$TARGET_LABEL" in |
| 166 | + "Production") |
| 167 | + push_production |
| 168 | + ;; |
| 169 | + "Development") |
| 170 | + push_development |
| 171 | + ;; |
| 172 | + "both") |
| 173 | + push_production |
| 174 | + push_development |
| 175 | + ;; |
| 176 | + *) |
| 177 | + echo "Unknown label '$TARGET_LABEL'. Valid options: Production, Development, both" |
| 178 | + exit 1 |
| 179 | + ;; |
| 180 | +esac |
84 | 181 |
|
85 | 182 | echo "" |
86 | | -echo "Done! All keys set under label '$LABEL' in '$APP_CONFIG_NAME'." |
| 183 | +echo "All done!" |
87 | 184 | echo "" |
0 commit comments