Skip to content

Commit dbfcc3d

Browse files
committed
Debuging environment value for demo
1 parent 4126029 commit dbfcc3d

File tree

2 files changed

+29
-13
lines changed

2 files changed

+29
-13
lines changed

app/app.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,14 @@
8484
border-radius: 20px;
8585
font-weight: bold;
8686
}
87+
.demo-value {
88+
display: inline-block;
89+
padding: 5px 15px;
90+
background: #FF6B35;
91+
border-radius: 20px;
92+
font-weight: bold;
93+
color: white;
94+
}
8795
</style>
8896
</head>
8997
<body>
@@ -94,6 +102,7 @@
94102
<p>Status: <span class="status">Running</span></p>
95103
<p>Timestamp: {{ timestamp }}</p>
96104
<p>Environment: {{ environment }}</p>
105+
<p>Demo Value: <span class="demo-value">{{ demo_value }}</span></p>
97106
</div>
98107
99108
<div class="info-card">
@@ -114,6 +123,7 @@
114123
<li>Azure Container Registry integration</li>
115124
<li>Health check endpoints</li>
116125
<li>Environment configuration</li>
126+
<li>Environment variable display (DEMO_VALUE)</li>
117127
</ul>
118128
</div>
119129
@@ -130,13 +140,15 @@
130140
@app.route('/')
131141
def home():
132142
"""Main page with system information"""
143+
demo_value = os.environ.get('DEMO_VALUE', 'Not Set')
133144
return render_template_string(HTML_TEMPLATE,
134145
timestamp=datetime.now().isoformat(),
135146
environment=os.environ.get('FLASK_ENV', 'production'),
136147
hostname=socket.gethostname(),
137148
platform=f"{platform.system()} {platform.release()}",
138149
python_version=platform.python_version(),
139-
architecture=platform.machine()
150+
architecture=platform.machine(),
151+
demo_value=demo_value
140152
)
141153

142154
@app.route('/health')
@@ -160,7 +172,8 @@ def api_info():
160172
'python_implementation': platform.python_implementation(),
161173
'uptime': time.time(),
162174
'environment': os.environ.get('FLASK_ENV', 'production'),
163-
'port': PORT
175+
'port': PORT,
176+
'demo_value': os.environ.get('DEMO_VALUE', 'Not Set')
164177
})
165178

166179
@app.route('/api/status')
@@ -172,7 +185,8 @@ def api_status():
172185
'environment': os.environ.get('FLASK_ENV', 'production'),
173186
'version': '1.0.0',
174187
'framework': 'Flask',
175-
'language': 'Python'
188+
'language': 'Python',
189+
'demo_value': os.environ.get('DEMO_VALUE', 'Not Set')
176190
})
177191

178192
@app.errorhandler(404)
@@ -197,6 +211,7 @@ def internal_error(error):
197211
print(f"Starting Python Demo App on port {PORT}")
198212
print(f"Environment: {os.environ.get('FLASK_ENV', 'production')}")
199213
print(f"Platform: {platform.system()} {platform.release()}")
214+
print(f"Demo Value: {os.environ.get('DEMO_VALUE', 'Not Set')}")
200215

201216
# Run the Flask app
202217
app.run(

infra/main.tf

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,16 @@ resource "azurerm_service_plan" "main" {
6161

6262
# Create App Service (Web App)
6363
resource "azurerm_linux_web_app" "main" {
64-
name = var.app_service_name
65-
resource_group_name = azurerm_resource_group.main.name
66-
location = azurerm_service_plan.main.location
67-
service_plan_id = azurerm_service_plan.main.id
68-
64+
name = var.app_service_name
65+
resource_group_name = azurerm_resource_group.main.name
66+
location = azurerm_service_plan.main.location
67+
service_plan_id = azurerm_service_plan.main.id
68+
webdeploy_publish_basic_authentication_enabled = false
69+
ftp_publish_basic_authentication_enabled = true
6970
site_config {
70-
always_on = var.app_service_always_on
71-
health_check_path = var.health_check_path
71+
always_on = var.app_service_always_on
72+
health_check_path = var.health_check_path
73+
container_registry_use_managed_identity = true
7274

7375
application_stack {
7476
docker_image_name = "${var.docker_image_name}:${var.docker_image_tag}"
@@ -79,11 +81,10 @@ resource "azurerm_linux_web_app" "main" {
7981
app_settings = merge(
8082
{
8183
"DOCKER_REGISTRY_SERVER_URL" = "https://${azurerm_container_registry.main.login_server}"
82-
"DOCKER_REGISTRY_SERVER_USERNAME" = ""
83-
"DOCKER_REGISTRY_SERVER_PASSWORD" = ""
8484
"WEBSITES_ENABLE_APP_SERVICE_STORAGE" = "false"
8585
"WEBSITES_PORT" = var.websites_port
8686
"DOCKER_ENABLE_CI" = "true"
87+
"DEMO_VALUE" = "Test value"
8788
},
8889
var.additional_app_settings
8990
)
@@ -97,7 +98,7 @@ resource "azurerm_linux_web_app" "main" {
9798
Project = var.project_name
9899
}
99100

100-
depends_on = [azurerm_container_registry.main, azurerm_role_assignment.acr_pull]
101+
depends_on = [azurerm_container_registry.main]
101102
}
102103

103104
# Grant App Service access to Container Registry using managed identity

0 commit comments

Comments
 (0)