Skip to content

Commit 5dcbf68

Browse files
Fix Web Apps + SQL Server Demo (#75)
* Added azlocal start-interception to all README files * Fix Web App + SQL Sample * Change secret name to be compliant with validate.sh * updated runner * skip if already exists * remove the pre-existing microsoft-prod.list * upgraded azurerm provider --------- Co-authored-by: Dris.S <idrissardary@outlook.com>
1 parent 5b30a8a commit 5dcbf68

8 files changed

Lines changed: 49 additions & 31 deletions

File tree

.github/workflows/run-samples.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ jobs:
7070
strategy:
7171
fail-fast: false
7272
matrix: ${{ fromJSON(needs.setup.outputs.matrix) }}
73-
runs-on: github-ubuntu2204-amd64-4
73+
runs-on: ubuntu-22.04
7474

7575
env:
7676
IMAGE_NAME: localstack/localstack-azure-alpha
@@ -163,6 +163,7 @@ jobs:
163163
# Required for the 'web-app-sql-database' sample which uses 'sqlcmd' to
164164
# initialize and verify the database schema in the local emulator.
165165
run: |
166+
sudo rm -f /etc/apt/sources.list.d/microsoft-prod.list
166167
curl https://packages.microsoft.com/keys/microsoft.asc | sudo tee /etc/apt/trusted.gpg.d/microsoft.asc
167168
curl https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/prod.list | sudo tee /etc/apt/sources.list.d/mssql-release.list
168169
sudo apt-get update

samples/web-app-sql-database/python/bicep/deploy.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ PREFIX='local'
55
SUFFIX='test'
66
TEMPLATE="main.bicep"
77
PARAMETERS="main.bicepparam"
8-
RESOURCE_GROUP_NAME="$PREFIX-webapp-sql-rg"
8+
RESOURCE_GROUP_NAME="$PREFIX-rg"
99
LOCATION="westeurope"
1010
VALIDATE_TEMPLATE=1
1111
USE_WHAT_IF=0
@@ -295,7 +295,7 @@ fi
295295

296296
# Create the zip package of the web app
297297
echo "Creating zip package of the web app..."
298-
zip -r "$ZIPFILE" app.py activities.py database.py static templates requirements.txt
298+
zip -r "$ZIPFILE" app.py activities.py certificates.py database.py static templates requirements.txt
299299

300300
# Deploy the web app
301301
echo "Deploying web app [$WEB_APP_NAME] with zip file [$ZIPFILE]..."

samples/web-app-sql-database/python/bicep/main.bicep

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ var sqlServerName = '${prefix}-sqlserver-${suffix}'
323323
var webAppName = '${prefix}-webapp-${suffix}'
324324
var appServicePlanName = '${prefix}-app-service-plan-${suffix}'
325325
var keyVaultName = '${prefix}-kv-${suffix}'
326-
var sqlConnectionStringSecretName = 'sql-connection-string'
326+
var sqlConnectionStringSecretName = '${prefix}-secret-${suffix}'
327327
var identity = {
328328
type: 'SystemAssigned'
329329
}
@@ -478,6 +478,7 @@ resource configAppSettings 'Microsoft.Web/sites/config@2024-11-01' = {
478478
KEY_VAULT_NAME: keyVaultName
479479
SECRET_NAME: sqlConnectionStringSecretName
480480
LOGIN_NAME: username
481+
KEYVAULT_URI: keyVault.properties.vaultUri
481482
}
482483
}
483484

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

33
# Variables
4+
PREFIX='local'
5+
SUFFIX='test'
6+
RESOURCE_GROUP_NAME="${PREFIX}-rg"
7+
SQL_SERVER_NAME="${PREFIX}-sqlserver-${SUFFIX}"
8+
SQL_DATABASE_NAME='PlannerDB'
9+
WEB_APP_NAME="${PREFIX}-webapp-${SUFFIX}"
10+
KEY_VAULT_NAME="${PREFIX}-kv-${SUFFIX}"
11+
SECRET_NAME="${PREFIX}-secret-${SUFFIX}"
12+
413
# Check resource group
14+
echo -e "[$RESOURCE_GROUP_NAME] resource group:\n"
515
az group show \
6-
--name local-rg \
7-
--output table
8-
9-
# List resources
10-
az resource list \
11-
--resource-group local-rg \
16+
--name "$RESOURCE_GROUP_NAME" \
1217
--output table
1318

1419
# Check Azure Web App
20+
echo -e "\n[$WEB_APP_NAME] web app:\n"
1521
az webapp show \
16-
--name local-webapp-test \
17-
--resource-group local-rg \
22+
--name "$WEB_APP_NAME" \
23+
--resource-group "$RESOURCE_GROUP_NAME" \
24+
--query "{name:name, state:state, defaultHostName:defaultHostName}" \
1825
--output table
1926

2027
# Check Azure SQL Server
28+
echo -e "\n[$SQL_SERVER_NAME] SQL server:\n"
2129
az sql server show \
22-
--name local-sqlserver-test \
23-
--resource-group local-rg \
30+
--name "$SQL_SERVER_NAME" \
31+
--resource-group "$RESOURCE_GROUP_NAME" \
2432
--output table
2533

2634
# Check Azure SQL Database
35+
echo -e "\n[$SQL_DATABASE_NAME] SQL database:\n"
2736
az sql db show \
28-
--name PlannerDB \
29-
--server local-sqlserver-test \
30-
--resource-group local-rg \
37+
--name "$SQL_DATABASE_NAME" \
38+
--server "$SQL_SERVER_NAME" \
39+
--resource-group "$RESOURCE_GROUP_NAME" \
3140
--output table
3241

3342
# Check Azure Key Vault
43+
echo -e "\n[$KEY_VAULT_NAME] Key Vault:\n"
3444
az keyvault show \
35-
--name local-kv-test \
36-
--resource-group local-rg \
45+
--name "$KEY_VAULT_NAME" \
46+
--resource-group "$RESOURCE_GROUP_NAME" \
3747
--output table
3848

3949
# Check Key Vault secret
50+
echo -e "\n[$SECRET_NAME] Key Vault secret:\n"
4051
az keyvault secret show \
41-
--vault-name local-kv-test \
42-
--name local-secret-test \
52+
--vault-name "$KEY_VAULT_NAME" \
53+
--name "$SECRET_NAME" \
4354
--query "{name:name, enabled:attributes.enabled, created:attributes.created}" \
44-
--output table
55+
--output table
56+
57+
# Print the list of resources in the resource group
58+
echo -e "\nListing resources in resource group [$RESOURCE_GROUP_NAME]...\n"
59+
az resource list --resource-group "$RESOURCE_GROUP_NAME" --output table
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
Flask==3.1.0
2-
azure-identity==1.25.1
1+
Flask==3.1.3
2+
azure-identity==1.25.3
33
pyodbc==5.3.0
4-
gunicorn==23.0.0
5-
python-dotenv==1.1.1
6-
azure-keyvault-secrets
7-
azure-keyvault-certificates
8-
cryptography
4+
gunicorn==25.3.0
5+
python-dotenv==1.2.2
6+
azure-keyvault-secrets==4.10.0
7+
azure-keyvault-certificates==4.10.0
8+
cryptography==46.0.7

samples/web-app-sql-database/python/terraform/providers.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ terraform {
44
required_providers {
55
azurerm = {
66
source = "hashicorp/azurerm"
7-
version = "=4.14.0"
7+
version = "=4.25.0"
88
}
99
}
1010
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
location = "westeurope"
2-
python_version = "3.12"
2+
python_version = "3.13"

samples/web-app-sql-database/python/terraform/variables.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,7 @@ variable "python_version" {
281281

282282
validation {
283283
condition = contains([
284+
"3.13",
284285
"3.12",
285286
"3.11",
286287
"3.10",

0 commit comments

Comments
 (0)